You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.2 KiB
Java

package net.brokenmoon.afloydwiremod.tileentity;
import net.brokenmoon.afloydwiremod.WireMod;
import net.brokenmoon.afloydwiremod.api.IWireConnectable;
import net.brokenmoon.afloydwiremod.api.WireConnection;
import net.brokenmoon.afloydwiremod.gui.WiringButton;
import net.brokenmoon.afloydwiremod.tile.RedstoneLinkTile;
import net.minecraft.src.BlockSensor;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.TileEntity;
public class RedstoneLinkTileEntity extends ChipTileEntity {
public boolean isActive = false;
public boolean shouldnotremove = false;
public RedstoneLinkTileEntity(){
super();
this.mode = "rslink";
inputs = new WiringButton[1];
outputs = new WiringButton[1];
outputs[0] = new WiringButton(214, 240, "Output", 0);
inputs[0] = new WiringButton(214, 220, "Input", 0);
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
this.isActive = nbttagcompound.getBoolean("activity");
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
nbttagcompound.setBoolean("activity", this.isActive);
}
@Override
public void updateEntity() {
updateIO();
if(inputs[0].floatvalue > 0 && !this.isActive && worldObj.blockExists(xCoord, yCoord, zCoord) && worldObj.getBlockId(xCoord, yCoord, zCoord) == WireMod.LinkTileInactive.blockID){
this.shouldnotremove = true;
RedstoneLinkTile.updateLinkBlockState(true, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
this.shouldnotremove = false;
this.isActive = true;
} else if(inputs[0].floatvalue == 0 && this.isActive && worldObj.blockExists(xCoord, yCoord, zCoord) && worldObj.getBlockId(xCoord, yCoord, zCoord) == WireMod.LinkTileActive.blockID){
this.shouldnotremove = true;
RedstoneLinkTile.updateLinkBlockState(false, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
this.shouldnotremove = false;
this.isActive = false;
}
}
}