diff options
| author | Foghrye4 <foghrye4@gmail.com> | 2017-06-17 08:12:18 +0300 |
|---|---|---|
| committer | Foghrye4 <foghrye4@gmail.com> | 2017-06-17 08:12:18 +0300 |
| commit | dc3df3edd5843bde0c1335d6a8e460b2c832aa48 (patch) | |
| tree | af13bfeee567f2351e35e1ef176d168fe37c8aac /ihl/trans_dimensional_item_teleporter | |
| parent | 1da8dcd58647e34c9af94ceeecaeaf3b0d08c48c (diff) | |
full project files
Diffstat (limited to 'ihl/trans_dimensional_item_teleporter')
5 files changed, 0 insertions, 942 deletions
diff --git a/ihl/trans_dimensional_item_teleporter/TDITBlock.java b/ihl/trans_dimensional_item_teleporter/TDITBlock.java deleted file mode 100644 index 584692d..0000000 --- a/ihl/trans_dimensional_item_teleporter/TDITBlock.java +++ /dev/null @@ -1,132 +0,0 @@ -package ihl.trans_dimensional_item_teleporter;
-
-import java.util.Random;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import ic2.api.item.IC2Items;
-import ihl.IHLCreativeTab;
-import ihl.IHLModInfo;
-import net.minecraft.block.Block;
-import net.minecraft.block.ITileEntityProvider;
-import net.minecraft.block.material.Material;
-import net.minecraft.client.renderer.texture.IIconRegister;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.IIcon;
-import net.minecraft.world.IBlockAccess;
-import net.minecraft.world.World;
-
-public class TDITBlock extends Block implements ITileEntityProvider{
-
- IIcon textureLeft, textureRight, textureBack, textureBottom;
-
- public TDITBlock(Material material)
- {
- super(material);
- this.setCreativeTab(IHLCreativeTab.tab);
- }
-
- @Override
- public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
- {
- return IC2Items.getItem("machine").getItem();
- }
-
- @Override
- public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
- {
- }
-
- @Override
- public TileEntity createNewTileEntity(World world, int var2) {
- return new TDITTileEntity();
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public void registerBlockIcons(IIconRegister par1IconRegister)
- {
- this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditTop");
- this.textureBack = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditBack");
- this.textureLeft = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditLeft");
- this.textureRight = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditRight");
- this.textureBottom = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditBottom");
- }
-
- @Override
- public boolean hasTileEntity(int metadata)
- {
- return true;
- }
-
- @Override
- public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z){
- TileEntity te = world.getTileEntity(x,y,z);
- if(te instanceof TDITTileEntity)
- {
- TDITTileEntity bte = (TDITTileEntity)te;
- if (bte == null || entityPlayer.isSneaking()) {
- return false;
- }
- else if(entityPlayer.getCurrentEquippedItem()==null || !(entityPlayer.getCurrentEquippedItem().getItem() instanceof TDITFrequencyTransmitter))
- {
- return bte.getGui(entityPlayer);
- }
- }
- return false;
- }
-
- /**
- * Called when the block is placed in the world.
- */
-
-
- @Override
- @SideOnly(Side.CLIENT)
- public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
- {
- switch (side)
- {
- case 0:
- return this.textureBottom;
- case 1:
- return this.blockIcon;
- case 2:
- return this.textureBack;
- case 3:
- return this.textureBack;
- case 4:
- return this.textureLeft;
- case 5:
- return this.textureRight;
- default:
- return this.blockIcon;
- }
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public IIcon getIcon(int side, int meta)
- {
- switch (side)
- {
- case 0:
- return this.textureBottom;
- case 1:
- return this.blockIcon;
- case 2:
- return this.textureBack;
- case 3:
- return this.textureBack;
- case 4:
- return this.textureLeft;
- case 5:
- return this.textureRight;
- default:
- return this.blockIcon;
- }
- }
-
-}
diff --git a/ihl/trans_dimensional_item_teleporter/TDITContainer.java b/ihl/trans_dimensional_item_teleporter/TDITContainer.java deleted file mode 100644 index 35dd1a0..0000000 --- a/ihl/trans_dimensional_item_teleporter/TDITContainer.java +++ /dev/null @@ -1,93 +0,0 @@ -package ihl.trans_dimensional_item_teleporter;
-
-import ic2.core.ContainerBase;
-import ic2.core.slot.SlotInvSlot;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.ICrafting;
-import net.minecraft.inventory.Slot;
-
-public class TDITContainer extends ContainerBase<TDITTileEntity> {
-
- protected TDITTileEntity tileEntity;
- public int lastStorage = -1;
- private final static int height=166;
-
- public TDITContainer(EntityPlayer entityPlayer, TDITTileEntity tileEntity1){
- super(tileEntity1);
- this.tileEntity = tileEntity1;
- int col, row;
-
- for (col = 0; col < 3; ++col)
- {
- for (int col1 = 0; col1 < 9; ++col1)
- {
- this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18));
- }
- }
-
- for (col = 0; col < 9; ++col)
- {
- this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24));
- }
-
- this.addSlotToContainer(new SlotInvSlot(tileEntity1.dischargeSlot, 0, 8, 44));
- for(row=0;row<=3;row++)
- {
- this.addSlotToContainer(new SlotInvSlot(tileEntity1.upgradeSlot, row, 152, 8+row*18));
- }
- for(row=0;row<=2;row++)
- {
- for(col=0;col<=2;col++)
- {
- this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputSlot, row+col*3, 31+col*18, 8+row*18));
- }
- }
- for(row=0;row<=2;row++)
- {
- for(col=0;col<=2;col++)
- {
- this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, row+col*3, 89+col*18, 8+row*18));
- }
- }
- }
-
- @Override
- public void detectAndSendChanges()
- {
- super.detectAndSendChanges();
- for (int i = 0; i < this.crafters.size(); ++i)
- {
- ICrafting icrafting = (ICrafting)this.crafters.get(i);
-
- if (this.tileEntity.getStored() != this.lastStorage)
- {
- icrafting.sendProgressBarUpdate(this, 0, (this.tileEntity.getStored()>>15) & Short.MAX_VALUE);
- icrafting.sendProgressBarUpdate(this, 1, (short)(this.tileEntity.getStored() & Short.MAX_VALUE));
-
- }
- }
-
- this.lastStorage = this.tileEntity.getStored();
- }
-
- @Override
- public void updateProgressBar(int index, int value)
- {
- super.updateProgressBar(index, value);
-
- switch (index)
- {
- case 0:
- this.tileEntity.setStored(value<<15);
- break;
- case 1:
- this.tileEntity.setStored(this.tileEntity.getStored()+value);
- break;
- }
- }
-
- @Override
- public boolean canInteractWith(EntityPlayer var1) {
- return tileEntity.isUseableByPlayer(var1);
- }
-}
diff --git a/ihl/trans_dimensional_item_teleporter/TDITFrequencyTransmitter.java b/ihl/trans_dimensional_item_teleporter/TDITFrequencyTransmitter.java deleted file mode 100644 index 633b824..0000000 --- a/ihl/trans_dimensional_item_teleporter/TDITFrequencyTransmitter.java +++ /dev/null @@ -1,172 +0,0 @@ -package ihl.trans_dimensional_item_teleporter;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import ic2.api.item.IItemHudInfo;
-import ic2.core.IC2;
-import ic2.core.util.StackUtil;
-import ihl.IHLCreativeTab;
-import ihl.IHLModInfo;
-import net.minecraft.client.renderer.texture.IIconRegister;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.IIcon;
-import net.minecraft.world.World;
-
-public class TDITFrequencyTransmitter extends Item implements IItemHudInfo {
-
- IIcon textureDamaged;
-
- public TDITFrequencyTransmitter()
- {
- super();
- this.setCreativeTab(IHLCreativeTab.tab);
- this.maxStackSize=1;
- this.setMaxDamage(0);
- }
-
- @Override
- public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
- {
- if (IC2.platform.isSimulating())
- {
- if (itemstack.getItemDamage() == 0)
- {
- NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(itemstack);
-
- if (nbtData.getBoolean("targetSet"))
- {
- nbtData.setBoolean("targetSet", false);
- IC2.platform.messagePlayer(entityplayer, "TDIT Frequency Transmitter unlinked", new Object[0]);
- }
- }
- else
- {
- itemstack.setItemDamage(0);
- }
- }
-
- return itemstack;
- }
-
- @Override
- public boolean onItemUseFirst(ItemStack itemstack, EntityPlayer entityPlayer, World world, int x, int y, int z, int l, float hitX, float hitY, float hitZ)
- {
- TileEntity tileEntity = world.getTileEntity(x, y, z);
-
- if (tileEntity instanceof TDITTileEntity && IC2.platform.isSimulating())
- {
- NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(itemstack);
- boolean targetSet = nbtData.getBoolean("targetSet");
- int dimesionID = nbtData.getInteger("dimesionID");
- int targetX = nbtData.getInteger("targetX");
- int targetY = nbtData.getInteger("targetY");
- int targetZ = nbtData.getInteger("targetZ");
- TDITTileEntity tp = (TDITTileEntity)tileEntity;
-
- if (!targetSet)
- {
- targetSet = true;
- dimesionID = world.provider.dimensionId;
- targetX = tp.xCoord;
- targetY = tp.yCoord;
- targetZ = tp.zCoord;
- IC2.platform.messagePlayer(entityPlayer, "TDIT Frequency Transmitter linked to TDIT.", new Object[0]);
- }
- else if (tp.xCoord == targetX && tp.yCoord == targetY && tp.zCoord == targetZ)
- {
- IC2.platform.messagePlayer(entityPlayer, "Can\'t link TDIT to itself.", new Object[0]);
- }
- else if (tp.targetSet && tp.targetX == targetX && tp.targetY == targetY && tp.targetZ == targetZ)
- {
- IC2.platform.messagePlayer(entityPlayer, "TDIT link unchanged.", new Object[0]);
- }
- else
- {
- tp.setTarget(targetX, targetY, targetZ, dimesionID);
-
- TileEntity te1 = MinecraftServer.getServer().worldServerForDimension(dimesionID).getTileEntity(targetX, targetY, targetZ);
-
- if (te1 instanceof TDITTileEntity)
- {
- TDITTileEntity tp21 = (TDITTileEntity)te1;
-
- if (!tp21.targetSet)
- {
- tp21.setTarget(tp.xCoord, tp.yCoord, tp.zCoord, dimesionID);
- }
- }
-
- IC2.platform.messagePlayer(entityPlayer, "Teleportation link established.", new Object[0]);
- }
-
- nbtData.setBoolean("targetSet", targetSet);
- nbtData.setInteger("dimesionID", dimesionID);
- nbtData.setInteger("targetX", targetX);
- nbtData.setInteger("targetY", targetY);
- nbtData.setInteger("targetZ", targetZ);
- itemstack.setItemDamage(1);
- return false;
- }
- else
- {
- return false;
- }
- }
-
- @Override
- public List<String> getHudInfo(ItemStack itemStack) {
- LinkedList<String> info = new LinkedList<String>();
- if(itemStack.stackTagCompound!=null)
- {
- NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(itemStack);
- boolean targetSet = nbtData.getBoolean("targetSet");
- if(targetSet)
- {
- int dimesionID = nbtData.getInteger("dimesionID");
- int targetX = nbtData.getInteger("targetX");
- int targetY = nbtData.getInteger("targetY");
- int targetZ = nbtData.getInteger("targetZ");
- info.add("Dimesion ID: " + dimesionID);
- info.add("X coord: " + targetX);
- info.add("Y coord: " + targetY);
- info.add("Z coord: " + targetZ);
- }
- else
- {
- info.add("Memory clean");
- }
- }
- return info;
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public void registerIcons(IIconRegister iconRegister)
- {
- this.itemIcon=iconRegister.registerIcon(IHLModInfo.MODID + ":itemTDITFT");
- this.textureDamaged=iconRegister.registerIcon(IHLModInfo.MODID + ":itemTDITFT_1");
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public IIcon getIconFromDamage(int meta)
- {
- switch(meta)
- {
- case 0:
- return this.itemIcon;
- case 1:
- return this.textureDamaged;
- default:
- return this.itemIcon;
- }
- }
-}
diff --git a/ihl/trans_dimensional_item_teleporter/TDITGui.java b/ihl/trans_dimensional_item_teleporter/TDITGui.java deleted file mode 100644 index 5966e5e..0000000 --- a/ihl/trans_dimensional_item_teleporter/TDITGui.java +++ /dev/null @@ -1,48 +0,0 @@ -package ihl.trans_dimensional_item_teleporter;
-
-import org.lwjgl.opengl.GL11;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import net.minecraft.client.gui.inventory.GuiContainer;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.StatCollector;
-
-@SideOnly(Side.CLIENT)
-public class TDITGui extends GuiContainer {
- private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUITDIT.png");
- private TDITContainer container;
-
- public TDITGui (TDITContainer container1) {
- //the container is instanciated and passed to the superclass for handling
- super(container1);
- this.container=container1;
- }
-
- @Override
- protected void drawGuiContainerForegroundLayer(int param1, int param2)
- {
- //the parameters for drawString are: string, x, y, color
- String status = StatCollector.translateToLocal("ihl.gui.tdit.message" + this.container.tileEntity.currentStatus);
- fontRendererObj.drawString(status, 12, 68, 852037);
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- this.mc.renderEngine.bindTexture(background);
- //charge
- if (this.container.tileEntity.getStored() > 0)
- {
- int chargeLevel=Math.min(Math.round(this.container.tileEntity.getStored()*13.0F/this.container.tileEntity.maxStorage),13);
- this.drawTexturedModalRect(11, 28+13-chargeLevel, xSize, 13-chargeLevel, 7, chargeLevel);
- }
- }
-
- @Override
- protected void drawGuiContainerBackgroundLayer(float par1, int par2,
- int par3) {
- //draw your Gui here, only thing you need to change is the path
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- this.mc.renderEngine.bindTexture(background);
- int x = (width - xSize) / 2;
- int y = (height - ySize) / 2;
- this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
- }
-}
\ No newline at end of file diff --git a/ihl/trans_dimensional_item_teleporter/TDITTileEntity.java b/ihl/trans_dimensional_item_teleporter/TDITTileEntity.java deleted file mode 100644 index d54a705..0000000 --- a/ihl/trans_dimensional_item_teleporter/TDITTileEntity.java +++ /dev/null @@ -1,497 +0,0 @@ -package ihl.trans_dimensional_item_teleporter;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import ic2.api.energy.event.EnergyTileLoadEvent;
-import ic2.api.energy.event.EnergyTileUnloadEvent;
-import ic2.api.energy.tile.IEnergySink;
-import ic2.api.item.IC2Items;
-import ic2.api.network.NetworkHelper;
-import ic2.core.ContainerBase;
-import ic2.core.IC2;
-import ic2.core.IHasGui;
-import ic2.core.audio.AudioSource;
-import ic2.core.audio.PositionSpec;
-import ic2.core.block.TileEntityInventory;
-import ic2.core.block.invslot.InvSlot;
-import ic2.core.block.invslot.InvSlot.Access;
-import ic2.core.block.invslot.InvSlotOutput;
-import ic2.core.block.invslot.InvSlotUpgrade;
-import ic2.core.upgrade.IUpgradableBlock;
-import ic2.core.upgrade.IUpgradeItem;
-import ic2.core.upgrade.UpgradableProperty;
-import ihl.IHLMod;
-import ihl.utils.IHLInvSlotDischarge;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.entity.item.EntityItem;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.world.World;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.common.util.ForgeDirection;
-
-public class TDITTileEntity extends TileEntityInventory implements IEnergySink, IHasGui, IUpgradableBlock
-{
- private int tier=4;
- private int defaultTier=4;
- public int maxStorage=12000;
- private int defaultMaxStorage=12000;
- private double energy=0D;
- private double energyConsume=12000D;//per full stack
- public boolean addedToEnergyNet = false;
- public final InvSlotUpgrade upgradeSlot;
- public final IHLInvSlotDischarge dischargeSlot;
- public final InvSlotOutput outputSlot;
- public final InvSlot inputSlot;
-
- public int updateChecksum=-1;
-
- private AudioSource startAS;
- public boolean targetSet=false;
- public int targetDimension;
- public int targetX;
- public int targetY;
- public int targetZ;
- /** 0 - Ready, 100%
- * 1 - Not enough energy
- * 2 - Receiver not responding
- * 3 - Receiver not defined
- * 4 - Clean receiver chamber!
- */
- public int currentStatus=0;
- public int lastStatus=0;
- private int timer=0;
-
-
- public TDITTileEntity()
- {
- this.defaultTier=IHLMod.config.tditTier;
- this.defaultMaxStorage=IHLMod.config.tditMaxEnergyStorage;
- this.energyConsume=IHLMod.config.tditEnergyConsumePerStack;
- this.dischargeSlot = new IHLInvSlotDischarge(this, 0, Access.IO, this.tier, InvSlot.InvSide.SIDE);
- this.upgradeSlot = new InvSlotUpgrade(this, "upgrade", 1, 4);
- this.outputSlot = new InvSlotOutput(this, "output", 2, 9);
- this.inputSlot = new InvSlot(this, "input", 2, InvSlot.Access.I, 9, InvSlot.InvSide.TOP);
- }
-
- @Override
- public List<String> getNetworkedFields()
- {
- List<String> fields = super.getNetworkedFields();
- fields.add("tier");
- fields.add("maxStorage");
- fields.add("currentStatus");
- return fields;
- }
-
- @Override
- public void readFromNBT(NBTTagCompound nbttagcompound)
- {
- super.readFromNBT(nbttagcompound);
- try
- {
- this.energy = nbttagcompound.getDouble("energy");
- }
- catch (Exception var3)
- {
- this.energy = nbttagcompound.getInteger("energy");
-
- if (this.maxStorage > Integer.MAX_VALUE)
- {
- this.energy *= 10.0D;
- }
- }
- this.targetSet = nbttagcompound.getBoolean("targetSet");
- this.targetDimension = nbttagcompound.getInteger("targetDimension");
- this.targetX = nbttagcompound.getInteger("targetX");
- this.targetY = nbttagcompound.getInteger("targetY");
- this.targetZ = nbttagcompound.getInteger("targetZ");
- }
-
- @Override
- public void writeToNBT(NBTTagCompound nbttagcompound)
- {
- super.writeToNBT(nbttagcompound);
- nbttagcompound.setDouble("energy", this.energy);
- nbttagcompound.setBoolean("targetSet", this.targetSet);
- nbttagcompound.setInteger("targetDimension", this.targetDimension);
- nbttagcompound.setInteger("targetX", this.targetX);
- nbttagcompound.setInteger("targetY", this.targetY);
- nbttagcompound.setInteger("targetZ", this.targetZ);
- }
-
- @Override
- public void onLoaded()
- {
- super.onLoaded();
- if (IC2.platform.isSimulating())
- {
- MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
- this.addedToEnergyNet = true;
- }
- if (IC2.platform.isRendering() && this.startAS==null)
- {
- this.startAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStartSoundFile(),false,false, 1F);
- }
- }
-
- @Override
- public void onUnloaded()
- {
- if (IC2.platform.isRendering() && this.startAS != null)
- {
- this.startAS.stop();
- this.startAS = null;
- IC2.audioManager.removeSources(this);
- }
-
- if (IC2.platform.isSimulating() && this.addedToEnergyNet)
- {
- MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
- this.addedToEnergyNet = false;
- }
- super.onUnloaded();
- }
-
- @Override
- public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
- return false;
- }
-
- @Override
- public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
- if(this.dischargeSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.dischargeSlot.get()));
- if(this.upgradeSlot.get(0)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(0)));
- if(this.upgradeSlot.get(1)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(1)));
- if(this.upgradeSlot.get(2)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(2)));
- if(this.upgradeSlot.get(3)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(3)));
- return new ItemStack(IHLMod.tditBlock,1);
- }
-
- @Override
- public void setFacing(short facing1)
- {
- super.setFacing(facing1);
- this.updateChecksum=-1;
- }
-
- public boolean enableUpdateEntity()
- {
- return true;
- }
-
- public String getStartSoundFile()
- {
- return "Machines/IHL Industrial Fan/start.ogg";
- }
-
- public String getLoopSoundFile()
- {
- return "Machines/IHL Industrial Fan/loop.ogg";
- }
-
- public String getStopSoundFile()
- {
- return "Machines/IHL Industrial Fan/stop.ogg";
- }
-
- @Override
- public void updateEntityServer()
- {
-
- if (IC2.platform.isSimulating())
- {
- this.setOverclockRates();
- if(this.timer>0)
- {
- this.timer--;
- }
- else
- {
- this.timer=60;
- int energyToOperate=this.countEnergyToOperate();
- if(energyToOperate>0 && energyToOperate<=this.energy)
- {
- this.sendItemStack();
- this.energy-=energyToOperate;
- }
- else if(energyToOperate==0 && this.energy>100D)
- {
- this.currentStatus=0;
- }
- else
- {
- this.currentStatus=1;
- }
- if(this.currentStatus!=this.lastStatus)
- {
- NetworkHelper.updateTileEntityField(this, "currentStatus");
- this.lastStatus=this.currentStatus;
- }
-
- }
-
- }
- if(this.dischargeSlot.tier!=this.tier)
- {
- this.dischargeSlot.tier=this.tier;
- }
- if(this.getDemandedEnergy() > 1.0D)
- {
- double amount = this.dischargeSlot.discharge(this.getDemandedEnergy(), false);
- this.energy += amount;
- }
- if(this.energy>this.maxStorage)
- {
- this.energy=this.maxStorage;
- }
-
-
- if(IC2.platform.isRendering() && this.startAS!=null)
- {
- if(this.getActive())
- {
- this.startAS.play();
- }
- else
- {
- this.startAS.stop();
- }
- }
-
- }
-
- @Override
- public boolean acceptsEnergyFrom(TileEntity emitter,
- ForgeDirection direction) {
- return true;
- }
-
- @Override
- public String getInventoryName() {
- return "tdit";
- }
-
- public int getStored() {
- return Math.round((float)this.energy);
- }
-
- public void setStored(int value) {
- this.energy=value;
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public GuiScreen getGui(EntityPlayer arg0, boolean arg1) {
- return new TDITGui(new TDITContainer(arg0, this));
- }
-
- public boolean getGui(EntityPlayer player)
- {
- return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false;
- }
-
- @Override
- public ContainerBase<?> getGuiContainer(EntityPlayer arg0) {
- return new TDITContainer(arg0, this);
- }
- @Override
- public void onGuiClosed(EntityPlayer arg0) {}
-
- public void setOverclockRates()
- {
- int tierUp=0;
- int capacityUp=0;
- int checksum=0;
- for(int i=0;i<this.upgradeSlot.size();i++)
- {
- if(this.upgradeSlot.get(i)!=null)
- {
- if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("transformerUpgrade").getItemDamage())
- {
- tierUp+=this.upgradeSlot.get(i).stackSize;
- }
- if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("energyStorageUpgrade").getItemDamage())
- {
- capacityUp+=this.upgradeSlot.get(i).stackSize;
- }
- }
- }
- checksum=tierUp*64+capacityUp;
- if(this.updateChecksum!=checksum)
- {
- this.maxStorage=this.defaultMaxStorage + capacityUp*10000;
- NetworkHelper.updateTileEntityField(this, "maxStorage");
- this.tier=this.defaultTier+tierUp;
- NetworkHelper.updateTileEntityField(this, "tier");
- this.updateChecksum=checksum;
- }
- }
-
- //1.7.10 API
- @Override
- public double getDemandedEnergy()
- {
- return this.maxStorage - this.energy;
- }
-
- @Override
- public int getSinkTier()
- {
- return this.tier;
- }
-
- @Override
- public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
- {
- if (this.energy >= this.maxStorage)
- {
- return amount;
- }
- else
- {
- this.energy += amount;
- return 0.0D;
- }
- }
-
- public void setTarget(int targetX2, int targetY2, int targetZ2, int dimesionID) {
- this.targetSet=true;
- this.targetX=targetX2;
- this.targetY=targetY2;
- this.targetZ=targetZ2;
- this.targetDimension=dimesionID;
- }
-
- public boolean canRecieve(List<ItemStack> itemStackList)
- {
- int countEmptySlots=0;
- for(int i=0;i<this.outputSlot.size();i++)
- {
- if(this.outputSlot.get(i)==null)
- {
- countEmptySlots++;
- }
- }
- return countEmptySlots>=itemStackList.size();
- }
-
- public void recieveItemStack(List<ItemStack> itemStackList)
- {
- this.outputSlot.add(itemStackList);
- for (int i = 0; i < this.upgradeSlot.size(); ++i)
- {
- ItemStack stack = this.upgradeSlot.get(i);
-
- if (stack != null && stack.getItem() instanceof ic2.core.upgrade.IUpgradeItem && ((IUpgradeItem)stack.getItem()).onTick(stack, this))
- {
- //needsInvUpdate = true;
- }
- }
- }
-
- private int countEnergyToOperate()
- {
- int energy = 0;
- for(int i=0;i<this.inputSlot.size();i++)
- {
- if(this.inputSlot.get(i)!=null)
- {
- energy+=this.energyConsume*this.inputSlot.get(i).stackSize/this.inputSlot.get(i).getMaxStackSize();
- }
- }
- return energy;
-
- }
-
- public void sendItemStack()
- {
- if(!this.inputSlot.isEmpty() && this.targetSet)
- {
- World targetWorld = MinecraftServer.getServer().worldServerForDimension(this.targetDimension);
- if(targetWorld!=null)
- {
- TileEntity te = targetWorld.getTileEntity(targetX, targetY, targetZ);
- if(te!=null && te instanceof TDITTileEntity)
- {
- TDITTileEntity tdit = (TDITTileEntity) te;
- List<ItemStack> itemStackList = new ArrayList<ItemStack>();
- for(int i=0;i<this.inputSlot.size();i++)
- {
- if(this.inputSlot.get(i)!=null)
- {
- itemStackList.add(this.inputSlot.get(i));
- }
- }
- if(tdit.canRecieve(itemStackList))
- {
- tdit.recieveItemStack(itemStackList);
- this.inputSlot.clear();
- }
- else
- {
- this.currentStatus=4;
- }
- }
- else
- {
- this.currentStatus=2;
- }
- }
- }
- else
- {
- this.currentStatus=3;
- }
- }
-
- public ItemStack getOutput(int arg0)
- {
- return this.outputSlot.get(arg0);
- }
-
- public int getOutputSize() {
- return this.outputSlot.size();
- }
-
- public void setOutput(int arg0, ItemStack arg1)
- {
- this.outputSlot.put(arg0, arg1);
- }
-
- @Override
- public Set<UpgradableProperty> getUpgradableProperties()
- {
- Set<UpgradableProperty> properties = new HashSet<UpgradableProperty>();
- properties.add(UpgradableProperty.ItemProducing);
- properties.add(UpgradableProperty.EnergyStorage);
- return properties;
- }
-
- @Override
- public double getEnergy() {
- return this.energy;
- }
-
- @Override
- public boolean useEnergy(double arg0) {
- if(this.energy>=arg0)
- {
- this.energy-=arg0;
- return true;
- }
- else
- {
- return false;
- }
-
- }
-}
\ No newline at end of file |
