Skip to content

Commit

Permalink
Fixed orphaned tanks not properly updating
Browse files Browse the repository at this point in the history
- Fixed TankBlockEntity not being removed when a tank is dismantled using the wrench.
  • Loading branch information
Zarathul committed Nov 8, 2019
1 parent 7ae0363 commit 3d9b310
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 59 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
//apply plugin: 'maven-publish'

String ForgeVersion = '1.14.4-28.1.61'
String ForgeVersion = '1.14.4-28.1.87'

version = "1.14.4-1.8.0.0"
version = "1.14.4-1.8.0.1"
group= "net.zarathul.simplefluidtanks" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "simplefluidtanks"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,16 @@ public void onReplaced(BlockState state, World world, BlockPos pos, BlockState n
if (ignoreBlockBreakCoords.contains(pos))
{
ignoreBlockBreakCoords.remove(pos);

return;
}

// get the valve the tank is connected to and disband the multiblock
ValveBlockEntity valveEntity = Utils.getValve(world, pos);

if (valveEntity != null)
else
{
valveEntity.disbandMultiblock(pos);
// get the valve the tank is connected to and disband the multiblock
ValveBlockEntity valveEntity = Utils.getValve(world, pos);

if (valveEntity != null)
{
valveEntity.disbandMultiblock(pos);
}
}
}
}
Expand All @@ -208,7 +208,7 @@ protected void handleToolWrenchClick(World world, BlockPos pos, PlayerEntity pla
valveEntity = tankEntity.getValve();
// ignore the BlockBreak event for this TankBlock, this way
// there will be no reset of the whole tank
ignoreBlockBreakCoords.add(pos);
ignoreBlockBreakCoords.add(pos.toImmutable());
}

world.destroyBlock(pos, true);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,22 @@ public final class Config

tankBlockHardness = CommonConfigBuilder.translation("config.tankblock_hardness")
.comment("The amount of hits the block can take before it breaks (-1 = indestructible).")
.worldRestart()
.defineInRange("tankBlockHardness", defaultTankBlockHardness, -1.0d, Float.MAX_VALUE);

tankBlockResistance = CommonConfigBuilder.translation("config.tankblock_resistance")
.comment("The blocks resistance to explosions.")
.worldRestart()
.defineInRange("tankBlockResistance", defaultTankBlockResistance, 1.0d, Float.MAX_VALUE);

valveBlockHardness = CommonConfigBuilder.translation("config.valveblock_hardness")
.comment("The amount of hits the block can take before it breaks (-1 = indestructible).")
.worldRestart()
.defineInRange("valveBlockHardness", defaultValveBlockHardness, -1.0d, Float.MAX_VALUE);

valveBlockResistance = CommonConfigBuilder.translation("config.valveblock_resistance")
.comment("The blocks resistance to explosions.")
.worldRestart()
.defineInRange("valveBlockResistance", defaultValveBlockResistance, 1.0d, Float.MAX_VALUE);

CommonConfigBuilder.pop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public void formMultiblock()
{
// store the current fluid for reinsertion
FluidStack fluid = internalTank.getFluid();
int oldFluidAmount = fluid.getAmount();
//int oldFluidAmount = fluid.getAmount();

// find new tanks and update the valves textures

Expand Down Expand Up @@ -495,6 +495,7 @@ private void updateOrphanedTanks()

if (tankEntity != null)
{
tankEntity.updateBlockState();
Utils.syncBlockAndRerender(world, tankEntity.getPos());
tankEntity.markDirty();
}
Expand Down Expand Up @@ -1120,7 +1121,7 @@ private boolean isUnlinkedTank(BlockPos block)

BlockState state = world.getBlockState(block);

if (state.getBlock() instanceof TankBlock)
if (state.getBlock() == SimpleFluidTanks.tankBlock)
{
TankBlockEntity tankEntity = Utils.getTileEntityAt(world, TankBlockEntity.class, block);

Expand All @@ -1129,10 +1130,10 @@ private boolean isUnlinkedTank(BlockPos block)
return !tankEntity.isPartOfTank();
}
}
else if (block.equals(pos) && tankPriorities.isEmpty())
else
{
// this valve is also considered a unlinked tank as long as it has no associated tanks
return true;
return (block.equals(pos) && tankPriorities.isEmpty());
}

return false;
Expand Down

0 comments on commit 3d9b310

Please sign in to comment.