Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more config options for max itemstack and speed of transfer #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<ItemStack> inventory;
protected long lastTickTime;
protected int transferCooldown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/net/gnomecraft/ductwork/config/DuctworkConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;


}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/gnomecraft/ductwork/duct/DuctEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
19 changes: 18 additions & 1 deletion src/main/resources/assets/ductwork/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."

}