Updated for UE 3.1
This commit is contained in:
parent
aa8432a07a
commit
4dac2739c1
264
minecraft/net/minecraft/src/Utility/BlockTotum.java
Normal file
264
minecraft/net/minecraft/src/Utility/BlockTotum.java
Normal file
|
@ -0,0 +1,264 @@
|
|||
package net.minecraft.src.Utility;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.*;
|
||||
import net.minecraft.src.forge.*;
|
||||
import net.minecraft.src.universalelectricity.*;
|
||||
import net.minecraft.src.universalelectricity.components.UniversalComponents;
|
||||
|
||||
public class BlockTotum extends UEBlockMachine implements ITextureProvider
|
||||
{
|
||||
|
||||
private Random furnaceRand = new Random();
|
||||
private static boolean keepFurnaceInventory = true;
|
||||
|
||||
public BlockTotum(int par1)
|
||||
{
|
||||
super("machine", par1, Material.iron);
|
||||
this.setRequiresSelfNotify();
|
||||
}
|
||||
@Override
|
||||
protected int damageDropped(int metadata)
|
||||
{
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getBlockTexture(IBlockAccess par1iBlockAccess, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity tileEntity = par1iBlockAccess.getBlockTileEntity(x, y, z);
|
||||
int metadata = par1iBlockAccess.getBlockMetadata(x, y, z);
|
||||
|
||||
if (side == 1)
|
||||
{
|
||||
switch(metadata)
|
||||
{
|
||||
case 0: return 1;
|
||||
case 1: return 3;
|
||||
case 2: return 18;
|
||||
case 3: return 5;
|
||||
}
|
||||
}
|
||||
|
||||
//If it is the front side
|
||||
if(side == ((TileEntityTotum)tileEntity).getDirection())
|
||||
{
|
||||
switch(metadata)
|
||||
{
|
||||
|
||||
case 1: return 3;
|
||||
case 3: return 3;
|
||||
}
|
||||
}
|
||||
//If it is the back side
|
||||
else if(side == UniversalElectricity.getOrientationFromSide(((TileEntityTotum)tileEntity).getDirection(), (byte)2))
|
||||
{
|
||||
switch(metadata)
|
||||
{
|
||||
case 0: return 19;
|
||||
case 1: return 6;
|
||||
case 2: return 17;
|
||||
case 3: return 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch(metadata)
|
||||
{
|
||||
case 1: return 4;
|
||||
case 2: return 16;
|
||||
case 3: return 2;
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public int getBlockTextureFromSideAndMetadata(int side, int metadata)
|
||||
{
|
||||
if (side == 1)
|
||||
{
|
||||
switch(metadata)
|
||||
{
|
||||
case 0: return 1;
|
||||
case 1: return 3;
|
||||
case 2: return 18;
|
||||
case 3: return 5;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//If it is the front side
|
||||
if(side == 3)
|
||||
{
|
||||
switch(metadata)
|
||||
{
|
||||
case 0: return 19;
|
||||
case 1: return 6;
|
||||
case 2: return 17;
|
||||
case 3: return 3;
|
||||
}
|
||||
}
|
||||
//If it is the back side
|
||||
else if(side == 2)
|
||||
{
|
||||
switch(metadata)
|
||||
{
|
||||
case 0: return this.blockIndexInTexture + 2;
|
||||
case 1: return this.blockIndexInTexture + 3;
|
||||
case 2: return this.blockIndexInTexture + 2;
|
||||
}
|
||||
}
|
||||
|
||||
switch(metadata)
|
||||
{
|
||||
case 1: return 4;
|
||||
case 2: return 16;
|
||||
case 3: return 2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public boolean blockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
|
||||
{
|
||||
int metadata = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
/**
|
||||
* Check if the player is holding a wrench or an electric item. If so, do not open the GUI.
|
||||
*/
|
||||
if(par5EntityPlayer.inventory.getCurrentItem() != null)
|
||||
{
|
||||
if(par5EntityPlayer.inventory.getCurrentItem().itemID == UniversalComponents.ItemWrench.shiftedIndex)
|
||||
{
|
||||
if(onUseWrench(par1World, par2, par3, par4, par5EntityPlayer))
|
||||
{
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof UEElectricItem)
|
||||
{
|
||||
if(onUseElectricItem(par1World, par2, par3, par4, par5EntityPlayer))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return machineActivated(par1World, par2, par3, par4, par5EntityPlayer);
|
||||
}
|
||||
public boolean onUseElectricItem(World par1World, int par2, int par3,
|
||||
int par4, EntityPlayer par5EntityPlayer) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
public boolean onUseWrench(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
|
||||
{
|
||||
TileEntityTotum tileEntity = (TileEntityTotum)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
//Reorient the block
|
||||
switch(tileEntity.getDirection())
|
||||
{
|
||||
case 2: tileEntity.setDirection((byte)5); break;
|
||||
case 5: tileEntity.setDirection((byte)3); break;
|
||||
case 3: tileEntity.setDirection((byte)4); break;
|
||||
case 4: tileEntity.setDirection((byte)2); break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the
|
||||
* block.
|
||||
*/
|
||||
public boolean machineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer)
|
||||
{
|
||||
if (par1World.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntity blockEntity = (TileEntity)par1World.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (blockEntity != null)
|
||||
{
|
||||
if(blockEntity instanceof TileEntityHealer)
|
||||
{
|
||||
TileEntity var6 = (TileEntityHealer)par1World.getBlockTileEntity(x, y, z);
|
||||
ModLoader.openGUI(par5EntityPlayer, new GUIHealer(par5EntityPlayer.inventory, (TileEntityHealer) var6 )); ;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public TileEntity getBlockEntity(int meta)
|
||||
{
|
||||
switch(meta)
|
||||
{
|
||||
case 0: return new TileEntityHealer();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLiving par5EntityLiving)
|
||||
{
|
||||
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
int metadata = par1World.getBlockMetadata(x, y, z);
|
||||
TileEntityTotum tileEntity = (TileEntityTotum)par1World.getBlockTileEntity(x, y, z);
|
||||
|
||||
if(metadata == 0)
|
||||
{
|
||||
switch (angle)
|
||||
{
|
||||
case 0: tileEntity.setDirection((byte)5); break;
|
||||
case 1: tileEntity.setDirection((byte)3); break;
|
||||
case 2: tileEntity.setDirection((byte)4); break;
|
||||
case 3: tileEntity.setDirection((byte)2); break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (angle)
|
||||
{
|
||||
case 0: tileEntity.setDirection((byte)3); break;
|
||||
case 1: tileEntity.setDirection((byte)4); break;
|
||||
case 2: tileEntity.setDirection((byte)2); break;
|
||||
case 3: tileEntity.setDirection((byte)5); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Called whenever the block is removed.
|
||||
*/
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity getBlockEntity() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String getTextureFile() {
|
||||
// TODO Auto-generated method stub
|
||||
return "/eui/blocks.png";
|
||||
}
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public int getRenderType()
|
||||
{
|
||||
return UniversalComponents.MachineRenderType;
|
||||
}
|
||||
}
|
40
minecraft/net/minecraft/src/Utility/ContainerBoost.java
Normal file
40
minecraft/net/minecraft/src/Utility/ContainerBoost.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package net.minecraft.src.Utility;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ContainerBoost extends Container
|
||||
{
|
||||
private TileEntityBoost tileEntity;
|
||||
|
||||
public ContainerBoost(InventoryPlayer par1InventoryPlayer, TileEntityBoost tileEntity2)
|
||||
{
|
||||
this.tileEntity = tileEntity2;
|
||||
int var3;
|
||||
|
||||
for (var3 = 0; var3 < 3; ++var3)
|
||||
{
|
||||
for (int var4 = 0; var4 < 9; ++var4)
|
||||
{
|
||||
this.addSlot(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (var3 = 0; var3 < 9; ++var3)
|
||||
{
|
||||
this.addSlot(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
public ItemStack transferStackInSlot(int par1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
40
minecraft/net/minecraft/src/Utility/ContainerHealer.java
Normal file
40
minecraft/net/minecraft/src/Utility/ContainerHealer.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package net.minecraft.src.Utility;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ContainerHealer extends Container
|
||||
{
|
||||
private TileEntityHealer tileEntity;
|
||||
|
||||
public ContainerHealer(InventoryPlayer par1InventoryPlayer, TileEntityHealer tileEntity)
|
||||
{
|
||||
this.tileEntity = tileEntity;
|
||||
int var3;
|
||||
|
||||
for (var3 = 0; var3 < 3; ++var3)
|
||||
{
|
||||
for (int var4 = 0; var4 < 9; ++var4)
|
||||
{
|
||||
this.addSlot(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (var3 = 0; var3 < 9; ++var3)
|
||||
{
|
||||
this.addSlot(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
public ItemStack transferStackInSlot(int par1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
54
minecraft/net/minecraft/src/Utility/GUIBoost.java
Normal file
54
minecraft/net/minecraft/src/Utility/GUIBoost.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
package net.minecraft.src.Utility;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import java.math.*;
|
||||
import java.lang.Integer;
|
||||
import net.minecraft.src.*;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
import net.minecraft.src.universalelectricity.components.ContainerCoalGenerator;
|
||||
import net.minecraft.src.universalelectricity.components.TileEntityCoalGenerator;
|
||||
|
||||
public class GUIBoost extends GuiContainer
|
||||
{
|
||||
private TileEntityBoost tileEntity;
|
||||
|
||||
private int containerWidth;
|
||||
private int containerHeight;
|
||||
|
||||
public GUIBoost(InventoryPlayer par1InventoryPlayer, TileEntityBoost tileEntity)
|
||||
{
|
||||
super(new ContainerBoost(par1InventoryPlayer, tileEntity));
|
||||
this.tileEntity = tileEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
protected void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
this.fontRenderer.drawString("Doc-o-Matic", 55, 6, 4210752);
|
||||
this.fontRenderer.drawString("MeterReadings", 90, 33, 4210752);
|
||||
String displayText = "";
|
||||
String displayText2 = "";
|
||||
String displayText3 = "";
|
||||
displayText2 = "Energy" + "-" + tileEntity.eStored;
|
||||
displayText3 = "Effects" + "-" + tileEntity.hStored;
|
||||
this.fontRenderer.drawString(displayText, (int)(105-displayText.length()*1), 45, 4210752);
|
||||
this.fontRenderer.drawString(displayText2, (int)(105-displayText.length()*1), 55, 4210752);
|
||||
this.fontRenderer.drawString(displayText3, (int)(105-displayText.length()*1), 65, 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)
|
||||
*/
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
int var4 = this.mc.renderEngine.getTexture("/eui/SteamGUI.png");
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.renderEngine.bindTexture(var4);
|
||||
containerWidth = (this.width - this.xSize) / 2;
|
||||
containerHeight = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
}
|
54
minecraft/net/minecraft/src/Utility/GUIHealer.java
Normal file
54
minecraft/net/minecraft/src/Utility/GUIHealer.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
package net.minecraft.src.Utility;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import java.math.*;
|
||||
import java.lang.Integer;
|
||||
import net.minecraft.src.*;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
import net.minecraft.src.universalelectricity.components.ContainerCoalGenerator;
|
||||
import net.minecraft.src.universalelectricity.components.TileEntityCoalGenerator;
|
||||
|
||||
public class GUIHealer extends GuiContainer
|
||||
{
|
||||
private TileEntityHealer tileEntity;
|
||||
|
||||
private int containerWidth;
|
||||
private int containerHeight;
|
||||
|
||||
public GUIHealer(InventoryPlayer par1InventoryPlayer, TileEntityHealer tileEntity)
|
||||
{
|
||||
super(new ContainerHealer(par1InventoryPlayer, tileEntity));
|
||||
this.tileEntity = tileEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
protected void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
this.fontRenderer.drawString("Doc-o-Matic", 55, 6, 4210752);
|
||||
this.fontRenderer.drawString("MeterReadings", 90, 33, 4210752);
|
||||
String displayText = "";
|
||||
String displayText2 = "";
|
||||
String displayText3 = "";
|
||||
displayText2 = "Energy" + "-" + tileEntity.eStored;
|
||||
displayText3 = "heals" + "-" + tileEntity.hStored;
|
||||
this.fontRenderer.drawString(displayText, (int)(105-displayText.length()*1), 45, 4210752);
|
||||
this.fontRenderer.drawString(displayText2, (int)(105-displayText.length()*1), 55, 4210752);
|
||||
this.fontRenderer.drawString(displayText3, (int)(105-displayText.length()*1), 65, 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)
|
||||
*/
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
int var4 = this.mc.renderEngine.getTexture("/eui/SteamGUI.png");
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.renderEngine.bindTexture(var4);
|
||||
containerWidth = (this.width - this.xSize) / 2;
|
||||
containerHeight = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
}
|
47
minecraft/net/minecraft/src/Utility/ItemTotum.java
Normal file
47
minecraft/net/minecraft/src/Utility/ItemTotum.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package net.minecraft.src.Utility;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ItemTotum extends ItemBlock {
|
||||
|
||||
public ItemTotum(int id) {
|
||||
super(id);
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
public int getMetadata(int metadata)
|
||||
{
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public String getItemName()
|
||||
{
|
||||
return "Totum";
|
||||
}
|
||||
|
||||
public int getPlacedBlockMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public String getItemNameIS(ItemStack par1ItemStack)
|
||||
{
|
||||
int var3 = par1ItemStack.getItemDamage();
|
||||
switch(var3)
|
||||
{
|
||||
case 0: return "Healer";
|
||||
case 1: return "Booster";
|
||||
case 2: return "";
|
||||
case 3: return "";
|
||||
case 15: return "";
|
||||
}
|
||||
return this.getItemName();
|
||||
}
|
||||
public void addCreativeItems(ArrayList itemList) {
|
||||
|
||||
itemList.add(new ItemStack(this, 1,0));
|
||||
itemList.add(new ItemStack(this, 1,1));
|
||||
|
||||
}
|
||||
|
||||
}
|
228
minecraft/net/minecraft/src/Utility/TileEntityBoost.java
Normal file
228
minecraft/net/minecraft/src/Utility/TileEntityBoost.java
Normal file
|
@ -0,0 +1,228 @@
|
|||
package net.minecraft.src.Utility;
|
||||
import net.minecraft.src.eui.TileEntityMachine;
|
||||
import net.minecraft.src.eui.api.*;
|
||||
import net.minecraft.src.forge.ForgeHooks;
|
||||
import net.minecraft.src.*;
|
||||
import net.minecraft.src.universalelectricity.*;
|
||||
import net.minecraft.src.forge.ISidedInventory;
|
||||
|
||||
public class TileEntityBoost extends TileEntityTotum implements UEIConsumer, IInventory, ISidedInventory
|
||||
{
|
||||
//Maximum possible generation rate of watts in SECONDS
|
||||
public UETileEntityConductor connectedWire = null;
|
||||
/**
|
||||
* The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
|
||||
*/
|
||||
public int itemCookTime = 0;
|
||||
public int eStored = 0;
|
||||
public int hStored = 0;
|
||||
public int tCount = 0;
|
||||
/**
|
||||
* The ItemStacks that hold the items currently being used in the battery box
|
||||
*/
|
||||
private ItemStack[] containingItems = new ItemStack[1];
|
||||
|
||||
/**
|
||||
* Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
|
||||
* ticks and creates a new spawn inside its implementation.
|
||||
*/
|
||||
public void updateEntity()
|
||||
{
|
||||
if(eStored >= 1000 && hStored < 100)
|
||||
{
|
||||
eStored -= 1000;
|
||||
hStored += 1;
|
||||
}
|
||||
if(hStored > 0 && tCount > 40)
|
||||
{
|
||||
if(this.containingItems[0] != null && this.containingItems[0].itemID == 373)
|
||||
{
|
||||
|
||||
EntityPlayer player = this.worldObj.getClosestPlayer(xCoord, yCoord, zCoord, 4.0F);
|
||||
if(player != null){
|
||||
//player.addPotionEffect(par1PotionEffect);
|
||||
hStored -= 1;
|
||||
tCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
tCount++;
|
||||
}
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.itemCookTime = par1NBTTagCompound.getInteger("itemCookTime");
|
||||
this.eStored = par1NBTTagCompound.getInteger("EU");
|
||||
this.hStored = par1NBTTagCompound.getInteger("HP");
|
||||
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.
|
||||
*/
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("itemCookTime", (int)this.itemCookTime);
|
||||
par1NBTTagCompound.setInteger("EU", (int)this.eStored);
|
||||
par1NBTTagCompound.setInteger("HP", (int)this.hStored);
|
||||
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(int side)
|
||||
{
|
||||
if (side == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (side == 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventorySide(int side) { return getSizeInventory(); }
|
||||
@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 "SteamGen";
|
||||
}
|
||||
@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((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
@Override
|
||||
public void openChest() { }
|
||||
@Override
|
||||
public void closeChest() { }
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getVolts() {
|
||||
// TODO Auto-generated method stub
|
||||
return 12000;
|
||||
}
|
||||
@Override
|
||||
public int onReceiveElectricity(int watts, int voltage, byte side) {
|
||||
if(this.eStored < this.getElectricityCapacity())
|
||||
{
|
||||
int rejectedElectricity = Math.max((this.eStored + watts) - this.getElectricityCapacity(), 0);
|
||||
this.eStored += watts - rejectedElectricity;
|
||||
return rejectedElectricity;
|
||||
}
|
||||
return watts;
|
||||
}
|
||||
@Override
|
||||
public boolean canReceiveElectricity(byte side) {
|
||||
if(side == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int getStoredElectricity() {
|
||||
return eStored;
|
||||
}
|
||||
@Override
|
||||
public int getElectricityCapacity() {
|
||||
return 1000;
|
||||
}
|
||||
@Override
|
||||
public void onDisable(int duration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
228
minecraft/net/minecraft/src/Utility/TileEntityHealer.java
Normal file
228
minecraft/net/minecraft/src/Utility/TileEntityHealer.java
Normal file
|
@ -0,0 +1,228 @@
|
|||
package net.minecraft.src.Utility;
|
||||
import net.minecraft.src.eui.TileEntityMachine;
|
||||
import net.minecraft.src.eui.api.*;
|
||||
import net.minecraft.src.forge.ForgeHooks;
|
||||
import net.minecraft.src.*;
|
||||
import net.minecraft.src.universalelectricity.*;
|
||||
import net.minecraft.src.forge.ISidedInventory;
|
||||
|
||||
public class TileEntityHealer extends TileEntityTotum implements UEIConsumer, IInventory, ISidedInventory
|
||||
{
|
||||
//Maximum possible generation rate of watts in SECONDS
|
||||
public UETileEntityConductor connectedWire = null;
|
||||
/**
|
||||
* The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
|
||||
*/
|
||||
public int itemCookTime = 0;
|
||||
public int eStored = 0;
|
||||
public int hStored = 0;
|
||||
public int tCount = 0;
|
||||
/**
|
||||
* The ItemStacks that hold the items currently being used in the battery box
|
||||
*/
|
||||
private ItemStack[] containingItems = new ItemStack[1];
|
||||
|
||||
/**
|
||||
* Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
|
||||
* ticks and creates a new spawn inside its implementation.
|
||||
*/
|
||||
public void updateEntity()
|
||||
{
|
||||
if(eStored >= 1000 && hStored < 100)
|
||||
{
|
||||
eStored -= 1000;
|
||||
hStored += 1;
|
||||
}
|
||||
if(hStored > 0 && tCount > 40)
|
||||
{
|
||||
EntityPlayer player = this.worldObj.getClosestPlayer(xCoord, yCoord, zCoord, 4.0F);
|
||||
if(player != null){
|
||||
|
||||
if(player.getHealth() < player.heartsHalvesLife)
|
||||
{
|
||||
System.out.println("hearts"+ player.getHealth());
|
||||
System.out.println("heartsMax"+ player.heartsHalvesLife);
|
||||
player.heal(1);
|
||||
hStored -= 1;
|
||||
tCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
tCount++;
|
||||
}
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.itemCookTime = par1NBTTagCompound.getInteger("itemCookTime");
|
||||
this.eStored = par1NBTTagCompound.getInteger("EU");
|
||||
this.hStored = par1NBTTagCompound.getInteger("HP");
|
||||
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.
|
||||
*/
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("itemCookTime", (int)this.itemCookTime);
|
||||
par1NBTTagCompound.setInteger("EU", (int)this.eStored);
|
||||
par1NBTTagCompound.setInteger("HP", (int)this.hStored);
|
||||
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(int side)
|
||||
{
|
||||
if (side == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (side == 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventorySide(int side) { return getSizeInventory(); }
|
||||
@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 "SteamGen";
|
||||
}
|
||||
@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((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
@Override
|
||||
public void openChest() { }
|
||||
@Override
|
||||
public void closeChest() { }
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getVolts() {
|
||||
// TODO Auto-generated method stub
|
||||
return 12000;
|
||||
}
|
||||
@Override
|
||||
public int onReceiveElectricity(int watts, int voltage, byte side) {
|
||||
if(this.eStored < this.getElectricityCapacity())
|
||||
{
|
||||
int rejectedElectricity = Math.max((this.eStored + watts) - this.getElectricityCapacity(), 0);
|
||||
this.eStored += watts - rejectedElectricity;
|
||||
return rejectedElectricity;
|
||||
}
|
||||
return watts;
|
||||
}
|
||||
@Override
|
||||
public boolean canReceiveElectricity(byte side) {
|
||||
if(side == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int getStoredElectricity() {
|
||||
return eStored;
|
||||
}
|
||||
@Override
|
||||
public int getElectricityCapacity() {
|
||||
return 1000;
|
||||
}
|
||||
@Override
|
||||
public void onDisable(int duration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
56
minecraft/net/minecraft/src/Utility/TileEntityTotum.java
Normal file
56
minecraft/net/minecraft/src/Utility/TileEntityTotum.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package net.minecraft.src.Utility;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
import net.minecraft.src.forge.ITextureProvider;
|
||||
import net.minecraft.src.universalelectricity.UEIRotatable;
|
||||
import net.minecraft.src.universalelectricity.components.UniversalComponents;
|
||||
|
||||
public class TileEntityTotum extends TileEntity implements ITextureProvider,UEIRotatable {
|
||||
private int facing;
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("facing", (int)this.facing);
|
||||
|
||||
}
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.facing = par1NBTTagCompound.getInteger("facing");
|
||||
}
|
||||
public TileEntity getSteamMachine(int i)
|
||||
{
|
||||
|
||||
int x = this.xCoord;
|
||||
int y = this.yCoord;
|
||||
int z = this.zCoord;
|
||||
switch(i){
|
||||
case 0: y = y - 1;break;
|
||||
case 1: y = y + 1;break;
|
||||
case 2: z = z + 1;break;
|
||||
case 3: z = z - 1;break;
|
||||
case 4: x = x + 1;break;
|
||||
case 5: x = x - 1;break;
|
||||
}
|
||||
TileEntity aEntity = worldObj.getBlockTileEntity(x, y, z);
|
||||
if(aEntity instanceof TileEntityTotum)
|
||||
{
|
||||
return aEntity;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public byte getDirection() {
|
||||
// TODO Auto-generated method stub
|
||||
return (byte) this.facing;
|
||||
}
|
||||
public void setDirection(byte facingDirection) {
|
||||
this.facing = facingDirection;
|
||||
}
|
||||
@Override
|
||||
public String getTextureFile()
|
||||
{
|
||||
return "/eui/blocks.png";
|
||||
}
|
||||
|
||||
}
|
|
@ -54,7 +54,7 @@ public class TileEntityCondenser extends TileEntityMachine implements IWaterProd
|
|||
return rejectedElectricity;
|
||||
}
|
||||
@Override
|
||||
public boolean canRecieveElectricity(byte side) {
|
||||
public boolean canReceiveElectricity(byte side) {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
@ -73,6 +73,17 @@ public class TileEntityCondenser extends TileEntityMachine implements IWaterProd
|
|||
// TODO Auto-generated method stub
|
||||
return 240;
|
||||
}
|
||||
@Override
|
||||
public void onDisable(int duration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ public class TileEntityNuller extends TileEntityMachine implements UEIConsumer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canRecieveElectricity(byte side) {
|
||||
public boolean canReceiveElectricity(byte side) {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
@ -34,4 +34,16 @@ public class TileEntityNuller extends TileEntityMachine implements UEIConsumer {
|
|||
return 100000000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(int duration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -372,7 +372,7 @@ public class TileEntityGrinder extends TileEntityMachine implements IInventory,
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canRecieveElectricity(byte side) {
|
||||
public boolean canReceiveElectricity(byte side) {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
@ -382,5 +382,17 @@ public class TileEntityGrinder extends TileEntityMachine implements IInventory,
|
|||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(int duration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -302,4 +302,16 @@ public class TileEntityGenerator extends TileEntityMachine implements UEIProduce
|
|||
// TODO Auto-generated method stub
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(int duration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class mod_EUIndustry extends NetworkMod {
|
|||
@Override
|
||||
public void load() {
|
||||
//register
|
||||
UniversalElectricity.registerAddon(this, "0.2.0");
|
||||
UniversalElectricity.registerAddon(this, "0.3.1");
|
||||
MinecraftForgeClient.preloadTexture("/eui/Blocks.png");
|
||||
MinecraftForgeClient.preloadTexture("/eui/Items.png");
|
||||
//Blocks
|
||||
|
|
24
minecraft/net/minecraft/src/mod_UtilityBlocks.java
Normal file
24
minecraft/net/minecraft/src/mod_UtilityBlocks.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package net.minecraft.src;
|
||||
import net.minecraft.src.eui.steam.RenderPipeWater;
|
||||
import net.minecraft.src.forge.*;
|
||||
import net.minecraft.src.universalelectricity.UEBlockRenderer;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
import net.minecraft.src.universalelectricity.components.UniversalComponents;
|
||||
public class mod_UtilityBlocks extends NetworkMod {
|
||||
|
||||
public static Block totum = new net.minecraft.src.Utility.BlockTotum(210).setBlockName("totum");
|
||||
@Override
|
||||
public String getVersion() {
|
||||
// TODO change each update
|
||||
return "V0.0.1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
UniversalElectricity.registerAddon(this, "0.3.1");
|
||||
ModLoader.registerBlock(totum,net.minecraft.src.eui.ItemMachine.class);
|
||||
ModLoader.registerTileEntity(net.minecraft.src.Utility.TileEntityHealer.class, "healer", new UEBlockRenderer());
|
||||
ModLoader.addShapelessRecipe(new ItemStack(totum, 1,0), new Object[] { new ItemStack(Block.dirt,1)});
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue