From 8ecf51445a0605b8a14464af0e74dd3416a6ede6 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sun, 22 Mar 2020 01:10:21 +0100 Subject: [PATCH] Ore Gen Inconsistencies - Features now get registered on init, addresses #102 - Fixed motors starting with a scrollvalue of 0 - Fixed deployers not initializing properly - Saws can now break leaves when moved - Kinetic networks now actually incorporate pre-config-update capacity/impact of a component --- src/main/java/com/simibubi/create/Create.java | 2 ++ .../com/simibubi/create/config/CWorldGen.java | 6 ++++++ .../create/foundation/item/ItemDescription.java | 7 +++---- .../foundation/world/AllWorldFeatures.java | 6 +++--- .../modules/contraptions/KineticNetwork.java | 16 ++++++++-------- .../modules/contraptions/base/KineticBlock.java | 1 - .../contraptions/base/KineticTileEntity.java | 13 ++++++------- .../components/actors/SawMovementBehaviour.java | 3 ++- .../components/motor/MotorTileEntity.java | 1 + 9 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index 5fe815d27..5f2b2a1c1 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -8,6 +8,7 @@ import org.apache.logging.log4j.Logger; import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.command.CreateCommand; import com.simibubi.create.foundation.command.ServerLagger; +import com.simibubi.create.foundation.world.AllWorldFeatures; import com.simibubi.create.modules.ModuleLoadedCondition; import com.simibubi.create.modules.contraptions.TorquePropagator; import com.simibubi.create.modules.logistics.RedstoneLinkNetworkHandler; @@ -62,6 +63,7 @@ public class Create { modEventBus.addListener(AllConfigs::onLoad); modEventBus.addListener(AllConfigs::onReload); CreateClient.addListeners(modEventBus); + AllWorldFeatures.reload(); } public static void init(final FMLCommonSetupEvent event) { diff --git a/src/main/java/com/simibubi/create/config/CWorldGen.java b/src/main/java/com/simibubi/create/config/CWorldGen.java index 7464e6859..b945ba94c 100644 --- a/src/main/java/com/simibubi/create/config/CWorldGen.java +++ b/src/main/java/com/simibubi/create/config/CWorldGen.java @@ -20,6 +20,12 @@ public class CWorldGen extends ConfigBase { super.onReload(); } + @Override + public void onLoad() { + AllWorldFeatures.reload(); + super.onLoad(); + } + @Override public String getName() { return "world"; diff --git a/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java b/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java index 63d47a7dc..7422a3933 100644 --- a/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java +++ b/src/main/java/com/simibubi/create/foundation/item/ItemDescription.java @@ -135,9 +135,8 @@ public class ItemDescription { add(linesOnShift, level); String genSpeed = generatorSpeed(block, rpmUnit); - if (!genSpeed.equals("")){ - add(linesOnShift, ""); - add(linesOnShift, GREEN + genSpeed); + if (!genSpeed.equals("")) { + add(linesOnShift, GREEN + " " + genSpeed); } } @@ -264,7 +263,7 @@ public class ItemDescription { return linesOnShift; } - private String generatorSpeed(Block block, String unitRPM){ + private String generatorSpeed(Block block, String unitRPM) { String value = ""; if (block instanceof WaterWheelBlock) { diff --git a/src/main/java/com/simibubi/create/foundation/world/AllWorldFeatures.java b/src/main/java/com/simibubi/create/foundation/world/AllWorldFeatures.java index f278e19b4..382100e5d 100644 --- a/src/main/java/com/simibubi/create/foundation/world/AllWorldFeatures.java +++ b/src/main/java/com/simibubi/create/foundation/world/AllWorldFeatures.java @@ -44,13 +44,13 @@ public enum AllWorldFeatures { for (AllWorldFeatures entry : AllWorldFeatures.values()) { for (Biome biome : ForgeRegistries.BIOMES) { - if (entry.featureInstances.containsKey(biome)) + if (entry.featureInstances.containsKey(biome)) biome.getFeatures(entry.feature.getGenerationStage()).remove(entry.featureInstances.remove(biome)); Optional> createFeature = entry.feature.createFeature(biome); - if (!createFeature.isPresent()) + if (!createFeature.isPresent()) continue; - + entry.featureInstances.put(biome, createFeature.get()); biome.addFeature(entry.feature.getGenerationStage(), createFeature.get()); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/KineticNetwork.java b/src/main/java/com/simibubi/create/modules/contraptions/KineticNetwork.java index 5b550da65..a0ae23f18 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/KineticNetwork.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/KineticNetwork.java @@ -37,22 +37,22 @@ public class KineticNetwork { if (members.containsKey(te)) return; if (te.isSource()) { - float capacity = te.getAddedStressCapacity(); - unloadedCapacity -= capacity * getStressMultiplierForSpeed(te.getGeneratedSpeed()); - if (unloadedCapacity < 0) - unloadedCapacity = 0; - sources.put(te, capacity); + unloadedCapacity -= lastCapacity * getStressMultiplierForSpeed(te.getGeneratedSpeed()); + float addedStressCapacity = te.getAddedStressCapacity(); + sources.put(te, addedStressCapacity); } + unloadedStress -= lastStress * getStressMultiplierForSpeed(te.getTheoreticalSpeed()); float stressApplied = te.getStressApplied(); - unloadedStress -= stressApplied * getStressMultiplierForSpeed(te.getTheoreticalSpeed()); - if (unloadedStress < 0) - unloadedStress = 0; members.put(te, stressApplied); unloadedMembers--; if (unloadedMembers < 0) unloadedMembers = 0; + if (unloadedCapacity < 0) + unloadedCapacity = 0; + if (unloadedStress < 0) + unloadedStress = 0; } public void add(KineticTileEntity te) { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticBlock.java index 6bea19b3f..215172baa 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticBlock.java @@ -102,7 +102,6 @@ public abstract class KineticBlock extends Block implements IRotate { return; if (worldIn.isRemote()) return; - tileEntity.removeSource(); RotationPropagator.handleAdded(worldIn.getWorld(), pos, tileEntity); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java index ae6cceebf..688a16419 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java @@ -51,13 +51,12 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick @Override public void initialize() { - if (!hasNetwork()) - return; - - KineticNetwork network = getOrCreateNetwork(); - if (!network.initialized) - network.initFromTE(capacity, stress, networkSize); - network.addSilently(this, lastCapacityProvided, lastStressApplied); + if (hasNetwork()) { + KineticNetwork network = getOrCreateNetwork(); + if (!network.initialized) + network.initFromTE(capacity, stress, networkSize); + network.addSilently(this, lastCapacityProvided, lastStressApplied); + } super.initialize(); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/SawMovementBehaviour.java index bd03396b3..00071f5ea 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/SawMovementBehaviour.java @@ -31,7 +31,8 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { @Override public boolean canBreak(World world, BlockPos breakingPos, BlockState state) { - return super.canBreak(world, breakingPos, state) && state.isIn(BlockTags.LOGS); + return super.canBreak(world, breakingPos, state) + && (state.isIn(BlockTags.LOGS) || state.isIn(BlockTags.LEAVES)); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java index c342777c1..06ee179ee 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java @@ -32,6 +32,7 @@ public class MotorTileEntity extends GeneratingKineticTileEntity { generatedSpeed = new ScrollValueBehaviour(Lang.translate("generic.speed"), this, slot); generatedSpeed.between(-max, max); generatedSpeed.value = DEFAULT_SPEED; + generatedSpeed.scrollableValue = DEFAULT_SPEED; generatedSpeed.withUnit(i -> Lang.translate("generic.unit.rpm")); generatedSpeed.withCallback(i -> this.updateGeneratedRotation()); generatedSpeed.withStepFunction(MotorTileEntity::step);