mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-20 04:09:40 +00:00
move more block logic to mantle
This commit is contained in:
1 parent
d19d4d4a0c
commit
bbec72109a
19 files changed
+35
-590
No files matched your search
@@ -24,7 +24,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import tconstruct.blocks.logic.LavaTankLogic;
|
||||
import tconstruct.client.block.TankRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
import mantle.blocks.iface.IServantLogic;
|
||||
|
||||
public class LavaTankBlock extends BlockContainer
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.AdaptiveSmelteryLogic;
|
||||
import tconstruct.blocks.logic.MultiServantLogic;
|
||||
import tconstruct.blocks.logic.AdaptiveDrainLogic;
|
||||
import tconstruct.blocks.logic.SmelteryDrainLogic;
|
||||
import tconstruct.blocks.logic.SmelteryLogic;
|
||||
@@ -22,8 +21,9 @@ import tconstruct.client.block.SmelteryRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
import mantle.blocks.iface.IMasterLogic;
|
||||
import mantle.blocks.iface.IServantLogic;
|
||||
import mantle.blocks.iface.MultiServantLogic;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
public class SmelteryBlock extends InventoryBlock
|
||||
|
||||
@@ -3,6 +3,7 @@ package tconstruct.blocks.component;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import mantle.blocks.iface.IServantLogic;
|
||||
import mantle.world.CoordTuple;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -12,7 +13,6 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.component.TankLayerScan;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
|
||||
public class SmelteryScan extends TankLayerScan
|
||||
{
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import mantle.blocks.iface.IMasterLogic;
|
||||
import mantle.blocks.iface.MultiServantLogic;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
@@ -28,7 +29,7 @@ public class AdaptiveDrainLogic extends MultiServantLogic implements IFluidHandl
|
||||
public boolean setPotentialMaster (IMasterLogic master, World world, int x, int y, int z)
|
||||
{
|
||||
// TConstruct.logger.info("Master: "+master);
|
||||
return (master instanceof AdaptiveSmelteryLogic || master instanceof AdaptiveDrainLogic) && !hasMaster;
|
||||
return (master instanceof AdaptiveSmelteryLogic || master instanceof AdaptiveDrainLogic) && !hasValidMaster();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,7 +37,7 @@ public class AdaptiveDrainLogic extends MultiServantLogic implements IFluidHandl
|
||||
{
|
||||
if (hasValidMaster() && canDrain(from, null))
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.fill(from, resource, doFill);
|
||||
}
|
||||
return 0;
|
||||
@@ -48,7 +49,7 @@ public class AdaptiveDrainLogic extends MultiServantLogic implements IFluidHandl
|
||||
// TConstruct.logger.info("Attempting drain " + hasValidMaster());
|
||||
if (hasValidMaster() && canDrain(from, null))
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
// TConstruct.logger.info("Found master");
|
||||
return smeltery.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
@@ -60,7 +61,7 @@ public class AdaptiveDrainLogic extends MultiServantLogic implements IFluidHandl
|
||||
{
|
||||
if (hasValidMaster() && canDrain(from, null))
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.drain(from, resource, doDrain);
|
||||
}
|
||||
return null;
|
||||
@@ -71,7 +72,7 @@ public class AdaptiveDrainLogic extends MultiServantLogic implements IFluidHandl
|
||||
{
|
||||
if (hasValidMaster())
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.getFillState() < 2;
|
||||
}
|
||||
return false;
|
||||
@@ -82,7 +83,7 @@ public class AdaptiveDrainLogic extends MultiServantLogic implements IFluidHandl
|
||||
{
|
||||
if (hasValidMaster())
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.getFillState() > 0;
|
||||
}
|
||||
return false;
|
||||
@@ -93,7 +94,7 @@ public class AdaptiveDrainLogic extends MultiServantLogic implements IFluidHandl
|
||||
{
|
||||
if (hasValidMaster() && (from == getForgeDirection() || from == getForgeDirection().getOpposite() || from == ForgeDirection.UNKNOWN))
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -28,14 +28,14 @@ import tconstruct.blocks.component.SmelteryScan;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.inventory.AdaptiveSmelteryContainer;
|
||||
import tconstruct.library.blocks.AdaptiveInventoryLogic;
|
||||
import mantle.blocks.abstracts.AdaptiveInventoryLogic;
|
||||
import tconstruct.library.component.IComponentHolder;
|
||||
import tconstruct.library.component.LogicComponent;
|
||||
import tconstruct.library.component.MultiFluidTank;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import mantle.world.CoordTuple;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
import mantle.blocks.iface.IMasterLogic;
|
||||
import mantle.blocks.iface.IServantLogic;
|
||||
|
||||
public class AdaptiveSmelteryLogic extends AdaptiveInventoryLogic implements IActiveLogic, IMasterLogic, IComponentHolder, IFluidHandler
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.iface.MultiServantLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.world.CoordTuple;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
|
||||
public class MultiServantLogic extends TileEntity implements IServantLogic
|
||||
{
|
||||
boolean hasMaster;
|
||||
CoordTuple master;
|
||||
short masterID;
|
||||
byte masterMeat; //Typo, it stays!
|
||||
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasValidMaster ()
|
||||
{
|
||||
if (!hasMaster)
|
||||
return false;
|
||||
|
||||
if (worldObj.getBlockId(master.x, master.y, master.z) == masterID && worldObj.getBlockMetadata(master.x, master.y, master.z) == masterMeat)
|
||||
return true;
|
||||
|
||||
else
|
||||
{
|
||||
hasMaster = false;
|
||||
master = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public CoordTuple getMasterPosition ()
|
||||
{
|
||||
return master;
|
||||
}
|
||||
|
||||
public void overrideMaster (int x, int y, int z)
|
||||
{
|
||||
hasMaster = true;
|
||||
master = new CoordTuple(x, y, z);
|
||||
masterID = (short) worldObj.getBlockId(x, y, z);
|
||||
masterMeat = (byte) worldObj.getBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
public void removeMaster ()
|
||||
{
|
||||
hasMaster = false;
|
||||
master = null;
|
||||
masterID = 0;
|
||||
masterMeat = 0;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean verifyMaster (IMasterLogic logic, int x, int y, int z)
|
||||
{
|
||||
if (master.equalCoords(x, y, z) && worldObj.getBlockId(x, y, z) == masterID && worldObj.getBlockMetadata(x, y, z) == masterMeat)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean setMaster (int x, int y, int z)
|
||||
{
|
||||
if (!hasMaster || worldObj.getBlockId(master.x, master.y, master.z) != masterID || (worldObj.getBlockMetadata(master.x, master.y, master.z) != masterMeat))
|
||||
{
|
||||
overrideMaster(x, y, z);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPotentialMaster (IMasterLogic master, World world, int x, int y, int z)
|
||||
{
|
||||
return !hasMaster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyMaster (IMasterLogic logic, World world, int x, int y, int z)
|
||||
{
|
||||
if (hasMaster)
|
||||
{
|
||||
return hasValidMaster();
|
||||
}
|
||||
else
|
||||
{
|
||||
overrideMaster(x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateMaster (IMasterLogic master, World world, int x, int y, int z)
|
||||
{
|
||||
hasMaster = false;
|
||||
master = null;
|
||||
}
|
||||
|
||||
public void notifyMasterOfChange ()
|
||||
{
|
||||
if (hasValidMaster())
|
||||
{
|
||||
IMasterLogic logic = (IMasterLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
logic.notifyChange(this, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
hasMaster = tags.getBoolean("TiedToMaster");
|
||||
if (hasMaster)
|
||||
{
|
||||
int xCenter = tags.getInteger("xCenter");
|
||||
int yCenter = tags.getInteger("yCenter");
|
||||
int zCenter = tags.getInteger("zCenter");
|
||||
master = new CoordTuple(xCenter, yCenter, zCenter);
|
||||
masterID = tags.getShort("MasterID");
|
||||
masterMeat = tags.getByte("masterMeat");
|
||||
}
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setBoolean("TiedToMaster", hasMaster);
|
||||
if (hasMaster)
|
||||
{
|
||||
tags.setInteger("xCenter", master.x);
|
||||
tags.setInteger("yCenter", master.y);
|
||||
tags.setInteger("zCenter", master.z);
|
||||
tags.setShort("MasterID", masterID);
|
||||
tags.setByte("masterMeat", masterMeat);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readCustomNBT(packet.data);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import mantle.blocks.iface.MultiServantLogic;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
@@ -29,7 +30,7 @@ public class SmelteryDrainLogic extends MultiServantLogic implements IFluidHandl
|
||||
{
|
||||
if (doFill)
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.fill(resource, doFill);
|
||||
}
|
||||
else
|
||||
@@ -48,7 +49,7 @@ public class SmelteryDrainLogic extends MultiServantLogic implements IFluidHandl
|
||||
{
|
||||
if (hasValidMaster() && canDrain(from, null))
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.drain(maxDrain, doDrain);
|
||||
}
|
||||
else
|
||||
@@ -79,7 +80,7 @@ public class SmelteryDrainLogic extends MultiServantLogic implements IFluidHandl
|
||||
boolean containsFluid = fluid == null;
|
||||
if (fluid != null)
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
for (FluidStack fstack : smeltery.moltenMetal)
|
||||
{
|
||||
if (fstack.fluidID == fluid.getID())
|
||||
@@ -98,7 +99,7 @@ public class SmelteryDrainLogic extends MultiServantLogic implements IFluidHandl
|
||||
{
|
||||
if (hasValidMaster() && (from == getForgeDirection() || from == getForgeDirection().getOpposite() || from == ForgeDirection.UNKNOWN))
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.getMultiTankInfo();
|
||||
//return new FluidTankInfo[] { smeltery.getInfo() };
|
||||
}
|
||||
|
||||
@@ -37,9 +37,10 @@ import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.library.crafting.Smeltery;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import mantle.blocks.iface.MultiServantLogic;
|
||||
import mantle.world.CoordTuple;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
import mantle.blocks.iface.IMasterLogic;
|
||||
import mantle.blocks.iface.IServantLogic;
|
||||
import tconstruct.util.SmelteryDamageSource;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
@@ -18,8 +18,8 @@ import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.component.TankAirComponent;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import mantle.world.CoordTuple;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
import mantle.blocks.iface.IMasterLogic;
|
||||
import mantle.blocks.iface.IServantLogic;
|
||||
|
||||
public class TankAirLogic extends InventoryLogic implements IServantLogic, ISidedInventory
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.library.blocks.AdaptiveInventoryLogic;
|
||||
import mantle.blocks.abstracts.AdaptiveInventoryLogic;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import mantle.blocks.iface.IMasterLogic;
|
||||
|
||||
//Not actually abstract
|
||||
public abstract class TowerFurnaceLogic extends AdaptiveInventoryLogic implements IActiveLogic, IFacingLogic, IMasterLogic
|
||||
|
||||
Reference in new issue
Block a user