Skip to content

Commit

Permalink
Added configurable tool usage to Slice'n'Splice
Browse files Browse the repository at this point in the history
and fixed exploit that allowed tool usage to be skipped
  • Loading branch information
HenryLoenwind committed Apr 23, 2017
1 parent 8de1a5d commit d8fbb94
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/crazypants/enderio/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ public String lc() {
public static int soulBinderTunedPressurePlateRF = 250000;
public static int soulBinderMaxXpLevel = 40;

public static float slicenspliceToolDamageChance = 0.01f;

public static boolean powerConduitCanDifferentTiersConnect = false;
public static int powerConduitTierOneRF = 640;
public static int powerConduitTierTwoRF = 5120;
Expand Down Expand Up @@ -1362,6 +1364,11 @@ public static void processConfig(Configuration config) {

soulBinderMaxXpLevel = config.get(sectionSoulBinder.name, "soulBinderMaxXPLevel", soulBinderMaxXpLevel, "Maximum level of XP the soul binder can contain.").getInt();

slicenspliceToolDamageChance = (float) config.get(sectionAdvanced.name, "slicenspliceToolDamageChance", slicenspliceToolDamageChance,
"The chance that a tool will take damage each tick while the Slice'n'Splice is running (0 = no chance, 1 = 100% chance). "
+ "Tools will always take damage when the crafting is finished.")
.getDouble(slicenspliceToolDamageChance);

spawnGuardStopAllSlimesDebug = config.getBoolean("spawnGuardStopAllSlimesDebug", sectionAttractor.name, spawnGuardStopAllSlimesDebug,
"When true slimes wont be allowed to spawn at all. Only added to aid testing in super flat worlds.");
spawnGuardStopAllSquidSpawning = config.getBoolean("spawnGuardStopAllSquidSpawning", sectionAttractor.name, spawnGuardStopAllSquidSpawning,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static crazypants.enderio.capacitor.CapacitorKey.SLICE_POWER_BUFFER;
import static crazypants.enderio.capacitor.CapacitorKey.SLICE_POWER_INTAKE;
import static crazypants.enderio.capacitor.CapacitorKey.SLICE_POWER_USE;
import static crazypants.enderio.config.Config.slicenspliceToolDamageChance;

@Storable
public class TileSliceAndSplice extends AbstractPoweredTaskEntity implements IPaintable.IPaintableTileEntity {
Expand Down Expand Up @@ -63,13 +64,32 @@ private ItemStack getShears() {
return inventory[shearsIndex];
}

@Override
protected boolean checkProgress(boolean redstoneChecksPassed) {
if (getAxe() == null || getShears() == null) {
return false;
}
return super.checkProgress(redstoneChecksPassed);
}

@Override
protected void taskComplete() {
super.taskComplete();
damageTool(getAxe(), axeIndex);
damageTool(getShears(), shearsIndex);
}

@Override
protected double usePower() {
if (random.nextFloat() < slicenspliceToolDamageChance) {
damageTool(getAxe(), axeIndex);
}
if (random.nextFloat() < slicenspliceToolDamageChance) {
damageTool(getShears(), shearsIndex);
}
return super.usePower();
}

private void damageTool(ItemStack tool, int toolIndex) {
if (tool != null && tool.isItemStackDamageable()) {
tool.damageItem(1, getFakePlayer());
Expand Down

0 comments on commit d8fbb94

Please sign in to comment.