Skip to content

Commit

Permalink
Allow Syncing Properties Between Dim
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Aug 6, 2024
1 parent aa16cee commit f6c516d
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/groovy-tests/recipeMapTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import static gregtech.api.GTValues.*
// via labs config.
// Example for Temperature Property:
// gregtech/api/recipes/recipeproperties/TemperatureProperty@drawInfo@(Lnet/minecraft/client/Minecraft;IIILjava/lang/Object;)V
// All GT Properties, in 2.8.10, require this change.

// Building Test Recipes
mods.gregtech.sifter.recipeBuilder()
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,13 @@ public static class Advanced {
@Config.LangKey("config.nomilabs.advanced.disable_xp_scaling")
public boolean disableXpScaling = false;

@Config.Comment({ "Whether to enable Syncing between Dimensions.",
"This means that changing difficulty, time, spawn point or other properties in one dimension will sync to all dimensions.",
"[default: false]" })
@Config.LangKey("config.nomilabs.advanced.sync_dim_properties")
@Config.RequiresWorldRestart
public boolean syncDimProperties = false;

@Config.Comment({ "Amount of XP Per Level, for Linear XP Scaling.",
"Used for Linear XP Scaling in Actually Additions and EIO Machines.",
"MUST be used in conjunction with UT's Linear XP Scaling Config, else weird issues may happen!",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.nomiceu.nomilabs.mixin;

import net.minecraft.world.storage.DerivedWorldInfo;
import net.minecraft.world.storage.WorldInfo;

import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import com.nomiceu.nomilabs.mixinhelper.AccessibleDerivedWorldInfo;

/**
* Allows Accessing the Delegate of Derived World Infos.
*/
@Mixin(DerivedWorldInfo.class)
public class DerivedWorldInfoMixin implements AccessibleDerivedWorldInfo {

@Shadow
@Final
private WorldInfo delegate;

@Override
public WorldInfo getDelegate() {
return delegate;
}
}
33 changes: 33 additions & 0 deletions src/main/java/com/nomiceu/nomilabs/mixin/WorldMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.nomiceu.nomilabs.mixin;

import net.minecraft.profiler.Profiler;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.WorldInfo;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.nomiceu.nomilabs.config.LabsConfig;
import com.nomiceu.nomilabs.mixinhelper.AccessibleDerivedWorldInfo;

/**
* Allows Syncing of Properties Between Dimensions.
*/
@Mixin(World.class)
public class WorldMixin {

@Shadow
protected WorldInfo worldInfo;

@Inject(method = "<init>", at = @At("RETURN"))
private void findProperWorldInfo(ISaveHandler saveHandlerIn, WorldInfo info, WorldProvider providerIn,
Profiler profilerIn, boolean client, CallbackInfo ci) {
if (LabsConfig.advanced.syncDimProperties && info instanceof AccessibleDerivedWorldInfo adri)
worldInfo = adri.getDelegate();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.nomiceu.nomilabs.mixinhelper;

import net.minecraft.world.storage.WorldInfo;

public interface AccessibleDerivedWorldInfo {

WorldInfo getDelegate();
}
8 changes: 6 additions & 2 deletions src/main/resources/assets/nomilabs/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ config.nomilabs.content.custom_content.items=Enable Custom Items
config.nomilabs.content.custom_content.blocks=Enable Custom Blocks
config.nomilabs.content.custom_content.fluids=Enable Custom Fluids
config.nomilabs.content.custom_content.complex_recipes=Enable Complex Recipes
config.nomilabs.content.custom_content.remap=Remap Old Content Tweaker Content
config.nomilabs.content.custom_content.custom_void=Enable Custom Void Dimension

config.nomilabs.content.gt_content=Custom GT Content Settings
config.nomilabs.content.gt_content.tooltip=Custom GT Content Settings
config.nomilabs.content.gt_content.materials=Enable Custom GT Materials
config.nomilabs.content.gt_content.perfect_gems=Enable Perfect Gems
config.nomilabs.content.gt_content.remap_perfect_gems=Remap Old Perfect Gems
config.nomilabs.content.gt_content.blocks=Enable Custom GT Blocks
config.nomilabs.content.gt_content.old_multiblocks=Enable Old Multiblocks
config.nomilabs.content.gt_content.new_multiblocks=Enable New Multiblocks
Expand Down Expand Up @@ -88,6 +87,11 @@ config.nomilabs.advanced.language_modify_option=Language Tab Modifier Mode
config.nomilabs.advanced.window=Minecraft Window Title Overrides
config.nomilabs.advanced.difficulty=Difficulty Overrides
config.nomilabs.advanced.server_motd_substitutions=Enable Server MOTD Substitutions
config.nomilabs.advanced.sync_dim_properties=Sync Dimension Properties
config.nomilabs.advanced.client_side_fields=Client Side ONLY Fields
config.nomilabs.advanced.client_side_methods=Client Side ONLY Methods
config.nomilabs.advanced.server_side_fields=Server Side ONLY Fields
config.nomilabs.advanced.server_side_methods=Server Side ONLY Methods

config.nomilabs.advanced.tiers=Quest Tier Detector Settings
config.nomilabs.advanced.tiers.normal_qb_ids=Normal Mode Quest IDs
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/mixins.nomilabs.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
"mixins": [
"AccessibleFluidRegistry",
"CommandDifficultyMixin",
"DerivedWorldInfoMixin",
"FluidRegistryMixin",
"ForgeRegistryMixin",
"GameDataMixin",
"ItemStackMixin",
"NarratorMixin",
"SnapshotMixin",
"WorldLoadHandler"
"WorldLoadHandler",
"WorldMixin"
],
"client": [
"EntityPlayerSPMixin",
Expand Down

0 comments on commit f6c516d

Please sign in to comment.