Removed BasicComponents
This commit is contained in:
parent
39bcb6ffa1
commit
87d22898a8
30 changed files with 0 additions and 3261 deletions
|
@ -1,54 +0,0 @@
|
|||
package universalelectricity.components.client;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.components.client.gui.GuiBatteryBox;
|
||||
import universalelectricity.components.client.gui.GuiCoalGenerator;
|
||||
import universalelectricity.components.client.gui.GuiElectricFurnace;
|
||||
import universalelectricity.components.common.CommonProxy;
|
||||
import universalelectricity.components.common.tileentity.TileEntityBatteryBox;
|
||||
import universalelectricity.components.common.tileentity.TileEntityCoalGenerator;
|
||||
import universalelectricity.components.common.tileentity.TileEntityCopperWire;
|
||||
import universalelectricity.components.common.tileentity.TileEntityElectricFurnace;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ClientProxy extends CommonProxy
|
||||
{
|
||||
@Override
|
||||
public void preInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCopperWire.class, new RenderCopperWire());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
switch (ID)
|
||||
{
|
||||
case 0:
|
||||
return new GuiBatteryBox(player.inventory, ((TileEntityBatteryBox) tileEntity));
|
||||
case 1:
|
||||
return new GuiCoalGenerator(player.inventory, ((TileEntityCoalGenerator) tileEntity));
|
||||
case 2:
|
||||
return new GuiElectricFurnace(player.inventory, ((TileEntityElectricFurnace) tileEntity));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
package universalelectricity.components.client;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelCopperWire extends ModelBase
|
||||
{
|
||||
// fields
|
||||
ModelRenderer Middle;
|
||||
ModelRenderer Right;
|
||||
ModelRenderer Left;
|
||||
ModelRenderer Back;
|
||||
ModelRenderer Front;
|
||||
ModelRenderer Top;
|
||||
ModelRenderer Bottom;
|
||||
|
||||
public ModelCopperWire()
|
||||
{
|
||||
textureWidth = 64;
|
||||
textureHeight = 32;
|
||||
Middle = new ModelRenderer(this, 0, 0);
|
||||
Middle.addBox(-1F, -1F, -1F, 4, 4, 4);
|
||||
Middle.setRotationPoint(-1F, 15F, -1F);
|
||||
Middle.setTextureSize(64, 32);
|
||||
Middle.mirror = true;
|
||||
setRotation(Middle, 0F, 0F, 0F);
|
||||
Right = new ModelRenderer(this, 21, 0);
|
||||
Right.addBox(0F, 0F, 0F, 6, 4, 4);
|
||||
Right.setRotationPoint(2F, 14F, -2F);
|
||||
Right.setTextureSize(64, 32);
|
||||
Right.mirror = true;
|
||||
setRotation(Right, 0F, 0F, 0F);
|
||||
Left = new ModelRenderer(this, 21, 0);
|
||||
Left.addBox(0F, 0F, 0F, 6, 4, 4);
|
||||
Left.setRotationPoint(-8F, 14F, -2F);
|
||||
Left.setTextureSize(64, 32);
|
||||
Left.mirror = true;
|
||||
setRotation(Left, 0F, 0F, 0F);
|
||||
Back = new ModelRenderer(this, 0, 11);
|
||||
Back.addBox(0F, 0F, 0F, 4, 4, 6);
|
||||
Back.setRotationPoint(-2F, 14F, 2F);
|
||||
Back.setTextureSize(64, 32);
|
||||
Back.mirror = true;
|
||||
setRotation(Back, 0F, 0F, 0F);
|
||||
Front = new ModelRenderer(this, 0, 11);
|
||||
Front.addBox(0F, 0F, 0F, 4, 4, 6);
|
||||
Front.setRotationPoint(-2F, 14F, -8F);
|
||||
Front.setTextureSize(64, 32);
|
||||
Front.mirror = true;
|
||||
setRotation(Front, 0F, 0F, 0F);
|
||||
Top = new ModelRenderer(this, 21, 11);
|
||||
Top.addBox(0F, 0F, 0F, 4, 6, 4);
|
||||
Top.setRotationPoint(-2F, 8F, -2F);
|
||||
Top.setTextureSize(64, 32);
|
||||
Top.mirror = true;
|
||||
setRotation(Top, 0F, 0F, 0F);
|
||||
Bottom = new ModelRenderer(this, 21, 11);
|
||||
Bottom.addBox(0F, 0F, 0F, 4, 6, 4);
|
||||
Bottom.setRotationPoint(-2F, 18F, -2F);
|
||||
Bottom.setTextureSize(64, 32);
|
||||
Bottom.mirror = true;
|
||||
setRotation(Bottom, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
|
||||
{
|
||||
super.render(entity, f, f1, f2, f3, f4, f5);
|
||||
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
|
||||
this.renderMiddle();
|
||||
this.renderBottom();
|
||||
this.renderTop();
|
||||
this.renderLeft();
|
||||
this.renderRight();
|
||||
this.renderBack();
|
||||
this.renderFront();
|
||||
}
|
||||
|
||||
public void renderMiddle()
|
||||
{
|
||||
Middle.render(0.0625F);
|
||||
}
|
||||
|
||||
public void renderBottom()
|
||||
{
|
||||
Bottom.render(0.0625F);
|
||||
}
|
||||
|
||||
public void renderTop()
|
||||
{
|
||||
Top.render(0.0625F);
|
||||
}
|
||||
|
||||
public void renderLeft()
|
||||
{
|
||||
Left.render(0.0625F);
|
||||
}
|
||||
|
||||
public void renderRight()
|
||||
{
|
||||
Right.render(0.0625F);
|
||||
}
|
||||
|
||||
public void renderBack()
|
||||
{
|
||||
Back.render(0.0625F);
|
||||
}
|
||||
|
||||
public void renderFront()
|
||||
{
|
||||
Front.render(0.0625F);
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotationAngles(float x, float y, float z, float f3, float f4, float f5, Entity entity)
|
||||
{
|
||||
super.setRotationAngles(x, y, z, f3, f4, f5, entity);
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package universalelectricity.components.client;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import universalelectricity.components.common.tileentity.TileEntityCopperWire;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderCopperWire extends TileEntitySpecialRenderer
|
||||
{
|
||||
private ModelCopperWire model;
|
||||
|
||||
public RenderCopperWire()
|
||||
{
|
||||
model = new ModelCopperWire();
|
||||
}
|
||||
|
||||
public void renderAModelAt(TileEntityCopperWire tileEntity, double d, double d1, double d2, float f)
|
||||
{
|
||||
// Texture file
|
||||
this.bindTextureByName(BasicComponents.MODEL_TEXTURE_DIRECTORY + "copperWire.png");
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
|
||||
if (tileEntity.visuallyConnected[0])
|
||||
{
|
||||
model.renderBottom();
|
||||
}
|
||||
|
||||
if (tileEntity.visuallyConnected[1])
|
||||
{
|
||||
model.renderTop();
|
||||
}
|
||||
|
||||
if (tileEntity.visuallyConnected[2])
|
||||
{
|
||||
model.renderBack();
|
||||
}
|
||||
|
||||
if (tileEntity.visuallyConnected[3])
|
||||
{
|
||||
model.renderFront();
|
||||
}
|
||||
|
||||
if (tileEntity.visuallyConnected[4])
|
||||
{
|
||||
model.renderLeft();
|
||||
}
|
||||
|
||||
if (tileEntity.visuallyConnected[5])
|
||||
{
|
||||
model.renderRight();
|
||||
}
|
||||
|
||||
model.renderMiddle();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
|
||||
{
|
||||
this.renderAModelAt((TileEntityCopperWire) tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package universalelectricity.components.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import universalelectricity.components.common.container.ContainerBatteryBox;
|
||||
import universalelectricity.components.common.tileentity.TileEntityBatteryBox;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiBatteryBox extends GuiContainer
|
||||
{
|
||||
private TileEntityBatteryBox tileEntity;
|
||||
|
||||
private int containerWidth;
|
||||
private int containerHeight;
|
||||
|
||||
public GuiBatteryBox(InventoryPlayer par1InventoryPlayer, TileEntityBatteryBox batteryBox)
|
||||
{
|
||||
super(new ContainerBatteryBox(par1InventoryPlayer, batteryBox));
|
||||
this.tileEntity = batteryBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
this.fontRenderer.drawString(this.tileEntity.getInvName(), 65, 6, 4210752);
|
||||
String displayJoules = ElectricityDisplay.getDisplayShort(tileEntity.getJoules(), ElectricUnit.JOULES);
|
||||
String displayMaxJoules = ElectricityDisplay.getDisplay(tileEntity.getMaxJoules(), ElectricUnit.JOULES);
|
||||
|
||||
if (this.tileEntity.isDisabled())
|
||||
{
|
||||
displayMaxJoules = "Disabled";
|
||||
}
|
||||
|
||||
this.fontRenderer.drawString(displayJoules + " of", 98 - displayJoules.length(), 30, 4210752);
|
||||
this.fontRenderer.drawString(displayMaxJoules, 78, 40, 4210752);
|
||||
this.fontRenderer.drawString("Voltage: " + (int) this.tileEntity.getVoltage(), 90, 60, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the background layer for the GuiContainer (everything behind the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
this.mc.renderEngine.bindTexture(BasicComponents.GUI_DIRECTORY + "battery_box.png");
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
this.containerWidth = (this.width - this.xSize) / 2;
|
||||
this.containerHeight = (this.height - this.ySize) / 2;
|
||||
// Background energy bar
|
||||
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
|
||||
// Foreground energy bar
|
||||
int scale = (int) (((double) this.tileEntity.getJoules() / this.tileEntity.getMaxJoules()) * 72);
|
||||
this.drawTexturedModalRect(containerWidth + 87, containerHeight + 52, 176, 0, scale, 20);
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package universalelectricity.components.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import universalelectricity.components.common.container.ContainerCoalGenerator;
|
||||
import universalelectricity.components.common.tileentity.TileEntityCoalGenerator;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiCoalGenerator extends GuiContainer
|
||||
{
|
||||
private TileEntityCoalGenerator tileEntity;
|
||||
|
||||
private int containerWidth;
|
||||
private int containerHeight;
|
||||
|
||||
public GuiCoalGenerator(InventoryPlayer par1InventoryPlayer, TileEntityCoalGenerator tileEntity)
|
||||
{
|
||||
super(new ContainerCoalGenerator(par1InventoryPlayer, tileEntity));
|
||||
this.tileEntity = tileEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
this.fontRenderer.drawString(this.tileEntity.getInvName(), 55, 6, 4210752);
|
||||
this.fontRenderer.drawString("Generating", 90, 33, 4210752);
|
||||
String displayText = "";
|
||||
|
||||
if (this.tileEntity.isDisabled())
|
||||
{
|
||||
displayText = "Disabled";
|
||||
}
|
||||
else if (this.tileEntity.generateWatts <= 0)
|
||||
{
|
||||
displayText = "Not Generating";
|
||||
}
|
||||
else if (this.tileEntity.generateWatts < this.tileEntity.MIN_GENERATE_WATTS)
|
||||
{
|
||||
displayText = "Hull Heat: " + (int) (this.tileEntity.generateWatts / this.tileEntity.MIN_GENERATE_WATTS * 100) + "%";
|
||||
}
|
||||
else
|
||||
{
|
||||
displayText = ElectricityDisplay.getDisplay(tileEntity.generateWatts, ElectricUnit.WATT);
|
||||
}
|
||||
|
||||
this.fontRenderer.drawString(displayText, (int) (100 - displayText.length() * 1.25), 45, 4210752);
|
||||
this.fontRenderer.drawString("Voltage: " + (int) this.tileEntity.getVoltage(), 85, 60, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the background layer for the GuiContainer (everything behind the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
this.mc.renderEngine.bindTexture(BasicComponents.GUI_DIRECTORY + "coal_generator.png");
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
containerWidth = (this.width - this.xSize) / 2;
|
||||
containerHeight = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package universalelectricity.components.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import universalelectricity.components.common.container.ContainerElectricFurnace;
|
||||
import universalelectricity.components.common.tileentity.TileEntityElectricFurnace;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiElectricFurnace extends GuiContainer
|
||||
{
|
||||
private TileEntityElectricFurnace tileEntity;
|
||||
|
||||
private int containerWidth;
|
||||
private int containerHeight;
|
||||
|
||||
public GuiElectricFurnace(InventoryPlayer par1InventoryPlayer, TileEntityElectricFurnace tileEntity)
|
||||
{
|
||||
super(new ContainerElectricFurnace(par1InventoryPlayer, tileEntity));
|
||||
this.tileEntity = tileEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
this.fontRenderer.drawString(this.tileEntity.getInvName(), 60, 6, 4210752);
|
||||
this.fontRenderer.drawString("Smelting:", 10, 28, 4210752);
|
||||
this.fontRenderer.drawString("Battery:", 10, 53, 4210752);
|
||||
String displayText = "";
|
||||
|
||||
if (this.tileEntity.isDisabled())
|
||||
{
|
||||
displayText = "Disabled!";
|
||||
}
|
||||
else if (this.tileEntity.processTicks > 0)
|
||||
{
|
||||
displayText = "Smelting";
|
||||
}
|
||||
else
|
||||
{
|
||||
displayText = "Idle";
|
||||
}
|
||||
|
||||
this.fontRenderer.drawString("Status: " + displayText, 82, 45, 4210752);
|
||||
this.fontRenderer.drawString(ElectricityDisplay.getDisplay(this.tileEntity.WATTS_PER_TICK * 20, ElectricUnit.WATT), 82, 56, 4210752);
|
||||
this.fontRenderer.drawString(ElectricityDisplay.getDisplay(this.tileEntity.getVoltage(), ElectricUnit.VOLTAGE), 82, 68, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the background layer for the GuiContainer (everything behind the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
this.mc.renderEngine.bindTexture(BasicComponents.GUI_DIRECTORY + "electric_furnace.png");
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
containerWidth = (this.width - this.xSize) / 2;
|
||||
containerHeight = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if (this.tileEntity.processTicks > 0)
|
||||
{
|
||||
int scale = (int) (((double) this.tileEntity.processTicks / (double) this.tileEntity.PROCESS_TIME_REQUIRED) * 23);
|
||||
this.drawTexturedModalRect(containerWidth + 77, containerHeight + 24, 176, 0, 23 - scale, 20);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,154 +0,0 @@
|
|||
package universalelectricity.components.common;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import universalelectricity.components.common.block.BlockBCOre;
|
||||
import universalelectricity.components.common.block.BlockBasicMachine;
|
||||
import universalelectricity.components.common.block.BlockCopperWire;
|
||||
import universalelectricity.components.common.item.ItemBasic;
|
||||
import universalelectricity.components.common.item.ItemBattery;
|
||||
import universalelectricity.components.common.item.ItemBlockBCOre;
|
||||
import universalelectricity.components.common.item.ItemBlockBasicMachine;
|
||||
import universalelectricity.components.common.item.ItemBlockCopperWire;
|
||||
import universalelectricity.components.common.item.ItemCircuit;
|
||||
import universalelectricity.components.common.item.ItemInfiniteBattery;
|
||||
import universalelectricity.components.common.item.ItemWrench;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.core.item.ElectricItemHelper;
|
||||
import universalelectricity.prefab.RecipeHelper;
|
||||
import universalelectricity.prefab.TranslationHelper;
|
||||
import universalelectricity.prefab.network.ConnectionHandler;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import universalelectricity.prefab.ore.OreGenReplaceStone;
|
||||
import universalelectricity.prefab.ore.OreGenerator;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.PreInit;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
@Mod(modid = BasicComponents.CHANNEL, name = BasicComponents.NAME, version = UniversalElectricity.VERSION)
|
||||
@NetworkMod(channels = BasicComponents.CHANNEL, clientSideRequired = true, serverSideRequired = false, connectionHandler = ConnectionHandler.class, packetHandler = PacketManager.class)
|
||||
public class BCLoader
|
||||
{
|
||||
private static final String[] LANGUAGES_SUPPORTED = new String[] { "en_US", "zh_CN", "es_ES", "it_IT", "nl_NL", "de_DE" };
|
||||
|
||||
@Instance("BasicComponents")
|
||||
public static BCLoader instance;
|
||||
|
||||
@SidedProxy(clientSide = "universalelectricity.components.client.ClientProxy", serverSide = "universalelectricity.components.common.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@PreInit
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
NetworkRegistry.instance().registerGuiHandler(this, this.proxy);
|
||||
|
||||
/**
|
||||
* Define the items and blocks.
|
||||
*/
|
||||
UniversalElectricity.CONFIGURATION.load();
|
||||
BasicComponents.blockBasicOre = new BlockBCOre(UniversalElectricity.CONFIGURATION.getBlock("Copper and Tin Ores", BasicComponents.BLOCK_ID_PREFIX + 0).getInt());
|
||||
BasicComponents.blockCopperWire = new BlockCopperWire(UniversalElectricity.CONFIGURATION.getBlock("Copper_Wire", BasicComponents.BLOCK_ID_PREFIX + 1).getInt());
|
||||
BasicComponents.blockMachine = new BlockBasicMachine(UniversalElectricity.CONFIGURATION.getBlock("Basic Machine", BasicComponents.BLOCK_ID_PREFIX + 4).getInt(), 0);
|
||||
|
||||
BasicComponents.itemInfiniteBattery = new ItemInfiniteBattery(UniversalElectricity.CONFIGURATION.getItem("Infinite Battery", BasicComponents.ITEM_ID_PREFIX + 0).getInt());
|
||||
BasicComponents.itemBattery = new ItemBattery(UniversalElectricity.CONFIGURATION.getItem("Battery", BasicComponents.ITEM_ID_PREFIX + 1).getInt());
|
||||
BasicComponents.itemWrench = new ItemWrench(UniversalElectricity.CONFIGURATION.getItem("Universal Wrench", BasicComponents.ITEM_ID_PREFIX + 2).getInt(), 20);
|
||||
BasicComponents.itemCircuit = new ItemCircuit(UniversalElectricity.CONFIGURATION.getItem("Circuit", BasicComponents.ITEM_ID_PREFIX + 3).getInt(), 16);
|
||||
|
||||
BasicComponents.itemBronzeDust = new ItemBasic("dustBronze", UniversalElectricity.CONFIGURATION.getItem("Bronze Dust", BasicComponents.ITEM_ID_PREFIX + 8).getInt());
|
||||
BasicComponents.itemSteelDust = new ItemBasic("dustSteel", UniversalElectricity.CONFIGURATION.getItem("Steel Dust", BasicComponents.ITEM_ID_PREFIX + 9).getInt());
|
||||
|
||||
BasicComponents.itemMotor = new ItemBasic("motor", UniversalElectricity.CONFIGURATION.getItem("Motor", BasicComponents.ITEM_ID_PREFIX + 14).getInt());
|
||||
|
||||
// Register Blocks
|
||||
GameRegistry.registerBlock(BasicComponents.blockBasicOre, ItemBlockBCOre.class, "Ore");
|
||||
GameRegistry.registerBlock(BasicComponents.blockMachine, ItemBlockBasicMachine.class, "Basic Machine");
|
||||
GameRegistry.registerBlock(BasicComponents.blockCopperWire, ItemBlockCopperWire.class, "Copper Wire");
|
||||
|
||||
BasicComponents.copperOreGeneration = new OreGenReplaceStone("Copper Ore", "oreCopper", new ItemStack(BasicComponents.blockBasicOre, 1, 0), 60, 26, 4).enable(UniversalElectricity.CONFIGURATION);
|
||||
BasicComponents.tinOreGeneration = new OreGenReplaceStone("Tin Ore", "oreTin", new ItemStack(BasicComponents.blockBasicOre, 1, 1), 60, 23, 4).enable(UniversalElectricity.CONFIGURATION);
|
||||
|
||||
UniversalElectricity.CONFIGURATION.save();
|
||||
|
||||
/**
|
||||
* Registering all Basic Component items into the Forge Ore Dictionary.
|
||||
*/
|
||||
OreDictionary.registerOre("copperWire", BasicComponents.blockCopperWire);
|
||||
|
||||
OreDictionary.registerOre("coalGenerator", ((BlockBasicMachine) BasicComponents.blockMachine).getCoalGenerator());
|
||||
OreDictionary.registerOre("batteryBox", ((BlockBasicMachine) BasicComponents.blockMachine).getBatteryBox());
|
||||
OreDictionary.registerOre("electricFurnace", ((BlockBasicMachine) BasicComponents.blockMachine).getElectricFurnace());
|
||||
|
||||
OreDictionary.registerOre("battery", BasicComponents.itemBattery);
|
||||
OreDictionary.registerOre("wrench", BasicComponents.itemWrench);
|
||||
OreDictionary.registerOre("motor", BasicComponents.itemMotor);
|
||||
|
||||
OreDictionary.registerOre("basicCircuit", new ItemStack(BasicComponents.itemCircuit, 1, 0));
|
||||
OreDictionary.registerOre("advancedCircuit", new ItemStack(BasicComponents.itemCircuit, 1, 1));
|
||||
OreDictionary.registerOre("eliteCircuit", new ItemStack(BasicComponents.itemCircuit, 1, 2));
|
||||
|
||||
OreDictionary.registerOre("dustBronze", BasicComponents.itemBronzeDust);
|
||||
OreDictionary.registerOre("dustSteel", BasicComponents.itemSteelDust);
|
||||
|
||||
BasicComponents.requestIngots(0);
|
||||
BasicComponents.requestPlates(0);
|
||||
|
||||
proxy.preInit();
|
||||
}
|
||||
|
||||
@Init
|
||||
public void load(FMLInitializationEvent evt)
|
||||
{
|
||||
proxy.init();
|
||||
|
||||
System.out.println("Basic Components Loaded: " + TranslationHelper.loadLanguages(BasicComponents.LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages.");
|
||||
|
||||
OreGenerator.addOre(BasicComponents.copperOreGeneration);
|
||||
OreGenerator.addOre(BasicComponents.tinOreGeneration);
|
||||
|
||||
// Recipe Registry
|
||||
// Motor
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BasicComponents.itemMotor), new Object[] { "@!@", "!#!", "@!@", '!', "ingotSteel", '#', Item.ingotIron, '@', "copperWire" }));
|
||||
// Wrench
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BasicComponents.itemWrench), new Object[] { " S ", " DS", "S ", 'S', "ingotSteel", 'D', Item.diamond }));
|
||||
// Battery Box
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(OreDictionary.getOres("batteryBox").get(0), new Object[] { "SSS", "BBB", "SSS", 'B', ElectricItemHelper.getUncharged(BasicComponents.itemBattery), 'S', "ingotSteel" }));
|
||||
// Coal Generator
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(OreDictionary.getOres("coalGenerator").get(0), new Object[] { "MMM", "MOM", "MCM", 'M', "ingotSteel", 'C', BasicComponents.itemMotor, 'O', Block.furnaceIdle }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(OreDictionary.getOres("coalGenerator").get(0), new Object[] { "MMM", "MOM", "MCM", 'M', "ingotBronze", 'C', BasicComponents.itemMotor, 'O', Block.furnaceIdle }));
|
||||
// Electric Furnace
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(OreDictionary.getOres("electricFurnace").get(0), new Object[] { "SSS", "SCS", "SMS", 'S', "ingotSteel", 'C', BasicComponents.itemCircuit, 'M', BasicComponents.itemMotor }));
|
||||
// Copper
|
||||
FurnaceRecipes.smelting().addSmelting(BasicComponents.blockBasicOre.blockID, 0, OreDictionary.getOres("ingotCopper").get(0), 0.7f);
|
||||
// Copper Wire
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BasicComponents.blockCopperWire, 6), new Object[] { "!!!", "@@@", "!!!", '!', Block.cloth, '@', "ingotCopper" }));
|
||||
// Tin
|
||||
FurnaceRecipes.smelting().addSmelting(BasicComponents.blockBasicOre.blockID, 1, OreDictionary.getOres("ingotTin").get(0), 0.7f);
|
||||
// Battery
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BasicComponents.itemBattery), new Object[] { " T ", "TRT", "TCT", 'T', "ingotTin", 'R', Item.redstone, 'C', Item.coal }));
|
||||
// Steel
|
||||
RecipeHelper.addRecipe(new ShapedOreRecipe(new ItemStack(BasicComponents.itemSteelDust), new Object[] { " C ", "CIC", " C ", 'C', new ItemStack(Item.coal, 1, 1), 'I', Item.ingotIron }), "Steel Dust", UniversalElectricity.CONFIGURATION, true);
|
||||
RecipeHelper.addRecipe(new ShapedOreRecipe(new ItemStack(BasicComponents.itemSteelDust), new Object[] { " C ", "CIC", " C ", 'C', new ItemStack(Item.coal, 1, 0), 'I', Item.ingotIron }), "Steel Dust", UniversalElectricity.CONFIGURATION, true);
|
||||
GameRegistry.addSmelting(BasicComponents.itemSteelDust.itemID, OreDictionary.getOres("ingotSteel").get(0), 0.8f);
|
||||
// Bronze
|
||||
RecipeHelper.addRecipe(new ShapedOreRecipe(new ItemStack(BasicComponents.itemBronzeDust), new Object[] { "!#!", '!', "ingotCopper", '#', "ingotTin" }), "Bronze Dust", UniversalElectricity.CONFIGURATION, true);
|
||||
GameRegistry.addSmelting(BasicComponents.itemBronzeDust.itemID, OreDictionary.getOres("ingotBronze").get(0), 0.6f);
|
||||
|
||||
// Circuit
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BasicComponents.itemCircuit, 1, 0), new Object[] { "!#!", "#@#", "!#!", '@', "plateBronze", '#', Item.redstone, '!', "copperWire" }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BasicComponents.itemCircuit, 1, 0), new Object[] { "!#!", "#@#", "!#!", '@', "plateSteel", '#', Item.redstone, '!', "copperWire" }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BasicComponents.itemCircuit, 1, 1), new Object[] { "@@@", "#?#", "@@@", '@', Item.redstone, '?', Item.diamond, '#', BasicComponents.itemCircuit }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BasicComponents.itemCircuit, 1, 2), new Object[] { "@@@", "?#?", "@@@", '@', Item.ingotGold, '?', new ItemStack(BasicComponents.itemCircuit, 1, 1), '#', Block.blockLapis }));
|
||||
}
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
package universalelectricity.components.common;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import universalelectricity.components.common.item.ItemIngot;
|
||||
import universalelectricity.components.common.item.ItemPlate;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.core.item.ItemElectric;
|
||||
import universalelectricity.prefab.ore.OreGenBase;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
/**
|
||||
* The main class for managing Basic Component items and blocks. Reference objects from this class
|
||||
* to add them to your recipes and such.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
|
||||
public class BasicComponents
|
||||
{
|
||||
public static final String NAME = "Basic Components";
|
||||
public static final String CHANNEL = "BasicComponents";
|
||||
|
||||
public static final String RESOURCE_PATH = "/mods/basiccomponents/";
|
||||
|
||||
public static final CreativeTabs TAB = new TabBC(CreativeTabs.getNextID(), CHANNEL);
|
||||
|
||||
public static final String TEXTURE_DIRECTORY = RESOURCE_PATH + "textures/";
|
||||
public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/";
|
||||
public static final String BLOCK_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "blocks/";
|
||||
public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/";
|
||||
public static final String MODEL_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "models/";
|
||||
|
||||
public static final String TEXTURE_NAME_PREFIX = "basiccomponents:";
|
||||
|
||||
public static final String LANGUAGE_PATH = RESOURCE_PATH + "languages/";
|
||||
|
||||
public static int BLOCK_ID_PREFIX = 3970;
|
||||
|
||||
public static Block blockBasicOre;
|
||||
public static Block blockCopperWire;
|
||||
public static Block blockMachine;
|
||||
|
||||
public static final int ITEM_ID_PREFIX = 13970;
|
||||
public static ItemElectric itemBattery;
|
||||
public static Item itemInfiniteBattery;
|
||||
public static Item itemWrench;
|
||||
public static Item itemCircuit;
|
||||
public static Item itemBronzeDust;
|
||||
public static Item itemMotor;
|
||||
public static Item itemPlate;
|
||||
public static Item itemIngot;
|
||||
public static Item itemSteelDust;
|
||||
|
||||
public static OreGenBase copperOreGeneration;
|
||||
public static OreGenBase tinOreGeneration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param itemName: Steel, Bronze Copper, Tin
|
||||
* @return
|
||||
*/
|
||||
public static void requestPlates(int id)
|
||||
{
|
||||
if (BasicComponents.itemPlate == null)
|
||||
{
|
||||
UniversalElectricity.CONFIGURATION.load();
|
||||
itemPlate = new ItemPlate(UniversalElectricity.CONFIGURATION.getItem("Plates", BasicComponents.ITEM_ID_PREFIX + 13).getInt());
|
||||
OreDictionary.registerOre("ingotIron", Item.ingotIron);
|
||||
OreDictionary.registerOre("ingotGold", Item.ingotGold);
|
||||
|
||||
for (int i = 0; i < ItemPlate.TYPES.length; i++)
|
||||
{
|
||||
String plateName = ItemPlate.TYPES[i];
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPlate, 1, i), new Object[] { "!!", "!!", '!', plateName.replaceAll("plate", "ingot") }));
|
||||
|
||||
if (plateName.equals("ingotIron"))
|
||||
{
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(Item.ingotIron, new Object[] { new ItemStack(itemPlate, 1, i) }));
|
||||
}
|
||||
else if (plateName.equals("ingotGold"))
|
||||
{
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(Item.ingotGold, new Object[] { new ItemStack(itemPlate, 1, i) }));
|
||||
}
|
||||
|
||||
OreDictionary.registerOre(plateName, new ItemStack(itemPlate, 1, i));
|
||||
}
|
||||
|
||||
UniversalElectricity.CONFIGURATION.save();
|
||||
}
|
||||
}
|
||||
|
||||
public static void requestIngots(int id)
|
||||
{
|
||||
if (BasicComponents.itemIngot == null)
|
||||
{
|
||||
UniversalElectricity.CONFIGURATION.load();
|
||||
BasicComponents.itemIngot = new ItemIngot(UniversalElectricity.CONFIGURATION.getItem("Ingots", BasicComponents.ITEM_ID_PREFIX + 4).getInt());
|
||||
|
||||
for (int i = 0; i < ItemIngot.TYPES.length; i++)
|
||||
{
|
||||
String itemName = ItemIngot.TYPES[i];
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(itemIngot, 1, i), new Object[] { itemName.replaceAll("ingot", "plate") }));
|
||||
OreDictionary.registerOre(itemName, new ItemStack(itemIngot, 1, i));
|
||||
}
|
||||
|
||||
UniversalElectricity.CONFIGURATION.save();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package universalelectricity.components.common;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.components.common.container.ContainerBatteryBox;
|
||||
import universalelectricity.components.common.container.ContainerCoalGenerator;
|
||||
import universalelectricity.components.common.container.ContainerElectricFurnace;
|
||||
import universalelectricity.components.common.tileentity.TileEntityBatteryBox;
|
||||
import universalelectricity.components.common.tileentity.TileEntityCoalGenerator;
|
||||
import universalelectricity.components.common.tileentity.TileEntityCopperWire;
|
||||
import universalelectricity.components.common.tileentity.TileEntityElectricFurnace;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class CommonProxy implements IGuiHandler
|
||||
{
|
||||
public void preInit()
|
||||
{
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
/**
|
||||
* Registering Tile Entities
|
||||
*/
|
||||
GameRegistry.registerTileEntity(TileEntityBatteryBox.class, "UEBatteryBox");
|
||||
GameRegistry.registerTileEntity(TileEntityCoalGenerator.class, "UECoalGenerator");
|
||||
GameRegistry.registerTileEntity(TileEntityElectricFurnace.class, "UEElectricFurnace");
|
||||
GameRegistry.registerTileEntity(TileEntityCopperWire.class, "UECopperWire");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
switch (ID)
|
||||
{
|
||||
case 0:
|
||||
return new ContainerBatteryBox(player.inventory, ((TileEntityBatteryBox) tileEntity));
|
||||
case 1:
|
||||
return new ContainerCoalGenerator(player.inventory, ((TileEntityCoalGenerator) tileEntity));
|
||||
case 2:
|
||||
return new ContainerElectricFurnace(player.inventory, ((TileEntityElectricFurnace) tileEntity));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package universalelectricity.components.common;
|
||||
|
||||
import universalelectricity.components.common.block.BlockBasicMachine;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class TabBC extends CreativeTabs
|
||||
{
|
||||
public TabBC(int par1, String par2Str)
|
||||
{
|
||||
super(par1, par2Str);
|
||||
}
|
||||
|
||||
public ItemStack getIconItemStack()
|
||||
{
|
||||
return new ItemStack(BasicComponents.blockMachine, 1, BlockBasicMachine.BATTERY_BOX_METADATA);
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package universalelectricity.components.common.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
|
||||
public class BlockBCOre extends Block
|
||||
{
|
||||
private Icon iconCopper;
|
||||
private Icon iconTin;
|
||||
|
||||
public BlockBCOre(int id)
|
||||
{
|
||||
super(id, Material.rock);
|
||||
this.setCreativeTab(BasicComponents.TAB);
|
||||
this.setUnlocalizedName("bcOre");
|
||||
this.setHardness(2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBlockTextureFromSideAndMetadata(int side, int metadata)
|
||||
{
|
||||
if (metadata == 1)
|
||||
{
|
||||
return this.iconTin;
|
||||
}
|
||||
|
||||
return this.iconCopper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.iconCopper = par1IconRegister.registerIcon(BasicComponents.TEXTURE_NAME_PREFIX + "oreCopper");
|
||||
this.iconTin = par1IconRegister.registerIcon(BasicComponents.TEXTURE_NAME_PREFIX + "oreTin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int metadata)
|
||||
{
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
}
|
||||
}
|
|
@ -1,385 +0,0 @@
|
|||
package universalelectricity.components.common.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.components.common.BCLoader;
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import universalelectricity.components.common.tileentity.TileEntityBatteryBox;
|
||||
import universalelectricity.components.common.tileentity.TileEntityCoalGenerator;
|
||||
import universalelectricity.components.common.tileentity.TileEntityElectricFurnace;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.prefab.block.BlockAdvanced;
|
||||
|
||||
public class BlockBasicMachine extends BlockAdvanced
|
||||
{
|
||||
public static final int COAL_GENERATOR_METADATA = 0;
|
||||
public static final int BATTERY_BOX_METADATA = 4;
|
||||
public static final int ELECTRIC_FURNACE_METADATA = 8;
|
||||
|
||||
private Icon iconMachineSide;
|
||||
private Icon iconInput;
|
||||
private Icon iconOutput;
|
||||
|
||||
private Icon iconCoalGenerator;
|
||||
private Icon iconBatteryBox;
|
||||
private Icon iconElectricFurnace;
|
||||
|
||||
public BlockBasicMachine(int id, int textureIndex)
|
||||
{
|
||||
super(id, UniversalElectricity.machine);
|
||||
this.setUnlocalizedName("bcMachine");
|
||||
this.setCreativeTab(BasicComponents.TAB);
|
||||
this.setStepSound(soundMetalFootstep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(BasicComponents.TEXTURE_NAME_PREFIX + "machine");
|
||||
this.iconInput = par1IconRegister.registerIcon(BasicComponents.TEXTURE_NAME_PREFIX + "machine_input");
|
||||
this.iconOutput = par1IconRegister.registerIcon(BasicComponents.TEXTURE_NAME_PREFIX + "machine_output");
|
||||
|
||||
this.iconMachineSide = par1IconRegister.registerIcon(BasicComponents.TEXTURE_NAME_PREFIX + "machine_side");
|
||||
this.iconCoalGenerator = par1IconRegister.registerIcon(BasicComponents.TEXTURE_NAME_PREFIX + "coalGenerator");
|
||||
this.iconBatteryBox = par1IconRegister.registerIcon(BasicComponents.TEXTURE_NAME_PREFIX + "batteryBox");
|
||||
this.iconElectricFurnace = par1IconRegister.registerIcon(BasicComponents.TEXTURE_NAME_PREFIX + "electricFurnace");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World par1World, int x, int y, int z, Random par5Random)
|
||||
{
|
||||
TileEntity tile = par1World.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileEntityCoalGenerator)
|
||||
{
|
||||
TileEntityCoalGenerator tileEntity = (TileEntityCoalGenerator) tile;
|
||||
if (tileEntity.generateWatts > 0)
|
||||
{
|
||||
int metadata = par1World.getBlockMetadata(x, y, z);
|
||||
float var7 = (float) x + 0.5F;
|
||||
float var8 = (float) y + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
|
||||
float var9 = (float) z + 0.5F;
|
||||
float var10 = 0.52F;
|
||||
float var11 = par5Random.nextFloat() * 0.6F - 0.3F;
|
||||
|
||||
if (metadata == 3)
|
||||
{
|
||||
par1World.spawnParticle("smoke", (double) (var7 - var10), (double) var8, (double) (var9 + var11), 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", (double) (var7 - var10), (double) var8, (double) (var9 + var11), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (metadata == 2)
|
||||
{
|
||||
par1World.spawnParticle("smoke", (double) (var7 + var10), (double) var8, (double) (var9 + var11), 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", (double) (var7 + var10), (double) var8, (double) (var9 + var11), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (metadata == 1)
|
||||
{
|
||||
par1World.spawnParticle("smoke", (double) (var7 + var11), (double) var8, (double) (var9 - var10), 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", (double) (var7 + var11), (double) var8, (double) (var9 - var10), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (metadata == 0)
|
||||
{
|
||||
par1World.spawnParticle("smoke", (double) (var7 + var11), (double) var8, (double) (var9 + var10), 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", (double) (var7 + var11), (double) var8, (double) (var9 + var10), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBlockTextureFromSideAndMetadata(int side, int metadata)
|
||||
{
|
||||
|
||||
if (side == 0 || side == 1)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
if (metadata >= ELECTRIC_FURNACE_METADATA)
|
||||
{
|
||||
metadata -= ELECTRIC_FURNACE_METADATA;
|
||||
|
||||
// If it is the front side
|
||||
if (side == metadata + 2)
|
||||
{
|
||||
return this.iconInput;
|
||||
}
|
||||
// If it is the back side
|
||||
else if (side == ForgeDirection.getOrientation(metadata + 2).getOpposite().ordinal())
|
||||
{
|
||||
return this.iconElectricFurnace;
|
||||
}
|
||||
}
|
||||
else if (metadata >= BATTERY_BOX_METADATA)
|
||||
{
|
||||
metadata -= BATTERY_BOX_METADATA;
|
||||
|
||||
// If it is the front side
|
||||
if (side == metadata + 2)
|
||||
{
|
||||
return this.iconOutput;
|
||||
}
|
||||
// If it is the back side
|
||||
else if (side == ForgeDirection.getOrientation(metadata + 2).getOpposite().ordinal())
|
||||
{
|
||||
return this.iconInput;
|
||||
}
|
||||
|
||||
return this.iconBatteryBox;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If it is the front side
|
||||
if (side == metadata + 2)
|
||||
{
|
||||
return this.iconOutput;
|
||||
}
|
||||
// If it is the back side
|
||||
else if (side == ForgeDirection.getOrientation(metadata + 2).getOpposite().ordinal())
|
||||
{
|
||||
return this.iconCoalGenerator;
|
||||
}
|
||||
}
|
||||
|
||||
return this.iconMachineSide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityLiving, ItemStack itemStack)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
|
||||
int angle = MathHelper.floor_double((entityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
int change = 0;
|
||||
|
||||
switch (angle)
|
||||
{
|
||||
case 0:
|
||||
change = 1;
|
||||
break;
|
||||
case 1:
|
||||
change = 2;
|
||||
break;
|
||||
case 2:
|
||||
change = 0;
|
||||
break;
|
||||
case 3:
|
||||
change = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
if (metadata >= ELECTRIC_FURNACE_METADATA)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, ELECTRIC_FURNACE_METADATA + change, 3);
|
||||
}
|
||||
else if (metadata >= BATTERY_BOX_METADATA)
|
||||
{
|
||||
switch (angle)
|
||||
{
|
||||
case 0:
|
||||
change = 3;
|
||||
break;
|
||||
case 1:
|
||||
change = 1;
|
||||
break;
|
||||
case 2:
|
||||
change = 2;
|
||||
break;
|
||||
case 3:
|
||||
change = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, BATTERY_BOX_METADATA + change, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, COAL_GENERATOR_METADATA + change, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
int metadata = par1World.getBlockMetadata(x, y, z);
|
||||
int original = metadata;
|
||||
|
||||
int change = 0;
|
||||
|
||||
if (metadata >= ELECTRIC_FURNACE_METADATA)
|
||||
{
|
||||
original -= ELECTRIC_FURNACE_METADATA;
|
||||
}
|
||||
else if (metadata >= BATTERY_BOX_METADATA)
|
||||
{
|
||||
original -= BATTERY_BOX_METADATA;
|
||||
}
|
||||
|
||||
// Re-orient the block
|
||||
switch (original)
|
||||
{
|
||||
case 0:
|
||||
change = 3;
|
||||
break;
|
||||
case 3:
|
||||
change = 1;
|
||||
break;
|
||||
case 1:
|
||||
change = 2;
|
||||
break;
|
||||
case 2:
|
||||
change = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (metadata >= ELECTRIC_FURNACE_METADATA)
|
||||
{
|
||||
change += ELECTRIC_FURNACE_METADATA;
|
||||
}
|
||||
else if (metadata >= BATTERY_BOX_METADATA)
|
||||
{
|
||||
change += BATTERY_BOX_METADATA;
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(x, y, z, change, 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is right clicked by the player
|
||||
*/
|
||||
@Override
|
||||
public boolean onMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
int metadata = par1World.getBlockMetadata(x, y, z);
|
||||
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
if (metadata >= ELECTRIC_FURNACE_METADATA)
|
||||
{
|
||||
par5EntityPlayer.openGui(BCLoader.instance, 2, par1World, x, y, z);
|
||||
return true;
|
||||
}
|
||||
else if (metadata >= BATTERY_BOX_METADATA)
|
||||
{
|
||||
par5EntityPlayer.openGui(BCLoader.instance, 0, par1World, x, y, z);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
par5EntityPlayer.openGui(BCLoader.instance, 1, par1World, x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata)
|
||||
{
|
||||
if (metadata >= ELECTRIC_FURNACE_METADATA)
|
||||
{
|
||||
return new TileEntityElectricFurnace();
|
||||
}
|
||||
else if (metadata >= BATTERY_BOX_METADATA)
|
||||
{
|
||||
return new TileEntityBatteryBox();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TileEntityCoalGenerator();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ItemStack getCoalGenerator()
|
||||
{
|
||||
return new ItemStack(this.blockID, 1, COAL_GENERATOR_METADATA);
|
||||
}
|
||||
|
||||
public ItemStack getBatteryBox()
|
||||
{
|
||||
return new ItemStack(this.blockID, 1, BATTERY_BOX_METADATA);
|
||||
}
|
||||
|
||||
public ItemStack getElectricFurnace()
|
||||
{
|
||||
return new ItemStack(this.blockID, 1, ELECTRIC_FURNACE_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
par3List.add(this.getCoalGenerator());
|
||||
par3List.add(this.getBatteryBox());
|
||||
par3List.add(this.getElectricFurnace());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int metadata)
|
||||
{
|
||||
if (metadata >= ELECTRIC_FURNACE_METADATA)
|
||||
{
|
||||
return ELECTRIC_FURNACE_METADATA;
|
||||
}
|
||||
else if (metadata >= BATTERY_BOX_METADATA)
|
||||
{
|
||||
return BATTERY_BOX_METADATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
return COAL_GENERATOR_METADATA;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
||||
{
|
||||
int id = idPicked(world, x, y, z);
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Item item = Item.itemsList[id];
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int metadata = getDamageValue(world, x, y, z);
|
||||
|
||||
return new ItemStack(id, 1, metadata);
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package universalelectricity.components.common.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import universalelectricity.components.common.tileentity.TileEntityCopperWire;
|
||||
import universalelectricity.prefab.block.BlockConductor;
|
||||
|
||||
public class BlockCopperWire extends BlockConductor
|
||||
{
|
||||
public BlockCopperWire(int id)
|
||||
{
|
||||
super(id, Material.cloth);
|
||||
this.setUnlocalizedName("copperWire");
|
||||
this.setStepSound(soundClothFootstep);
|
||||
this.setResistance(0.2F);
|
||||
this.setHardness(0.1f);
|
||||
this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
|
||||
this.setCreativeTab(BasicComponents.TAB);
|
||||
this.setBurnProperties(this.blockID, 30, 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(BasicComponents.TEXTURE_NAME_PREFIX + this.getUnlocalizedName2());
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the
|
||||
* shared face of two adjacent blocks and also whether the player can attach torches, redstone
|
||||
* wire, etc to this block.
|
||||
*/
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs,
|
||||
* buttons, stairs, etc)
|
||||
*/
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1)
|
||||
{
|
||||
return new TileEntityCopperWire();
|
||||
}
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
package universalelectricity.components.common.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import universalelectricity.components.common.tileentity.TileEntityBatteryBox;
|
||||
import universalelectricity.core.item.IItemElectric;
|
||||
import universalelectricity.prefab.SlotSpecific;
|
||||
|
||||
public class ContainerBatteryBox extends Container
|
||||
{
|
||||
private TileEntityBatteryBox tileEntity;
|
||||
|
||||
public ContainerBatteryBox(InventoryPlayer par1InventoryPlayer, TileEntityBatteryBox batteryBox)
|
||||
{
|
||||
this.tileEntity = batteryBox;
|
||||
// Top slot for battery output
|
||||
this.addSlotToContainer(new SlotSpecific(batteryBox, 0, 33, 24, IItemElectric.class));
|
||||
// Bottom slot for batter input
|
||||
this.addSlotToContainer(new SlotSpecific(batteryBox, 1, 33, 48, IItemElectric.class));
|
||||
int var3;
|
||||
|
||||
for (var3 = 0; var3 < 3; ++var3)
|
||||
{
|
||||
for (int var4 = 0; var4 < 9; ++var4)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (var3 = 0; var3 < 9; ++var3)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
|
||||
}
|
||||
|
||||
tileEntity.openChest();
|
||||
}
|
||||
|
||||
public void onCraftGuiClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onCraftGuiClosed(entityplayer);
|
||||
tileEntity.closeChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotID)
|
||||
{
|
||||
ItemStack returnStack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotID);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemStack = slot.getStack();
|
||||
returnStack = itemStack.copy();
|
||||
|
||||
if (slotID != 0 && slotID != 1)
|
||||
{
|
||||
if (this.getSlot(0).isItemValid(itemStack))
|
||||
{
|
||||
if (((IItemElectric) itemStack.getItem()).getProvideRequest(itemStack).getWatts() > 0)
|
||||
{
|
||||
if (!this.mergeItemStack(itemStack, 1, 2, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this.mergeItemStack(itemStack, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (slotID >= 30 && slotID < 38 && !this.mergeItemStack(itemStack, 3, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemStack, 3, 38, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemStack.stackSize == returnStack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(par1EntityPlayer, itemStack);
|
||||
}
|
||||
|
||||
return returnStack;
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
package universalelectricity.components.common.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import universalelectricity.components.common.tileentity.TileEntityCoalGenerator;
|
||||
|
||||
public class ContainerCoalGenerator extends Container
|
||||
{
|
||||
private TileEntityCoalGenerator tileEntity;
|
||||
|
||||
public ContainerCoalGenerator(InventoryPlayer par1InventoryPlayer, TileEntityCoalGenerator tileEntity)
|
||||
{
|
||||
this.tileEntity = tileEntity;
|
||||
this.addSlotToContainer(new Slot(tileEntity, 0, 33, 34));
|
||||
int var3;
|
||||
|
||||
for (var3 = 0; var3 < 3; ++var3)
|
||||
{
|
||||
for (int var4 = 0; var4 < 9; ++var4)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (var3 = 0; var3 < 9; ++var3)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
|
||||
}
|
||||
|
||||
tileEntity.openChest();
|
||||
}
|
||||
|
||||
public void onCraftGuiClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onCraftGuiClosed(entityplayer);
|
||||
tileEntity.closeChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1)
|
||||
{
|
||||
ItemStack var2 = null;
|
||||
Slot var3 = (Slot) this.inventorySlots.get(par1);
|
||||
|
||||
if (var3 != null && var3.getHasStack())
|
||||
{
|
||||
ItemStack var4 = var3.getStack();
|
||||
var2 = var4.copy();
|
||||
|
||||
if (par1 != 0)
|
||||
{
|
||||
if (var4.itemID == Item.coal.itemID)
|
||||
{
|
||||
if (!this.mergeItemStack(var4, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par1 >= 30 && par1 < 37 && !this.mergeItemStack(var4, 3, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(var4, 3, 37, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (var4.stackSize == 0)
|
||||
{
|
||||
var3.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var3.onSlotChanged();
|
||||
}
|
||||
|
||||
if (var4.stackSize == var2.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var3.onPickupFromSlot(par1EntityPlayer, var4);
|
||||
}
|
||||
|
||||
return var2;
|
||||
}
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
package universalelectricity.components.common.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotFurnace;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import universalelectricity.components.common.tileentity.TileEntityElectricFurnace;
|
||||
import universalelectricity.core.item.IItemElectric;
|
||||
import universalelectricity.prefab.SlotSpecific;
|
||||
|
||||
public class ContainerElectricFurnace extends Container
|
||||
{
|
||||
private TileEntityElectricFurnace tileEntity;
|
||||
|
||||
public ContainerElectricFurnace(InventoryPlayer par1InventoryPlayer, TileEntityElectricFurnace tileEntity)
|
||||
{
|
||||
this.tileEntity = tileEntity;
|
||||
|
||||
// Electric Input Slot
|
||||
this.addSlotToContainer(new SlotSpecific(tileEntity, 0, 55, 49, IItemElectric.class));
|
||||
|
||||
// To be smelted
|
||||
this.addSlotToContainer(new Slot(tileEntity, 1, 55, 25));
|
||||
|
||||
// Smelting result
|
||||
this.addSlotToContainer(new SlotFurnace(par1InventoryPlayer.player, tileEntity, 2, 108, 25));
|
||||
int var3;
|
||||
|
||||
for (var3 = 0; var3 < 3; ++var3)
|
||||
{
|
||||
for (int var4 = 0; var4 < 9; ++var4)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (var3 = 0; var3 < 9; ++var3)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
|
||||
}
|
||||
|
||||
tileEntity.openChest();
|
||||
}
|
||||
|
||||
public void onCraftGuiClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onCraftGuiClosed(entityplayer);
|
||||
tileEntity.closeChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1)
|
||||
{
|
||||
ItemStack var2 = null;
|
||||
Slot var3 = (Slot) this.inventorySlots.get(par1);
|
||||
|
||||
if (var3 != null && var3.getHasStack())
|
||||
{
|
||||
ItemStack var4 = var3.getStack();
|
||||
var2 = var4.copy();
|
||||
|
||||
if (par1 == 2)
|
||||
{
|
||||
if (!this.mergeItemStack(var4, 3, 39, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var3.onSlotChange(var4, var2);
|
||||
}
|
||||
else if (par1 != 1 && par1 != 0)
|
||||
{
|
||||
if (var4.getItem() instanceof IItemElectric)
|
||||
{
|
||||
if (!this.mergeItemStack(var4, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (FurnaceRecipes.smelting().getSmeltingResult(var4) != null)
|
||||
{
|
||||
if (!this.mergeItemStack(var4, 1, 2, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par1 >= 3 && par1 < 30)
|
||||
{
|
||||
if (!this.mergeItemStack(var4, 30, 39, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par1 >= 30 && par1 < 39 && !this.mergeItemStack(var4, 3, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(var4, 3, 39, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (var4.stackSize == 0)
|
||||
{
|
||||
var3.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var3.onSlotChanged();
|
||||
}
|
||||
|
||||
if (var4.stackSize == var2.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var3.onPickupFromSlot(par1EntityPlayer, var4);
|
||||
}
|
||||
|
||||
return var2;
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package universalelectricity.components.common.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBasic extends Item
|
||||
{
|
||||
protected List<Icon> icons = new ArrayList<Icon>();
|
||||
|
||||
public ItemBasic(String name, int id)
|
||||
{
|
||||
super(id);
|
||||
this.setUnlocalizedName(name);
|
||||
this.setCreativeTab(BasicComponents.TAB);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void func_94581_a(IconRegister iconRegister)
|
||||
{
|
||||
List<ItemStack> list = new ArrayList<ItemStack>();
|
||||
this.getSubItems(this.itemID, this.getCreativeTab(), list);
|
||||
|
||||
if (list.size() > 0)
|
||||
{
|
||||
for (ItemStack itemStack : list)
|
||||
{
|
||||
this.icons.add(iconRegister.registerIcon(this.getUnlocalizedName(itemStack).replace("item.", BasicComponents.TEXTURE_NAME_PREFIX)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.iconIndex = iconRegister.registerIcon(this.getUnlocalizedName().replace("item.", BasicComponents.TEXTURE_NAME_PREFIX));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIconFromDamage(int damage)
|
||||
{
|
||||
if (this.icons.size() > damage)
|
||||
{
|
||||
return icons.get(damage);
|
||||
}
|
||||
|
||||
return super.getIconFromDamage(damage);
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package universalelectricity.components.common.item;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import universalelectricity.core.item.ItemElectric;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBattery extends ItemElectric
|
||||
{
|
||||
public ItemBattery(int id)
|
||||
{
|
||||
super(id);
|
||||
this.setUnlocalizedName("battery");
|
||||
this.setCreativeTab(BasicComponents.TAB);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void func_94581_a(IconRegister iconRegister)
|
||||
{
|
||||
this.iconIndex = iconRegister.registerIcon(this.getUnlocalizedName().replace("item.", BasicComponents.TEXTURE_NAME_PREFIX));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxJoules(ItemStack itemStack)
|
||||
{
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getVoltage(ItemStack itemStack)
|
||||
{
|
||||
return 25;
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package universalelectricity.components.common.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemBlockBCOre extends ItemBlock
|
||||
{
|
||||
private String[] ores = { "Copper Ore", "Tin Ore" };
|
||||
|
||||
public ItemBlockBCOre(int id)
|
||||
{
|
||||
super(id);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage)
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack par1ItemStack)
|
||||
{
|
||||
return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + (par1ItemStack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return Block.blocksList[this.getBlockID()].getUnlocalizedName() + ".0";
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package universalelectricity.components.common.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import universalelectricity.components.common.block.BlockBasicMachine;
|
||||
|
||||
public class ItemBlockBasicMachine extends ItemBlock
|
||||
{
|
||||
public ItemBlockBasicMachine(int id)
|
||||
{
|
||||
super(id);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage)
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemstack)
|
||||
{
|
||||
int metadata = 0;
|
||||
|
||||
if (itemstack.getItemDamage() >= BlockBasicMachine.ELECTRIC_FURNACE_METADATA)
|
||||
{
|
||||
metadata = 2;
|
||||
}
|
||||
else if (itemstack.getItemDamage() >= BlockBasicMachine.BATTERY_BOX_METADATA)
|
||||
{
|
||||
metadata = 1;
|
||||
}
|
||||
|
||||
return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return Block.blocksList[this.getBlockID()].getUnlocalizedName() + ".0";
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package universalelectricity.components.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import universalelectricity.components.common.tileentity.TileEntityCopperWire;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
||||
|
||||
public class ItemBlockCopperWire extends ItemBlock
|
||||
{
|
||||
public ItemBlockCopperWire(int id)
|
||||
{
|
||||
super(id);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage)
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Resistance: " + ElectricityDisplay.getDisplay(TileEntityCopperWire.RESISTANCE, ElectricUnit.RESISTANCE));
|
||||
par3List.add("Max Amps: " + ElectricityDisplay.getDisplay(TileEntityCopperWire.MAX_AMPS, ElectricUnit.AMPERE));
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package universalelectricity.components.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemCircuit extends ItemBasic
|
||||
{
|
||||
public static final String[] TYPES = { "circuitBasic", "circuitAdvanced", "circuitElite" };
|
||||
|
||||
public ItemCircuit(int id, int texture)
|
||||
{
|
||||
super("circuit", id);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage)
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return "item." + TYPES[itemStack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List list)
|
||||
{
|
||||
for (int i = 0; i < TYPES.length; i++)
|
||||
{
|
||||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package universalelectricity.components.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
import universalelectricity.core.item.IItemElectric;
|
||||
|
||||
/**
|
||||
* An infinite battery used for players and modders to test things.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class ItemInfiniteBattery extends ItemBasic implements IItemElectric
|
||||
{
|
||||
public ItemInfiniteBattery(int id)
|
||||
{
|
||||
super("infiniteBattery", id);
|
||||
this.setMaxStackSize(1);
|
||||
this.setNoRepair();
|
||||
this.setCreativeTab(BasicComponents.TAB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("\u00a72 Infinite");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getJoules(ItemStack itemStack)
|
||||
{
|
||||
return this.getMaxJoules(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJoules(double joules, ItemStack itemStack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxJoules(ItemStack itemStack)
|
||||
{
|
||||
return Double.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getVoltage(ItemStack itemStack)
|
||||
{
|
||||
return 25;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectricityPack onReceive(ElectricityPack electricityPack, ItemStack itemStack)
|
||||
{
|
||||
return electricityPack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectricityPack onProvide(ElectricityPack electricityPack, ItemStack itemStack)
|
||||
{
|
||||
return electricityPack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectricityPack getReceiveRequest(ItemStack itemStack)
|
||||
{
|
||||
return new ElectricityPack(Double.POSITIVE_INFINITY, this.getVoltage(itemStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectricityPack getProvideRequest(ItemStack itemStack)
|
||||
{
|
||||
return new ElectricityPack(Double.POSITIVE_INFINITY, this.getVoltage(itemStack));
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package universalelectricity.components.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemIngot extends ItemBasic
|
||||
{
|
||||
public static final String[] TYPES = { "ingotCopper", "ingotTin", "ingotBronze", "ingotSteel" };
|
||||
|
||||
public ItemIngot(int id)
|
||||
{
|
||||
super("ingot", id);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage)
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return "item." + TYPES[itemStack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int par1, CreativeTabs creativeTabs, List list)
|
||||
{
|
||||
for (int i = 0; i < TYPES.length; i++)
|
||||
{
|
||||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package universalelectricity.components.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemPlate extends ItemBasic
|
||||
{
|
||||
public static final String[] TYPES = { "plateCopper", "plateTin", "plateBronze", "plateSteel", "plateIron", "plateGold" };
|
||||
|
||||
public ItemPlate(int id)
|
||||
{
|
||||
super("plate", id);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage)
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return "item." + TYPES[itemStack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List list)
|
||||
{
|
||||
for (int i = 0; i < TYPES.length; i++)
|
||||
{
|
||||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package universalelectricity.components.common.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.prefab.implement.IToolConfigurator;
|
||||
|
||||
public class ItemWrench extends ItemBasic implements IToolConfigurator
|
||||
{
|
||||
public ItemWrench(int id, int texture)
|
||||
{
|
||||
super("wrench", id);
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(5000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench(EntityPlayer entityPlayer, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wrenchUsed(EntityPlayer entityPlayer, int x, int y, int z)
|
||||
{
|
||||
if (entityPlayer.getCurrentEquippedItem() != null)
|
||||
{
|
||||
if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemWrench)
|
||||
{
|
||||
entityPlayer.getCurrentEquippedItem().damageItem(1, entityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
|
||||
if (blockID == Block.furnaceIdle.blockID || blockID == Block.furnaceBurning.blockID || blockID == Block.hopperBlock.blockID || blockID == Block.dropper.blockID || blockID == Block.dispenser.blockID || blockID == Block.pistonBase.blockID || blockID == Block.pistonStickyBase.blockID)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
|
||||
int[] rotationMatrix = { 1, 2, 3, 4, 5, 0 };
|
||||
|
||||
if (blockID == Block.furnaceIdle.blockID || blockID == Block.furnaceBurning.blockID)
|
||||
{
|
||||
rotationMatrix = ForgeDirection.ROTATION_MATRIX[0];
|
||||
}
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, ForgeDirection.getOrientation(rotationMatrix[metadata]).ordinal(), 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPassSneakingClickToBlock(World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,310 +0,0 @@
|
|||
package universalelectricity.components.common.tileentity;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.ISidedInventory;
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import universalelectricity.components.common.block.BlockBasicMachine;
|
||||
import universalelectricity.core.block.IElectricityStorage;
|
||||
import universalelectricity.core.electricity.ElectricityNetworkHelper;
|
||||
import universalelectricity.core.electricity.IElectricityNetwork;
|
||||
import universalelectricity.core.item.ElectricItemHelper;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.core.vector.VectorHelper;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import universalelectricity.prefab.tile.TileEntityElectricityStorage;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public class TileEntityBatteryBox extends TileEntityElectricityStorage implements IElectricityStorage, IPacketReceiver, ISidedInventory
|
||||
{
|
||||
private ItemStack[] containingItems = new ItemStack[2];
|
||||
|
||||
private int playersUsing = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (!this.isDisabled())
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
/**
|
||||
* Recharges electric item.
|
||||
*/
|
||||
this.setJoules(this.getJoules() - ElectricItemHelper.chargeItem(this.containingItems[0], this.getJoules(), this.getVoltage()));
|
||||
|
||||
/**
|
||||
* Decharge electric item.
|
||||
*/
|
||||
this.setJoules(this.getJoules() + ElectricItemHelper.dechargeItem(this.containingItems[1], this.getMaxJoules() - this.getJoules(), this.getVoltage()));
|
||||
|
||||
ForgeDirection outputDirection = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockBasicMachine.BATTERY_BOX_METADATA + 2);
|
||||
TileEntity inputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), outputDirection.getOpposite());
|
||||
TileEntity outputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), outputDirection);
|
||||
|
||||
IElectricityNetwork inputNetwork = ElectricityNetworkHelper.getNetworkFromTileEntity(inputTile, outputDirection.getOpposite());
|
||||
IElectricityNetwork outputNetwork = ElectricityNetworkHelper.getNetworkFromTileEntity(outputTile, outputDirection);
|
||||
|
||||
if (outputNetwork != null && inputNetwork != outputNetwork)
|
||||
{
|
||||
double outputWatts = Math.min(outputNetwork.getRequest(this).getWatts(), Math.min(this.getJoules(), 10000));
|
||||
|
||||
if (this.getJoules() > 0 && outputWatts > 0)
|
||||
{
|
||||
outputNetwork.startProducing(this, outputWatts / this.getVoltage(), this.getVoltage());
|
||||
this.setJoules(this.getJoules() - outputWatts);
|
||||
}
|
||||
else
|
||||
{
|
||||
outputNetwork.stopProducing(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gradually lose energy.
|
||||
*/
|
||||
this.setJoules(this.getJoules() - 0.00005);
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (this.ticks % 3 == 0 && this.playersUsing > 0)
|
||||
{
|
||||
PacketManager.sendPacketToClients(getDescriptionPacket(), this.worldObj, new Vector3(this), 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return direction == ForgeDirection.getOrientation(this.getBlockMetadata() - BlockBasicMachine.BATTERY_BOX_METADATA + 2) || direction == ForgeDirection.getOrientation(this.getBlockMetadata() - BlockBasicMachine.BATTERY_BOX_METADATA + 2).getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EnumSet<ForgeDirection> getConsumingSides()
|
||||
{
|
||||
return EnumSet.of(ForgeDirection.getOrientation(this.getBlockMetadata() - BlockBasicMachine.BATTERY_BOX_METADATA + 2).getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return PacketManager.getPacket(BasicComponents.CHANNEL, this, this.getJoules(), this.disabledTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int type, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.setJoules(dataStream.readDouble());
|
||||
this.disabledTicks = dataStream.readInt();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
this.playersUsing++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
this.playersUsing--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
|
||||
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
|
||||
this.containingItems = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
|
||||
{
|
||||
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
|
||||
byte var5 = var4.getByte("Slot");
|
||||
|
||||
if (var5 >= 0 && var5 < this.containingItems.length)
|
||||
{
|
||||
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
NBTTagList var2 = new NBTTagList();
|
||||
|
||||
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
|
||||
{
|
||||
if (this.containingItems[var3] != null)
|
||||
{
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var4.setByte("Slot", (byte) var3);
|
||||
this.containingItems[var3].writeToNBT(var4);
|
||||
var2.appendTag(var4);
|
||||
}
|
||||
}
|
||||
|
||||
par1NBTTagCompound.setTag("Items", var2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartInventorySide(ForgeDirection side)
|
||||
{
|
||||
if (side == side.DOWN)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (side == side.UP)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventorySide(ForgeDirection side)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.containingItems.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int par1)
|
||||
{
|
||||
return this.containingItems[par1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1, int par2)
|
||||
{
|
||||
if (this.containingItems[par1] != null)
|
||||
{
|
||||
ItemStack var3;
|
||||
|
||||
if (this.containingItems[par1].stackSize <= par2)
|
||||
{
|
||||
var3 = this.containingItems[par1];
|
||||
this.containingItems[par1] = null;
|
||||
return var3;
|
||||
}
|
||||
else
|
||||
{
|
||||
var3 = this.containingItems[par1].splitStack(par2);
|
||||
|
||||
if (this.containingItems[par1].stackSize == 0)
|
||||
{
|
||||
this.containingItems[par1] = null;
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int par1)
|
||||
{
|
||||
if (this.containingItems[par1] != null)
|
||||
{
|
||||
ItemStack var2 = this.containingItems[par1];
|
||||
this.containingItems[par1] = null;
|
||||
return var2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
|
||||
{
|
||||
this.containingItems[par1] = par2ItemStack;
|
||||
|
||||
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
|
||||
{
|
||||
par2ItemStack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return LanguageRegistry.instance().getStringLocalization("tile.bcMachine.1.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxJoules()
|
||||
{
|
||||
return 5000000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStackValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,355 +0,0 @@
|
|||
package universalelectricity.components.common.tileentity;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.ISidedInventory;
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import universalelectricity.components.common.block.BlockBasicMachine;
|
||||
import universalelectricity.core.block.IConductor;
|
||||
import universalelectricity.core.electricity.ElectricityNetworkHelper;
|
||||
import universalelectricity.core.electricity.IElectricityNetwork;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.core.vector.VectorHelper;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import universalelectricity.prefab.tile.TileEntityElectrical;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public class TileEntityCoalGenerator extends TileEntityElectrical implements IInventory, ISidedInventory, IPacketReceiver
|
||||
{
|
||||
/**
|
||||
* Maximum amount of energy needed to generate electricity
|
||||
*/
|
||||
public static final int MAX_GENERATE_WATTS = 10000;
|
||||
|
||||
/**
|
||||
* Amount of heat the coal generator needs before generating electricity.
|
||||
*/
|
||||
public static final int MIN_GENERATE_WATTS = 100;
|
||||
|
||||
private static final float BASE_ACCELERATION = 0.3f;
|
||||
|
||||
/**
|
||||
* Per second
|
||||
*/
|
||||
public double prevGenerateWatts, generateWatts = 0;
|
||||
|
||||
public IConductor connectedElectricUnit = null;
|
||||
/**
|
||||
* The number of ticks that a fresh copy of the currently-burning item would keep the furnace
|
||||
* burning for
|
||||
*/
|
||||
public int itemCookTime = 0;
|
||||
/**
|
||||
* The ItemStacks that hold the items currently being used in the battery box
|
||||
*/
|
||||
private ItemStack[] containingItems = new ItemStack[1];
|
||||
|
||||
private int playersUsing = 0;
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return direction == ForgeDirection.getOrientation(this.getBlockMetadata() - BlockBasicMachine.COAL_GENERATOR_METADATA + 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
this.prevGenerateWatts = this.generateWatts;
|
||||
|
||||
// Check nearby blocks and see if the conductor is full. If so, then it is connected
|
||||
ForgeDirection outputDirection = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockBasicMachine.COAL_GENERATOR_METADATA + 2);
|
||||
TileEntity outputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this.xCoord, this.yCoord, this.zCoord), outputDirection);
|
||||
|
||||
IElectricityNetwork network = ElectricityNetworkHelper.getNetworkFromTileEntity(outputTile, outputDirection);
|
||||
|
||||
if (network != null)
|
||||
{
|
||||
if (network.getRequest().getWatts() > 0)
|
||||
{
|
||||
this.connectedElectricUnit = (IConductor) outputTile;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.connectedElectricUnit = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.connectedElectricUnit = null;
|
||||
}
|
||||
|
||||
if (!this.isDisabled())
|
||||
{
|
||||
if (this.itemCookTime > 0)
|
||||
{
|
||||
this.itemCookTime--;
|
||||
|
||||
if (this.connectedElectricUnit != null)
|
||||
{
|
||||
this.generateWatts = (double) Math.min(this.generateWatts + Math.min((this.generateWatts * 0.005 + BASE_ACCELERATION), 5), this.MAX_GENERATE_WATTS);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.containingItems[0] != null && this.connectedElectricUnit != null)
|
||||
{
|
||||
if (this.containingItems[0].getItem().itemID == Item.coal.itemID)
|
||||
{
|
||||
if (this.itemCookTime <= 0)
|
||||
{
|
||||
this.itemCookTime = 320;
|
||||
this.decrStackSize(0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.connectedElectricUnit == null || this.itemCookTime <= 0)
|
||||
{
|
||||
this.generateWatts = (double) Math.max(this.generateWatts - 8, 0);
|
||||
}
|
||||
|
||||
if (this.connectedElectricUnit != null)
|
||||
{
|
||||
if (this.generateWatts > MIN_GENERATE_WATTS)
|
||||
{
|
||||
this.connectedElectricUnit.getNetwork().startProducing(this, (this.generateWatts / this.getVoltage()) / 20, this.getVoltage());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.connectedElectricUnit.getNetwork().stopProducing(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.ticks % 3 == 0 && this.playersUsing > 0)
|
||||
{
|
||||
PacketManager.sendPacketToClients(getDescriptionPacket(), this.worldObj, new Vector3(this), 12);
|
||||
}
|
||||
|
||||
if (this.prevGenerateWatts <= 0 && this.generateWatts > 0 || this.prevGenerateWatts > 0 && this.generateWatts <= 0)
|
||||
{
|
||||
PacketManager.sendPacketToClients(getDescriptionPacket(), this.worldObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return PacketManager.getPacket(BasicComponents.CHANNEL, this, this.generateWatts, this.itemCookTime, this.disabledTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int type, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
this.generateWatts = dataStream.readDouble();
|
||||
this.itemCookTime = dataStream.readInt();
|
||||
this.disabledTicks = dataStream.readInt();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
PacketManager.sendPacketToClients(getDescriptionPacket(), this.worldObj, new Vector3(this), 15);
|
||||
}
|
||||
|
||||
this.playersUsing++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
this.playersUsing--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.itemCookTime = par1NBTTagCompound.getInteger("itemCookTime");
|
||||
this.generateWatts = par1NBTTagCompound.getDouble("generateRate");
|
||||
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
|
||||
this.containingItems = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
|
||||
{
|
||||
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
|
||||
byte var5 = var4.getByte("Slot");
|
||||
|
||||
if (var5 >= 0 && var5 < this.containingItems.length)
|
||||
{
|
||||
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("itemCookTime", this.itemCookTime);
|
||||
par1NBTTagCompound.setDouble("generateRate", this.generateWatts);
|
||||
NBTTagList var2 = new NBTTagList();
|
||||
|
||||
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
|
||||
{
|
||||
if (this.containingItems[var3] != null)
|
||||
{
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var4.setByte("Slot", (byte) var3);
|
||||
this.containingItems[var3].writeToNBT(var4);
|
||||
var2.appendTag(var4);
|
||||
}
|
||||
}
|
||||
|
||||
par1NBTTagCompound.setTag("Items", var2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartInventorySide(ForgeDirection side)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventorySide(ForgeDirection side)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.containingItems.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int par1)
|
||||
{
|
||||
return this.containingItems[par1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1, int par2)
|
||||
{
|
||||
if (this.containingItems[par1] != null)
|
||||
{
|
||||
ItemStack var3;
|
||||
|
||||
if (this.containingItems[par1].stackSize <= par2)
|
||||
{
|
||||
var3 = this.containingItems[par1];
|
||||
this.containingItems[par1] = null;
|
||||
return var3;
|
||||
}
|
||||
else
|
||||
{
|
||||
var3 = this.containingItems[par1].splitStack(par2);
|
||||
|
||||
if (this.containingItems[par1].stackSize == 0)
|
||||
{
|
||||
this.containingItems[par1] = null;
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int par1)
|
||||
{
|
||||
if (this.containingItems[par1] != null)
|
||||
{
|
||||
ItemStack var2 = this.containingItems[par1];
|
||||
this.containingItems[par1] = null;
|
||||
return var2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
|
||||
{
|
||||
this.containingItems[par1] = par2ItemStack;
|
||||
|
||||
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
|
||||
{
|
||||
par2ItemStack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return LanguageRegistry.instance().getStringLocalization("tile.bcMachine.0.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStackValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package universalelectricity.components.common.tileentity;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import universalelectricity.prefab.tile.TileEntityConductor;
|
||||
|
||||
public class TileEntityCopperWire extends TileEntityConductor
|
||||
{
|
||||
/**
|
||||
* Changed this if your mod wants to nerf Basic Component's copper wire.
|
||||
*/
|
||||
public static double RESISTANCE = 0.05;
|
||||
public static double MAX_AMPS = 200;
|
||||
|
||||
public TileEntityCopperWire()
|
||||
{
|
||||
this.channel = BasicComponents.CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getResistance()
|
||||
{
|
||||
return RESISTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCurrentCapcity()
|
||||
{
|
||||
return MAX_AMPS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (this.getNetwork() != null && this.ticks % 20 == 0)
|
||||
{
|
||||
if (this.getNetwork().getProduced().amperes > this.getCurrentCapcity())
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, Block.fire.blockID, 0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,392 +0,0 @@
|
|||
package universalelectricity.components.common.tileentity;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.ISidedInventory;
|
||||
import universalelectricity.components.common.BasicComponents;
|
||||
import universalelectricity.components.common.block.BlockBasicMachine;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
import universalelectricity.core.item.ElectricItemHelper;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import universalelectricity.prefab.tile.TileEntityElectricityRunnable;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public class TileEntityElectricFurnace extends TileEntityElectricityRunnable implements IInventory, ISidedInventory, IPacketReceiver
|
||||
{
|
||||
/**
|
||||
* The amount of watts required every TICK.
|
||||
*/
|
||||
public static final double WATTS_PER_TICK = 500;
|
||||
|
||||
/**
|
||||
* The amount of processing time required.
|
||||
*/
|
||||
public static final int PROCESS_TIME_REQUIRED = 130;
|
||||
|
||||
/**
|
||||
* The amount of ticks this machine has been processing.
|
||||
*/
|
||||
public int processTicks = 0;
|
||||
|
||||
/**
|
||||
* The ItemStacks that hold the items currently being used in the battery box
|
||||
*/
|
||||
private ItemStack[] containingItems = new ItemStack[3];
|
||||
|
||||
/**
|
||||
* The amount of players using the electric furnace.
|
||||
*/
|
||||
private int playersUsing = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
/**
|
||||
* Attempts to charge using batteries.
|
||||
*/
|
||||
this.wattsReceived += ElectricItemHelper.dechargeItem(this.containingItems[0], WATTS_PER_TICK, this.getVoltage());
|
||||
|
||||
/**
|
||||
* Attempts to smelt an item.
|
||||
*/
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (this.canProcess())
|
||||
{
|
||||
if (this.wattsReceived >= this.WATTS_PER_TICK)
|
||||
{
|
||||
if (this.processTicks == 0)
|
||||
{
|
||||
this.processTicks = this.PROCESS_TIME_REQUIRED;
|
||||
}
|
||||
else if (this.processTicks > 0)
|
||||
{
|
||||
this.processTicks--;
|
||||
|
||||
/**
|
||||
* Process the item when the process timer is done.
|
||||
*/
|
||||
if (this.processTicks < 1)
|
||||
{
|
||||
this.smeltItem();
|
||||
this.processTicks = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.processTicks = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.processTicks = 0;
|
||||
}
|
||||
|
||||
this.wattsReceived = Math.max(this.wattsReceived - WATTS_PER_TICK / 4, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.processTicks = 0;
|
||||
}
|
||||
|
||||
if (this.ticks % 3 == 0 && this.playersUsing > 0)
|
||||
{
|
||||
PacketManager.sendPacketToClients(getDescriptionPacket(), this.worldObj, new Vector3(this), 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return direction == ForgeDirection.getOrientation(this.getBlockMetadata() - BlockBasicMachine.ELECTRIC_FURNACE_METADATA + 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectricityPack getRequest()
|
||||
{
|
||||
if (this.canProcess())
|
||||
{
|
||||
return new ElectricityPack(WATTS_PER_TICK / this.getVoltage(), this.getVoltage());
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ElectricityPack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return PacketManager.getPacket(BasicComponents.CHANNEL, this, this.processTicks, this.disabledTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int type, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.processTicks = dataStream.readInt();
|
||||
this.disabledTicks = dataStream.readInt();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
PacketManager.sendPacketToClients(getDescriptionPacket(), this.worldObj, new Vector3(this), 15);
|
||||
}
|
||||
this.playersUsing++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
this.playersUsing--;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Is this machine able to process its specific task?
|
||||
*/
|
||||
public boolean canProcess()
|
||||
{
|
||||
if (FurnaceRecipes.smelting().getSmeltingResult(this.containingItems[1]) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.containingItems[1] == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.containingItems[2] != null)
|
||||
{
|
||||
if (!this.containingItems[2].isItemEqual(FurnaceRecipes.smelting().getSmeltingResult(this.containingItems[1])))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.containingItems[2].stackSize + 1 > 64)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn one item from the furnace source stack into the appropriate smelted item in the furnace
|
||||
* result stack
|
||||
*/
|
||||
public void smeltItem()
|
||||
{
|
||||
if (this.canProcess())
|
||||
{
|
||||
ItemStack resultItemStack = FurnaceRecipes.smelting().getSmeltingResult(this.containingItems[1]);
|
||||
|
||||
if (this.containingItems[2] == null)
|
||||
{
|
||||
this.containingItems[2] = resultItemStack.copy();
|
||||
}
|
||||
else if (this.containingItems[2].isItemEqual(resultItemStack))
|
||||
{
|
||||
this.containingItems[2].stackSize++;
|
||||
}
|
||||
|
||||
this.containingItems[1].stackSize--;
|
||||
|
||||
if (this.containingItems[1].stackSize <= 0)
|
||||
{
|
||||
this.containingItems[1] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.processTicks = par1NBTTagCompound.getInteger("smeltingTicks");
|
||||
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
|
||||
this.containingItems = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
|
||||
{
|
||||
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
|
||||
byte var5 = var4.getByte("Slot");
|
||||
|
||||
if (var5 >= 0 && var5 < this.containingItems.length)
|
||||
{
|
||||
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("smeltingTicks", this.processTicks);
|
||||
NBTTagList var2 = new NBTTagList();
|
||||
|
||||
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
|
||||
{
|
||||
if (this.containingItems[var3] != null)
|
||||
{
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var4.setByte("Slot", (byte) var3);
|
||||
this.containingItems[var3].writeToNBT(var4);
|
||||
var2.appendTag(var4);
|
||||
}
|
||||
}
|
||||
|
||||
par1NBTTagCompound.setTag("Items", var2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartInventorySide(ForgeDirection side)
|
||||
{
|
||||
if (side == side.DOWN || side == side.UP)
|
||||
{
|
||||
return side.ordinal();
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventorySide(ForgeDirection side)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.containingItems.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int par1)
|
||||
{
|
||||
return this.containingItems[par1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1, int par2)
|
||||
{
|
||||
if (this.containingItems[par1] != null)
|
||||
{
|
||||
ItemStack var3;
|
||||
|
||||
if (this.containingItems[par1].stackSize <= par2)
|
||||
{
|
||||
var3 = this.containingItems[par1];
|
||||
this.containingItems[par1] = null;
|
||||
return var3;
|
||||
}
|
||||
else
|
||||
{
|
||||
var3 = this.containingItems[par1].splitStack(par2);
|
||||
|
||||
if (this.containingItems[par1].stackSize == 0)
|
||||
{
|
||||
this.containingItems[par1] = null;
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int par1)
|
||||
{
|
||||
if (this.containingItems[par1] != null)
|
||||
{
|
||||
ItemStack var2 = this.containingItems[par1];
|
||||
this.containingItems[par1] = null;
|
||||
return var2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
|
||||
{
|
||||
this.containingItems[par1] = par2ItemStack;
|
||||
|
||||
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
|
||||
{
|
||||
par2ItemStack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return LanguageRegistry.instance().getStringLocalization("tile.bcMachine.2.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStackValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue