From 6173f9600cee712f4806c3919e9b477b2954d61e Mon Sep 17 00:00:00 2001 From: MRH0 Date: Fri, 6 Aug 2021 01:27:14 +0200 Subject: [PATCH 1/9] Integration support for Furnace Engine speed modifiers + FurnaceEngineModifiers which hold a Block -> float map of modifiers ~ Changed FurnaceEngineTileEntity to use the FurnaceEngineModifiers map instead of hardcoded modifier fro the Blast Furnace. This will allow addon modders to change the speed modifier of a Furnace block. --- src/main/java/com/simibubi/create/Create.java | 2 + .../engine/FurnaceEngineModifiers.java | 39 +++++++++++++++++++ .../engine/FurnaceEngineTileEntity.java | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineModifiers.java diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index a5bc411e7..c7153e531 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -9,6 +9,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.simibubi.create.content.CreateItemGroup; import com.simibubi.create.content.contraptions.TorquePropagator; +import com.simibubi.create.content.contraptions.components.flywheel.engine.FurnaceEngineModifiers; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController; import com.simibubi.create.content.curiosities.weapons.PotatoCannonProjectileTypes; import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler; @@ -92,6 +93,7 @@ public class Create { AllWorldFeatures.register(); AllEnchantments.register(); AllConfigs.register(ModLoadingContext.get()); + FurnaceEngineModifiers.register(); ForgeMod.enableMilkFluid(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineModifiers.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineModifiers.java new file mode 100644 index 000000000..e785540de --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineModifiers.java @@ -0,0 +1,39 @@ +package com.simibubi.create.content.contraptions.components.flywheel.engine; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; + +public class FurnaceEngineModifiers { + + public final static FurnaceEngineModifiers INSTANCE = new FurnaceEngineModifiers(); + + protected Map blockModifiers; + + public FurnaceEngineModifiers(Map blockModifiers) { + this.blockModifiers = blockModifiers; + } + + public FurnaceEngineModifiers() { + this(new HashMap<>()); + } + + public void set(Block block, float modifier) { + this.blockModifiers.put(block, modifier); + } + + public float getModifier(BlockState state, float def) { + return blockModifiers.getOrDefault(state.getBlock(), def); + } + + public float getModifier(BlockState state) { + return getModifier(state, 1f); + } + + public static void register() { + INSTANCE.set(Blocks.BLAST_FURNACE, 2f); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineTileEntity.java index 22742c712..03f22efe0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineTileEntity.java @@ -25,7 +25,7 @@ public class FurnaceEngineTileEntity extends EngineTileEntity { if (!(state.getBlock() instanceof AbstractFurnaceBlock)) return; - float modifier = state.getBlock() == Blocks.BLAST_FURNACE ? 2 : 1; + float modifier = FurnaceEngineModifiers.INSTANCE.getModifier(state); boolean active = state.hasProperty(AbstractFurnaceBlock.LIT) && state.getValue(AbstractFurnaceBlock.LIT); float speed = active ? 16 * modifier : 0; float capacity = From 576a5922b4d45a5d365219263ed40e21faf3c665 Mon Sep 17 00:00:00 2001 From: Stephen Barnes Date: Sat, 18 Sep 2021 14:50:05 -0500 Subject: [PATCH 2/9] Add config options for harvesters --- .../actors/HarvesterMovementBehaviour.java | 22 ++++++++++++++----- .../create/foundation/config/CKinetics.java | 4 ++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java index 5b144822e..c66f22dcb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java @@ -12,6 +12,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; +import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; @@ -95,7 +96,9 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { MutableBoolean seedSubtracted = new MutableBoolean(notCropButCuttable); BlockState state = stateVisited; BlockHelper.destroyBlockAs(world, pos, null, item, effectChance, stack -> { - if (!seedSubtracted.getValue() && stack.sameItem(new ItemStack(state.getBlock()))) { + if (AllConfigs.SERVER.kinetics.harvesterReplants.get() + && !seedSubtracted.getValue() + && stack.sameItem(new ItemStack(state.getBlock()))) { stack.shrink(1); seedSubtracted.setTrue(); } @@ -108,7 +111,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { private boolean isValidCrop(World world, BlockPos pos, BlockState state) { if (state.getBlock() instanceof CropsBlock) { CropsBlock crop = (CropsBlock) state.getBlock(); - if (!crop.isMaxAge(state)) + if (!crop.isMaxAge(state) && !AllConfigs.SERVER.kinetics.harvestPartiallyGrown.get()) return false; return true; } @@ -120,9 +123,10 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { if (!property.getName() .equals(BlockStateProperties.AGE_1.getName())) continue; - if (((IntegerProperty) property).getPossibleValues() - .size() - 1 != state.getValue((IntegerProperty) property) - .intValue()) + if (!AllConfigs.SERVER.kinetics.harvestPartiallyGrown.get() + && (((IntegerProperty) property).getPossibleValues().size() - 1 + != state.getValue((IntegerProperty) property) + .intValue())) continue; return true; } @@ -161,6 +165,14 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { } private BlockState cutCrop(World world, BlockPos pos, BlockState state) { + if (!AllConfigs.SERVER.kinetics.harvesterReplants.get()) { + if (state.getFluidState() + .isEmpty()) + return Blocks.AIR.defaultBlockState(); + return state.getFluidState() + .createLegacyBlock(); + } + Block block = state.getBlock(); if (block instanceof CropsBlock) { CropsBlock crop = (CropsBlock) block; diff --git a/src/main/java/com/simibubi/create/foundation/config/CKinetics.java b/src/main/java/com/simibubi/create/foundation/config/CKinetics.java index 1ee7ec82c..3662cba3e 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CKinetics.java +++ b/src/main/java/com/simibubi/create/foundation/config/CKinetics.java @@ -38,6 +38,8 @@ public class CKinetics extends ConfigBase { public ConfigInt maxCartCouplingLength = i(32, 1, "maxCartCouplingLength", Comments.maxCartCouplingLength); public ConfigEnum spawnerMovement = e(SpawnerMovementSetting.NO_PICKUP, "movableSpawners", Comments.spawnerMovement); + public ConfigBool harvestPartiallyGrown = b(false, "harvestPartiallyGrown", Comments.harvestPartiallyGrown); + public ConfigBool harvesterReplants = b(true, "harvesterReplants", Comments.harvesterReplants); public CStress stressValues = nested(1, CStress::new, Comments.stress); @@ -74,6 +76,8 @@ public class CKinetics extends ConfigBase { static String maxPistonPoles = "Maximum amount of extension poles behind a Mechanical Piston."; static String maxRopeLength = "Max length of rope available off a Rope Pulley."; static String maxCartCouplingLength = "Maximum allowed distance of two coupled minecarts."; + static String harvestPartiallyGrown = "Whether harvesters should break crops that aren't fully grown."; + static String harvesterReplants = "Whether harvesters should replant crops after harvesting."; static String stats = "Configure speed/capacity levels for requirements and indicators."; static String rpm = "[in Revolutions per Minute]"; static String su = "[in Stress Units]"; From 85d64010bd062706c595ce2a57e49cede42824b5 Mon Sep 17 00:00:00 2001 From: Stephen Barnes Date: Sat, 18 Sep 2021 16:14:40 -0500 Subject: [PATCH 3/9] Config option to make mounted storage output-only --- .../components/structureMovement/MovementBehaviour.java | 7 ++++++- .../com/simibubi/create/foundation/config/CKinetics.java | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java index b7b3400eb..08b834108 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java @@ -5,6 +5,7 @@ import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; +import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -33,7 +34,11 @@ public abstract class MovementBehaviour { } public void dropItem(MovementContext context, ItemStack stack) { - ItemStack remainder = ItemHandlerHelper.insertItem(context.contraption.inventory, stack, false); + ItemStack remainder; + if (AllConfigs.SERVER.kinetics.moveItemsToStorage.get()) + remainder = ItemHandlerHelper.insertItem(context.contraption.inventory, stack, false); + else + remainder = stack; if (remainder.isEmpty()) return; diff --git a/src/main/java/com/simibubi/create/foundation/config/CKinetics.java b/src/main/java/com/simibubi/create/foundation/config/CKinetics.java index 3662cba3e..f476c0a3d 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CKinetics.java +++ b/src/main/java/com/simibubi/create/foundation/config/CKinetics.java @@ -38,6 +38,7 @@ public class CKinetics extends ConfigBase { public ConfigInt maxCartCouplingLength = i(32, 1, "maxCartCouplingLength", Comments.maxCartCouplingLength); public ConfigEnum spawnerMovement = e(SpawnerMovementSetting.NO_PICKUP, "movableSpawners", Comments.spawnerMovement); + public ConfigBool moveItemsToStorage = b(true, "moveItemsToStorage", Comments.moveItemsToStorage); public ConfigBool harvestPartiallyGrown = b(false, "harvestPartiallyGrown", Comments.harvestPartiallyGrown); public ConfigBool harvesterReplants = b(true, "harvesterReplants", Comments.harvesterReplants); @@ -76,6 +77,8 @@ public class CKinetics extends ConfigBase { static String maxPistonPoles = "Maximum amount of extension poles behind a Mechanical Piston."; static String maxRopeLength = "Max length of rope available off a Rope Pulley."; static String maxCartCouplingLength = "Maximum allowed distance of two coupled minecarts."; + static String moveItemsToStorage = + "Whether items mined or harvested by contraptions should be placed in their mounted storage."; static String harvestPartiallyGrown = "Whether harvesters should break crops that aren't fully grown."; static String harvesterReplants = "Whether harvesters should replant crops after harvesting."; static String stats = "Configure speed/capacity levels for requirements and indicators."; From f9791243f87c196bb11e2812cf2a865481d7ce30 Mon Sep 17 00:00:00 2001 From: Stephen Barnes Date: Sat, 18 Sep 2021 16:59:27 -0500 Subject: [PATCH 4/9] Add config option to prevent placing fluid source blocks --- .../content/contraptions/fluids/OpenEndedPipe.java | 5 +++++ .../fluids/actors/FluidFillingBehaviour.java | 9 ++++++--- .../com/simibubi/create/foundation/config/CFluids.java | 5 ++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java index f0b119fa7..47e344737 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java @@ -11,6 +11,7 @@ import javax.annotation.Nullable; import com.simibubi.create.AllFluids; import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler; import com.simibubi.create.foundation.advancement.AllTriggers; +import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.utility.BlockFace; @@ -214,6 +215,10 @@ public class OpenEndedPipe extends FlowSource { .scheduleTick(outputPos, Fluids.WATER, 1); return true; } + + if (!AllConfigs.SERVER.fluids.placeFluidSourceBlocks.get()) + return true; + world.setBlock(outputPos, fluid.getFluid() .defaultFluidState() .createLegacyBlock(), 3); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java index 612b82201..f3d2635a4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java @@ -7,6 +7,7 @@ import java.util.Objects; import java.util.Set; import com.simibubi.create.foundation.advancement.AllTriggers; +import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; @@ -126,12 +127,13 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { int maxBlocks = maxBlocks(); boolean evaporate = world.dimensionType() .ultraWarm() && fluid.is(FluidTags.WATER); + boolean canPlaceSources = AllConfigs.SERVER.fluids.placeFluidSourceBlocks.get(); - if ((!fillInfinite() && infinite) || evaporate) { + if ((!fillInfinite() && infinite) || evaporate || !canPlaceSources) { FluidState fluidState = world.getFluidState(rootPos); boolean equivalentTo = fluidState.getType() .isSame(fluid); - if (!equivalentTo && !evaporate) + if (!equivalentTo && !evaporate && canPlaceSources) return false; if (simulate) return true; @@ -142,7 +144,8 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { int k = root.getZ(); world.playSound(null, i, j, k, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); - } + } else if (!canPlaceSources) + AllTriggers.triggerForNearbyPlayers(AllTriggers.HOSE_PULLEY, world, tileEntity.getBlockPos(), 8); return true; } diff --git a/src/main/java/com/simibubi/create/foundation/config/CFluids.java b/src/main/java/com/simibubi/create/foundation/config/CFluids.java index f0c3c251c..3fdc99dac 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CFluids.java +++ b/src/main/java/com/simibubi/create/foundation/config/CFluids.java @@ -12,6 +12,8 @@ public class CFluids extends ConfigBase { public ConfigBool fillInfinite = b(false, "fillInfinite",Comments.fillInfinite); public ConfigInt hosePulleyRange = i(128, 1, "hosePulleyRange", Comments.blocks, Comments.hosePulleyRange); + public ConfigBool placeFluidSourceBlocks = b(true, "placeFluidSourceBlocks", Comments.placeFluidSourceBlocks); + @Override public String getName() { return "fluids"; @@ -29,7 +31,8 @@ public class CFluids extends ConfigBase { static String toDisable = "[-1 to disable this behaviour]"; static String hosePulleyBlockThreshold = "The minimum amount of fluid blocks the hose pulley needs to find before deeming it an infinite source."; - static String fillInfinite="Does hose pulley poor fluids to the world even if it is an infinite source?"; + static String fillInfinite = "Does hose pulley pour fluids into infinite sources?"; + static String placeFluidSourceBlocks = "Can open-ended pipes and hose pulleys place fluid source blocks?"; } } From cff90d6211daf865af0d4ac636587c1ea6b9e4e5 Mon Sep 17 00:00:00 2001 From: Stephen Barnes Date: Sat, 18 Sep 2021 17:12:22 -0500 Subject: [PATCH 5/9] Fix hose pulley particle position bug --- .../contraptions/fluids/actors/FluidFillingBehaviour.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java index f3d2635a4..814651f9d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/FluidFillingBehaviour.java @@ -137,7 +137,7 @@ public class FluidFillingBehaviour extends FluidManipulationBehaviour { return false; if (simulate) return true; - playEffect(world, null, fluid, false); + playEffect(world, root, fluid, false); if (evaporate) { int i = root.getX(); int j = root.getY(); From a2043bebc56b1804a13abaa1686cb15daae1bec5 Mon Sep 17 00:00:00 2001 From: Stephen Barnes Date: Sun, 19 Sep 2021 01:10:38 -0500 Subject: [PATCH 6/9] Make FluidTransportBehaviour fields public --- .../contraptions/fluids/FluidTransportBehaviour.java | 6 +++--- .../create/content/contraptions/fluids/PipeConnection.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidTransportBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidTransportBehaviour.java index 87d73c00c..0d7bb5199 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidTransportBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/FluidTransportBehaviour.java @@ -29,14 +29,14 @@ public abstract class FluidTransportBehaviour extends TileEntityBehaviour { public static BehaviourType TYPE = new BehaviourType<>(); - enum UpdatePhase { + public enum UpdatePhase { WAIT_FOR_PUMPS, // Do not run Layer II logic while pumps could still be distributing pressure FLIP_FLOWS, // Do not cut any flows until all pipes had a chance to reverse them IDLE; // Operate normally } - Map interfaces; - UpdatePhase phase; + public Map interfaces; + public UpdatePhase phase; public FluidTransportBehaviour(SmartTileEntity te) { super(te); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/PipeConnection.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PipeConnection.java index 240883516..3ef881ba0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/PipeConnection.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/PipeConnection.java @@ -32,7 +32,7 @@ import net.minecraftforge.fml.DistExecutor; public class PipeConnection { - Direction side; + public Direction side; // Layer I Couple pressure; // [inbound, outward] From 94436584312b5fcb921c836fe6ff2a74d96faf1a Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Thu, 21 Oct 2021 18:47:38 +0200 Subject: [PATCH 7/9] Dummy beats null - Implement #2228 --- .../worldWrappers/DummyStatusListener.java | 18 ++++++++++++++++++ .../worldWrappers/WrappedServerWorld.java | 6 ++++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/utility/worldWrappers/DummyStatusListener.java diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/DummyStatusListener.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/DummyStatusListener.java new file mode 100644 index 000000000..b963a236c --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/DummyStatusListener.java @@ -0,0 +1,18 @@ +package com.simibubi.create.foundation.utility.worldWrappers; + +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.chunk.ChunkStatus; +import net.minecraft.world.chunk.listener.IChunkStatusListener; + +public class DummyStatusListener implements IChunkStatusListener { + + @Override + public void updateSpawnPos(ChunkPos p_219509_1_) {} + + @Override + public void onStatusChange(ChunkPos p_219508_1_, ChunkStatus p_219508_2_) {} + + @Override + public void stop() {} + +} diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedServerWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedServerWorld.java index 6161cbfc4..8104de717 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedServerWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedServerWorld.java @@ -37,8 +37,10 @@ public class WrappedServerWorld extends ServerWorld { protected World world; public WrappedServerWorld(World world) { - // Replace null with world.getChunkProvider().chunkManager.progressListener ? We had null in 1.15 - super(world.getServer(), Util.backgroundExecutor(), getLevelSaveFromWorld(world), (IServerWorldInfo) world.getLevelData(), world.dimension(), world.dimensionType(), null, ((ServerChunkProvider) world.getChunkSource()).getGenerator(), world.isDebug(), world.getBiomeManager().biomeZoomSeed, Collections.EMPTY_LIST, false); //, world.field_25143); + super(world.getServer(), Util.backgroundExecutor(), getLevelSaveFromWorld(world), + (IServerWorldInfo) world.getLevelData(), world.dimension(), world.dimensionType(), + new DummyStatusListener(), ((ServerChunkProvider) world.getChunkSource()).getGenerator(), world.isDebug(), + world.getBiomeManager().biomeZoomSeed, Collections.emptyList(), false); this.world = world; } From 3093bf59178d6bd0f309c60872991ec75a7f17a6 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Thu, 21 Oct 2021 19:10:34 +0200 Subject: [PATCH 8/9] Update HarvesterMovementBehaviour.java - harvestpartial only breaks age zero crops if replant is disabled --- .../actors/HarvesterMovementBehaviour.java | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java index c66f22dcb..e7f604707 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java @@ -24,6 +24,7 @@ import net.minecraft.block.Blocks; import net.minecraft.block.CocoaBlock; import net.minecraft.block.CropsBlock; import net.minecraft.block.SugarCaneBlock; +import net.minecraft.block.SweetBerryBushBlock; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -51,14 +52,16 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { @Nullable @Override - public ActorInstance createInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) { + public ActorInstance createInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, + MovementContext context) { return new HarvesterActorInstance(materialManager, simulationWorld, context); } @Override public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, ContraptionMatrices matrices, IRenderTypeBuffer buffers) { - if (!Backend.getInstance().canUseInstancing()) + if (!Backend.getInstance() + .canUseInstancing()) HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers); } @@ -87,18 +90,18 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { ItemStack item = ItemStack.EMPTY; float effectChance = 1; - - if (stateVisited.getBlock().is(BlockTags.LEAVES)) { + + if (stateVisited.getBlock() + .is(BlockTags.LEAVES)) { item = new ItemStack(Items.SHEARS); effectChance = .45f; } - + MutableBoolean seedSubtracted = new MutableBoolean(notCropButCuttable); BlockState state = stateVisited; BlockHelper.destroyBlockAs(world, pos, null, item, effectChance, stack -> { - if (AllConfigs.SERVER.kinetics.harvesterReplants.get() - && !seedSubtracted.getValue() - && stack.sameItem(new ItemStack(state.getBlock()))) { + if (AllConfigs.SERVER.kinetics.harvesterReplants.get() && !seedSubtracted.getValue() + && stack.sameItem(new ItemStack(state.getBlock()))) { stack.shrink(1); seedSubtracted.setTrue(); } @@ -109,24 +112,31 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { } private boolean isValidCrop(World world, BlockPos pos, BlockState state) { + boolean harvestPartial = AllConfigs.SERVER.kinetics.harvestPartiallyGrown.get(); + boolean replant = AllConfigs.SERVER.kinetics.harvesterReplants.get(); + if (state.getBlock() instanceof CropsBlock) { CropsBlock crop = (CropsBlock) state.getBlock(); - if (!crop.isMaxAge(state) && !AllConfigs.SERVER.kinetics.harvestPartiallyGrown.get()) - return false; - return true; + if (harvestPartial) + return state.getValue(crop.getAgeProperty()) != 0 || !replant; + return crop.isMaxAge(state); } + if (state.getCollisionShape(world, pos) .isEmpty() || state.getBlock() instanceof CocoaBlock) { for (Property property : state.getProperties()) { if (!(property instanceof IntegerProperty)) continue; + IntegerProperty ageProperty = (IntegerProperty) property; if (!property.getName() .equals(BlockStateProperties.AGE_1.getName())) continue; - if (!AllConfigs.SERVER.kinetics.harvestPartiallyGrown.get() - && (((IntegerProperty) property).getPossibleValues().size() - 1 - != state.getValue((IntegerProperty) property) - .intValue())) + int age = state.getValue(ageProperty) + .intValue(); + if (state.getBlock() instanceof SweetBerryBushBlock && age <= 1 && replant) + continue; + if (age == 0 && replant || !harvestPartial && (ageProperty.getPossibleValues() + .size() - 1 != age)) continue; return true; } @@ -140,7 +150,8 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { return false; if (state.getBlock() instanceof SugarCaneBlock) return true; - if (state.getBlock().is(BlockTags.LEAVES)) + if (state.getBlock() + .is(BlockTags.LEAVES)) return true; if (state.getCollisionShape(world, pos) @@ -167,10 +178,10 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { private BlockState cutCrop(World world, BlockPos pos, BlockState state) { if (!AllConfigs.SERVER.kinetics.harvesterReplants.get()) { if (state.getFluidState() - .isEmpty()) + .isEmpty()) return Blocks.AIR.defaultBlockState(); return state.getFluidState() - .createLegacyBlock(); + .createLegacyBlock(); } Block block = state.getBlock(); @@ -183,18 +194,18 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { } if (block == Blocks.SUGAR_CANE || block instanceof AbstractPlantBlock) { if (state.getFluidState() - .isEmpty()) + .isEmpty()) return Blocks.AIR.defaultBlockState(); return state.getFluidState() - .createLegacyBlock(); + .createLegacyBlock(); } if (state.getCollisionShape(world, pos) - .isEmpty() || block instanceof CocoaBlock) { + .isEmpty() || block instanceof CocoaBlock) { for (Property property : state.getProperties()) { if (!(property instanceof IntegerProperty)) continue; if (!property.getName() - .equals(BlockStateProperties.AGE_1.getName())) + .equals(BlockStateProperties.AGE_1.getName())) continue; return state.setValue((IntegerProperty) property, Integer.valueOf(0)); } From 855fc52d6224f75c045085585f4e9aa025e6d38a Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Thu, 21 Oct 2021 19:23:49 +0200 Subject: [PATCH 9/9] Update FurnaceEngineModifiers.java - Use registry delegates - Reduce boilerplate --- .../engine/FurnaceEngineModifiers.java | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineModifiers.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineModifiers.java index e785540de..2a77de7b0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineModifiers.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineModifiers.java @@ -6,34 +6,27 @@ import java.util.Map; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraftforge.registries.IRegistryDelegate; public class FurnaceEngineModifiers { - + public final static FurnaceEngineModifiers INSTANCE = new FurnaceEngineModifiers(); - - protected Map blockModifiers; - - public FurnaceEngineModifiers(Map blockModifiers) { - this.blockModifiers = blockModifiers; - } - - public FurnaceEngineModifiers() { - this(new HashMap<>()); - } - - public void set(Block block, float modifier) { + + protected Map, Float> blockModifiers = new HashMap<>(); + + public void register(IRegistryDelegate block, float modifier) { this.blockModifiers.put(block, modifier); } - - public float getModifier(BlockState state, float def) { - return blockModifiers.getOrDefault(state.getBlock(), def); + + public float getModifierOrDefault(BlockState state, float defaultValue) { + return blockModifiers.getOrDefault(state.getBlock().delegate, defaultValue); } - + public float getModifier(BlockState state) { - return getModifier(state, 1f); + return getModifierOrDefault(state, 1f); } - + public static void register() { - INSTANCE.set(Blocks.BLAST_FURNACE, 2f); + INSTANCE.register(Blocks.BLAST_FURNACE.delegate, 2f); } }