From 0ec83cc6230c5a2427f02761531c1ecb83f91d6b Mon Sep 17 00:00:00 2001 From: Robin Heidrich <50168919+robin-heidrich@users.noreply.github.com> Date: Thu, 25 Jan 2024 20:04:39 +0100 Subject: [PATCH] Added more config options for max itemstack and speed of transfer --- .../ductwork/base/DuctworkBlockEntity.java | 3 ++- .../ductwork/collector/CollectorEntity.java | 4 ++-- .../ductwork/config/DuctworkConfig.java | 22 +++++++++++++++++++ .../ductwork/damper/DamperEntity.java | 2 +- .../gnomecraft/ductwork/duct/DuctEntity.java | 2 +- .../resources/assets/ductwork/lang/en_us.json | 19 +++++++++++++++- 6 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/gnomecraft/ductwork/base/DuctworkBlockEntity.java b/src/main/java/net/gnomecraft/ductwork/base/DuctworkBlockEntity.java index 2f1ca1f..477bd02 100644 --- a/src/main/java/net/gnomecraft/ductwork/base/DuctworkBlockEntity.java +++ b/src/main/java/net/gnomecraft/ductwork/base/DuctworkBlockEntity.java @@ -1,6 +1,7 @@ package net.gnomecraft.ductwork.base; import net.gnomecraft.cooldowncoordinator.CoordinatedCooldown; +import net.gnomecraft.ductwork.Ductwork; import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.LockableContainerBlockEntity; @@ -16,7 +17,7 @@ import java.util.Iterator; public abstract class DuctworkBlockEntity extends LockableContainerBlockEntity implements CoordinatedCooldown, Inventory { - public final static int defaultCooldown = 8; // 4 redstone ticks, just like vanilla + public final static int defaultCooldown = Ductwork.getConfig().itemTransferCooldown; // 4 redstone ticks, just like vanilla protected DefaultedList inventory; protected long lastTickTime; protected int transferCooldown; diff --git a/src/main/java/net/gnomecraft/ductwork/collector/CollectorEntity.java b/src/main/java/net/gnomecraft/ductwork/collector/CollectorEntity.java index e754fdc..5e2f841 100644 --- a/src/main/java/net/gnomecraft/ductwork/collector/CollectorEntity.java +++ b/src/main/java/net/gnomecraft/ductwork/collector/CollectorEntity.java @@ -147,7 +147,7 @@ private boolean push(World world, BlockPos pos, BlockState state, CollectorEntit if (sourceStorage != null && targetStorage != null) { boolean targetEmpty = CooldownCoordinator.isStorageEmpty(targetStorage); - if (StorageUtil.move(sourceStorage, targetStorage, variant -> true, 1, null) > 0) { + if (StorageUtil.move(sourceStorage, targetStorage, variant -> true, Ductwork.getConfig().maxItemStackCollector, null) > 0) { if (targetEmpty) { CooldownCoordinator.notify(targetEntity); } @@ -184,7 +184,7 @@ private boolean pull(World world, BlockPos pos, BlockState state, CollectorEntit // Try to pull from any discovered storage or inventory... if (sourceStorage != null && targetStorage != null) { - boolean result = (StorageUtil.move(sourceStorage, targetStorage, variant -> true, 1, null) > 0); + boolean result = (StorageUtil.move(sourceStorage, targetStorage, variant -> true, Ductwork.getConfig().maxItemStackCollector, null) > 0); BlockEntity sourceEntity = world.getBlockEntity(pos.offset(intake)); if (sourceEntity != null) { sourceEntity.markDirty(); diff --git a/src/main/java/net/gnomecraft/ductwork/config/DuctworkConfig.java b/src/main/java/net/gnomecraft/ductwork/config/DuctworkConfig.java index 58aea8f..ebf259e 100644 --- a/src/main/java/net/gnomecraft/ductwork/config/DuctworkConfig.java +++ b/src/main/java/net/gnomecraft/ductwork/config/DuctworkConfig.java @@ -24,4 +24,26 @@ public class DuctworkConfig implements ConfigData { @ConfigEntry.Gui.PrefixText @ConfigEntry.Gui.Tooltip public boolean cheaper = false; + + @Comment("Cooldown for item transfer (8 = 4 redstone ticks, just like vanilla)") + @ConfigEntry.Gui.PrefixText + @ConfigEntry.Gui.Tooltip + public int itemTransferCooldown = 8; + + @Comment("Max number of itemstacks that can be moved simultaneously for duct") + @ConfigEntry.Gui.PrefixText + @ConfigEntry.Gui.Tooltip + public int maxItemStackDuct = 1; + + @Comment("Max number of itemstacks that can be moved simultaneously for collector") + @ConfigEntry.Gui.PrefixText + @ConfigEntry.Gui.Tooltip + public int maxItemStackCollector = 1; + + @Comment("Max number of itemstacks that can be moved simultaneously for damper") + @ConfigEntry.Gui.PrefixText + @ConfigEntry.Gui.Tooltip + public int maxItemStackDamper = 1; + + } diff --git a/src/main/java/net/gnomecraft/ductwork/damper/DamperEntity.java b/src/main/java/net/gnomecraft/ductwork/damper/DamperEntity.java index f2ada64..1a52a22 100644 --- a/src/main/java/net/gnomecraft/ductwork/damper/DamperEntity.java +++ b/src/main/java/net/gnomecraft/ductwork/damper/DamperEntity.java @@ -70,7 +70,7 @@ private boolean push(World world, BlockPos pos, BlockState state, DamperEntity e if (sourceStorage != null && targetStorage != null) { boolean targetEmpty = CooldownCoordinator.isStorageEmpty(targetStorage); - if (StorageUtil.move(sourceStorage, targetStorage, variant -> true, 1, null) > 0) { + if (StorageUtil.move(sourceStorage, targetStorage, variant -> true, Ductwork.getConfig().maxItemStackDamper, null) > 0) { if (targetEmpty) { CooldownCoordinator.notify(targetEntity); } diff --git a/src/main/java/net/gnomecraft/ductwork/duct/DuctEntity.java b/src/main/java/net/gnomecraft/ductwork/duct/DuctEntity.java index cb9ccec..a082353 100644 --- a/src/main/java/net/gnomecraft/ductwork/duct/DuctEntity.java +++ b/src/main/java/net/gnomecraft/ductwork/duct/DuctEntity.java @@ -69,7 +69,7 @@ private boolean push(World world, BlockPos pos, BlockState state, DuctEntity ent if (sourceStorage != null && targetStorage != null) { boolean targetEmpty = CooldownCoordinator.isStorageEmpty(targetStorage); - if (StorageUtil.move(sourceStorage, targetStorage, variant -> true, 1, null) > 0) { + if (StorageUtil.move(sourceStorage, targetStorage, variant -> true, Ductwork.getConfig().maxItemStackDuct, null) > 0) { if (targetEmpty) { CooldownCoordinator.notify(targetEntity); } diff --git a/src/main/resources/assets/ductwork/lang/en_us.json b/src/main/resources/assets/ductwork/lang/en_us.json index 0cacaf1..d9729e6 100644 --- a/src/main/resources/assets/ductwork/lang/en_us.json +++ b/src/main/resources/assets/ductwork/lang/en_us.json @@ -20,5 +20,22 @@ "text.autoconfig.ductwork.option.cheaper": "Cheaper Ductwork Blocks?", "text.autoconfig.ductwork.option.cheaper.@PrefixText": "Use less Iron in Ductwork recipes?\nConvenient for iron farm nerfing modpacks.", - "text.autoconfig.ductwork.option.cheaper.@Tooltip": "Server overrides client." + "text.autoconfig.ductwork.option.cheaper.@Tooltip": "Server overrides client.", + + "text.autoconfig.ductwork.option.itemTransferCooldown": "Cooldown for item transfer (8 = 4 redstone ticks, just like vanilla)", + "text.autoconfig.ductwork.option.itemTransferCooldown.@PrefixText": "Configurable speed in duct blocks.", + "text.autoconfig.ductwork.option.itemTransferCooldown.@Tooltip": "Server overrides client.", + + "text.autoconfig.ductwork.option.maxItemStackDuct": "Max number of simultaneously itemstacks for duct.", + "text.autoconfig.ductwork.option.maxItemStackDuct.@PrefixText": "Number of items that can be transferred simultaneously.", + "text.autoconfig.ductwork.option.maxItemStackDuct.@Tooltip": "Server overrides client.", + + "text.autoconfig.ductwork.option.maxItemStackCollector": "Max number of simultaneously itemstacks for collector", + "text.autoconfig.ductwork.option.maxItemStackCollector.@PrefixText": "Number of items that can be transferred simultaneously.", + "text.autoconfig.ductwork.option.maxItemStackCollector.@Tooltip": "Server overrides client.", + + "text.autoconfig.ductwork.option.maxItemStackDamper": "Max number of simultaneously itemstacks for damper", + "text.autoconfig.ductwork.option.maxItemStackDamper.@PrefixText": "Number of items that can be transferred simultaneously.", + "text.autoconfig.ductwork.option.maxItemStackDamper.@Tooltip": "Server overrides client." + } \ No newline at end of file