Skip to content

Commit

Permalink
Add config option for piping into harvester
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiahwinsley committed Jun 6, 2022
1 parent 706722e commit e17577d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ org.gradle.daemon=false
mc_version=1.18.2
group=net.permutated
mod_id=pylons
version=2.1.0
version=2.1.1
6 changes: 6 additions & 0 deletions src/main/java/net/permutated/pylons/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static class ServerConfig {
// CATEGORY_HARVESTER
public final ForgeConfigSpec.IntValue harvesterWorkDelay;
public final ForgeConfigSpec.BooleanValue harvesterRequiresTool;
public final ForgeConfigSpec.BooleanValue harvesterCanBeAutomated;


ServerConfig(ForgeConfigSpec.Builder builder) {
Expand Down Expand Up @@ -109,6 +110,11 @@ public static class ServerConfig {
"If enabled, it will use 1 durability per harvest action")
.define("harvesterRequiresTool", true);

harvesterCanBeAutomated = builder
.comment("Whether the harvester can have tools piped in to automate it.",
"By default, unbreakable tools are required for full automation.")
.define("harvesterCanBeAutomated", false);

builder.pop();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ public boolean isItemValid(int slot, @Nonnull ItemStack stack) {

protected final LazyOptional<IItemHandler> handler = LazyOptional.of(() -> itemStackHandler);

protected boolean canAccessInventory() {
return false;
}

@Nonnull
@Override
public <T> LazyOptional<T> getCapability(Capability<T> cap, @Nullable Direction side) {
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && side == null) {
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && (side == null || canAccessInventory())) {
return handler.cast();
}
return super.getCapability(cap, side);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ protected byte[] getRange() {
protected boolean isItemValid(ItemStack stack) {
return stack.getItem() instanceof HoeItem;
}

@Override
protected boolean canAccessInventory() {
return ConfigManager.SERVER.harvesterCanBeAutomated.get();
}

private boolean requiresTool() {
return Boolean.TRUE.equals(ConfigManager.SERVER.harvesterRequiresTool.get());
}
Expand Down

0 comments on commit e17577d

Please sign in to comment.