mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Actually, I can refactor this to stay more true to the original
This commit is contained in:
parent
25015a4f7a
commit
aadb2d5f2a
@ -24,8 +24,9 @@ import net.minecraftforge.oredict.OreDictionary;
|
|||||||
|
|
||||||
public interface IToolAreaAbility extends IBaseAbility {
|
public interface IToolAreaAbility extends IBaseAbility {
|
||||||
// Should call tool.breakExtraBlock on a bunch of blocks.
|
// Should call tool.breakExtraBlock on a bunch of blocks.
|
||||||
// The initial block should be included if you want it broken!
|
// The initial block is implicitly broken, so don't call breakExtraBlock on it.
|
||||||
public void onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool);
|
// Returning true skips the reference block from being broken
|
||||||
|
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool);
|
||||||
|
|
||||||
// Whether breakExtraBlock is called at all. Currently only false for explosion
|
// Whether breakExtraBlock is called at all. Currently only false for explosion
|
||||||
public default boolean allowsHarvest(int level) {
|
public default boolean allowsHarvest(int level) {
|
||||||
@ -47,8 +48,8 @@ public interface IToolAreaAbility extends IBaseAbility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
|
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
|
||||||
tool.breakExtraBlock(world, x, y, z, player, x, y, z);
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -87,24 +88,22 @@ public interface IToolAreaAbility extends IBaseAbility {
|
|||||||
private Set<ThreeInts> pos = new HashSet<>();
|
private Set<ThreeInts> pos = new HashSet<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
|
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
|
||||||
Block b = world.getBlock(x, y, z);
|
Block b = world.getBlock(x, y, z);
|
||||||
|
|
||||||
if(b == Blocks.stone && !ToolConfig.recursiveStone) {
|
if(b == Blocks.stone && !ToolConfig.recursiveStone) {
|
||||||
tool.breakExtraBlock(world, x, y, z, player, x, y, z);
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b == Blocks.netherrack && !ToolConfig.recursiveNetherrack) {
|
if(b == Blocks.netherrack && !ToolConfig.recursiveNetherrack) {
|
||||||
tool.breakExtraBlock(world, x, y, z, player, x, y, z);
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos.clear();
|
pos.clear();
|
||||||
|
|
||||||
recurse(world, x, y, z, x, y, z, player, tool, 0, radiusAtLevel[level]);
|
recurse(world, x, y, z, x, y, z, player, tool, 0, radiusAtLevel[level]);
|
||||||
|
|
||||||
tool.breakExtraBlock(world, x, y, z, player, x, y, z);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final List<ThreeInts> offsets = new ArrayList<ThreeInts>(3*3*3-1) {{
|
private final List<ThreeInts> offsets = new ArrayList<ThreeInts>(3*3*3-1) {{
|
||||||
@ -202,7 +201,7 @@ public interface IToolAreaAbility extends IBaseAbility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
|
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
|
||||||
int range = rangeAtLevel[level];
|
int range = rangeAtLevel[level];
|
||||||
|
|
||||||
for(int a = x - range; a <= x + range; a++) {
|
for(int a = x - range; a <= x + range; a++) {
|
||||||
@ -210,12 +209,13 @@ public interface IToolAreaAbility extends IBaseAbility {
|
|||||||
for(int c = z - range; c <= z + range; c++) {
|
for(int c = z - range; c <= z + range; c++) {
|
||||||
if (a == x && b == y && c == z)
|
if (a == x && b == y && c == z)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tool.breakExtraBlock(world, a, b ,c, player, x, y, z);
|
tool.breakExtraBlock(world, a, b ,c, player, x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tool.breakExtraBlock(world, x, y, z, player, x, y, z);
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ public interface IToolAreaAbility extends IBaseAbility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
|
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
|
||||||
float strength = strengthAtLevel[level];
|
float strength = strengthAtLevel[level];
|
||||||
|
|
||||||
ExplosionNT ex = new ExplosionNT(player.worldObj, player, x + 0.5, y + 0.5, z + 0.5, strength);
|
ExplosionNT ex = new ExplosionNT(player.worldObj, player, x + 0.5, y + 0.5, z + 0.5, strength);
|
||||||
@ -264,6 +264,8 @@ public interface IToolAreaAbility extends IBaseAbility {
|
|||||||
ex.doExplosionB(false);
|
ex.doExplosionB(false);
|
||||||
|
|
||||||
player.worldObj.createExplosion(player, x + 0.5, y + 0.5, z + 0.5, 0.1F, false);
|
player.worldObj.createExplosion(player, x + 0.5, y + 0.5, z + 0.5, 0.1F, false);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// endregion handlers
|
// endregion handlers
|
||||||
|
|||||||
@ -167,8 +167,12 @@ public class ItemToolAbility extends ItemTool implements IDepthRockTool, IGUIPro
|
|||||||
|
|
||||||
preset.harvestAbility.preHarvestAll(preset.harvestAbilityLevel, world, player);
|
preset.harvestAbility.preHarvestAll(preset.harvestAbilityLevel, world, player);
|
||||||
|
|
||||||
preset.areaAbility.onDig(preset.areaAbilityLevel, world, x, y, z, player, this);
|
boolean skipRef = preset.areaAbility.onDig(preset.areaAbilityLevel, world, x, y, z, player, this);
|
||||||
|
|
||||||
|
if (!skipRef) {
|
||||||
|
breakExtraBlock(world, x, y, z, player, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
preset.harvestAbility.postHarvestAll(preset.harvestAbilityLevel, world, player);
|
preset.harvestAbility.postHarvestAll(preset.harvestAbilityLevel, world, player);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user