mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-10-25 20:32:32 +00:00
avoid repeated smeltery structure checks (#329)
This commit is contained in:
1 parent
034fede7ed
commit
7c1bf6724d
3 files changed
+42
-18
No files matched your search
@@ -25,7 +25,6 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
|||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import mantle.blocks.iface.IServantLogic;
|
|
||||||
import tconstruct.library.TConstructRegistry;
|
import tconstruct.library.TConstructRegistry;
|
||||||
import tconstruct.smeltery.itemblocks.LavaTankItemBlock;
|
import tconstruct.smeltery.itemblocks.LavaTankItemBlock;
|
||||||
import tconstruct.smeltery.logic.LavaTankLogic;
|
import tconstruct.smeltery.logic.LavaTankLogic;
|
||||||
@@ -246,11 +245,17 @@ public class LavaTankBlock extends BlockContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Updates */
|
/* Updates */
|
||||||
|
@Override
|
||||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block nBlockID) {
|
public void onNeighborBlockChange(World world, int x, int y, int z, Block nBlockID) {
|
||||||
TileEntity logic = world.getTileEntity(x, y, z);
|
if (!SmelteryBlock.isStructureChange(nBlockID)) return;
|
||||||
if (logic instanceof IServantLogic) {
|
|
||||||
((IServantLogic) logic).notifyMasterOfChange();
|
SmelteryBlock.notifyMasterOfStructureChange(world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockPreDestroy(World world, int x, int y, int z, int meta) {
|
||||||
|
SmelteryBlock.notifyMasterOfStructureChange(world, x, y, z);
|
||||||
|
super.onBlockPreDestroy(world, x, y, z, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.minecraft.block.material.Material;
|
|||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -26,6 +27,7 @@ import mantle.blocks.iface.IServantLogic;
|
|||||||
import tconstruct.TConstruct;
|
import tconstruct.TConstruct;
|
||||||
import tconstruct.library.TConstructRegistry;
|
import tconstruct.library.TConstructRegistry;
|
||||||
import tconstruct.smeltery.SmelteryProxyCommon;
|
import tconstruct.smeltery.SmelteryProxyCommon;
|
||||||
|
import tconstruct.smeltery.TinkerSmeltery;
|
||||||
import tconstruct.smeltery.logic.SmelteryDrainLogic;
|
import tconstruct.smeltery.logic.SmelteryDrainLogic;
|
||||||
import tconstruct.smeltery.logic.SmelteryLogic;
|
import tconstruct.smeltery.logic.SmelteryLogic;
|
||||||
import tconstruct.smeltery.model.SmelteryRender;
|
import tconstruct.smeltery.model.SmelteryRender;
|
||||||
@@ -232,7 +234,25 @@ public class SmelteryBlock extends InventoryBlock {
|
|||||||
/* Updating */
|
/* Updating */
|
||||||
@Override
|
@Override
|
||||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||||
// System.out.println("Neighbor changed");
|
if (!isStructureChange(block)) return;
|
||||||
|
|
||||||
|
notifyMasterOfStructureChange(world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockPreDestroy(World world, int x, int y, int z, int meta) {
|
||||||
|
notifyMasterOfStructureChange(world, x, y, z);
|
||||||
|
super.onBlockPreDestroy(world, x, y, z, meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean isStructureChange(Block block) {
|
||||||
|
return block == Blocks.air || block == TinkerSmeltery.smeltery
|
||||||
|
|| block == TinkerSmeltery.smelteryNether
|
||||||
|
|| block == TinkerSmeltery.lavaTank
|
||||||
|
|| block == TinkerSmeltery.lavaTankNether;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void notifyMasterOfStructureChange(World world, int x, int y, int z) {
|
||||||
TileEntity logic = world.getTileEntity(x, y, z);
|
TileEntity logic = world.getTileEntity(x, y, z);
|
||||||
if (logic instanceof IServantLogic) {
|
if (logic instanceof IServantLogic) {
|
||||||
((IServantLogic) logic).notifyMasterOfChange();
|
((IServantLogic) logic).notifyMasterOfChange();
|
||||||
@@ -241,17 +261,6 @@ public class SmelteryBlock extends InventoryBlock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void breakBlock(World world, int x, int y, int z, Block blockID, int meta) {
|
|
||||||
// TE is not valid anymore at this point. :/
|
|
||||||
|
|
||||||
TileEntity logic = world.getTileEntity(x, y, z);
|
|
||||||
if (logic instanceof IServantLogic) {
|
|
||||||
((IServantLogic) logic).notifyMasterOfChange();
|
|
||||||
}
|
|
||||||
super.breakBlock(world, x, y, z, blockID, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comparator
|
// Comparator
|
||||||
|
|
||||||
public boolean hasComparatorInputOverride() {
|
public boolean hasComparatorInputOverride() {
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
|||||||
public int[] activeTemps; // values are multiplied by 10
|
public int[] activeTemps; // values are multiplied by 10
|
||||||
public int[] meltingTemps; // values are multiplied by 10
|
public int[] meltingTemps; // values are multiplied by 10
|
||||||
private int tick;
|
private int tick;
|
||||||
|
private boolean structureCheckQueued;
|
||||||
|
|
||||||
public final List<FluidStack> moltenMetal = Collections.synchronizedList(new ArrayList<>());
|
public final List<FluidStack> moltenMetal = Collections.synchronizedList(new ArrayList<>());
|
||||||
public int maxLiquid;
|
public int maxLiquid;
|
||||||
@@ -287,6 +288,8 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
|||||||
/* Updating */
|
/* Updating */
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
checkStructureIfQueued();
|
||||||
|
|
||||||
tick++;
|
tick++;
|
||||||
if (tick == 60) {
|
if (tick == 60) {
|
||||||
tick = 0;
|
tick = 0;
|
||||||
@@ -329,6 +332,13 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkStructureIfQueued() {
|
||||||
|
if (structureCheckQueued) {
|
||||||
|
structureCheckQueued = false;
|
||||||
|
checkValidPlacement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void detectEntities() {
|
void detectEntities() {
|
||||||
if (!validStructure || minPos == null || maxPos == null) return;
|
if (!validStructure || minPos == null || maxPos == null) return;
|
||||||
|
|
||||||
@@ -680,7 +690,7 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
|||||||
/* Multiblock */
|
/* Multiblock */
|
||||||
@Override
|
@Override
|
||||||
public void notifyChange(IServantLogic servant, int x, int y, int z) {
|
public void notifyChange(IServantLogic servant, int x, int y, int z) {
|
||||||
checkValidPlacement();
|
structureCheckQueued = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkValidPlacement() {
|
public void checkValidPlacement() {
|
||||||
|
|||||||
Reference in new issue
Block a user