Jump to content

limexplosion7

Members
  • Posts

    4
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

limexplosion7's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hello. I'm making a vehicle entity. The class is barebones but I can't get the interact() to work properly. I have a simple print line but it's not being called. Entity class: And the registration if it helps:
  2. I did, set it to print yes inside the if statement or no outside of it, it printed no. I'll have a look at some other tile entities and see if i can find the problem.
  3. Yes, my block implements ITileEntityProvider and the tile entity is registered. Everything works, the GUI opens, the NBT tags are persistent, it just won't run the code inside the (!worldObj.isRemote). I removed that line to test it out but it didn't work either.
  4. I am making a machine and have all the things ready (gui,slots,container) but the (!worldObj.isRemote) condition is not triggering in the updateEntity() regardless of any changes I have made to it. package limemods.advpwrsys; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.item.ItemStack; import cofh.api.energy.IEnergyReceiver; import cofh.api.energy.EnergyStorage; import net.minecraftforge.common.util.ForgeDirection; public class TileEntityProcessor extends TileEntity implements ISidedInventory { protected EnergyStorage energy = new EnergyStorage(32000); private ItemStack[] slots = new ItemStack[3]; public int cycleTime; private String customName; private static final int[] slots_top = new int[] {0,1}; private static final int[] slots_bottom = new int[] {2}; public int getEnergyScaled() { return (energy.getEnergyStored() * 62 / 32000); } public int getProgressScaled() { return (cycleTime * 24 / 80); } public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setShort("CycleTime", (short)cycleTime); NBTTagList list = new NBTTagList(); for (int i = 0; i < slots.length; i++) { if (slots[i]!=null) { NBTTagCompound nbt1 = new NBTTagCompound(); nbt1.setByte("Slot", (byte) i); slots[i].writeToNBT(nbt1); list.appendTag(nbt1); } } nbt.setTag("Items",list); } public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("Items", 10); slots = new ItemStack[getSizeInventory()]; for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound nbt1 = (NBTTagCompound)list.getCompoundTagAt(i); byte b0 = nbt1.getByte("Slot"); if (b0 >= 0 && b0 < slots.length) { slots[b0] = ItemStack.loadItemStackFromNBT(nbt1); } } cycleTime = nbt.getShort("CycleTime"); } public void updateEntity() { boolean f = cycleTime > 0; boolean f1 = false; if (!worldObj.isRemote) { if (canCycle()) { cycleTime++; if (cycleTime == 40) { cycleTime = 0; cycle(); f1 = true; } else { cycleTime = 0; } } if (f != cycleTime > 0) { f1 = true; BlockProcessor.updateBlockState(cycleTime > 0, worldObj, xCoord,yCoord,zCoord); } } if (f1) { this.markDirty(); } } private void cycle() { if (canCycle()) { ItemStack is = ProcessorRecipes.getOutput(slots[0].getItem(), slots[1].getItem()); if (slots[2] == null) { slots[2] = is.copy(); } else if (slots[2].isItemEqual(is)) { slots[2].stackSize+=1; } for (int i = 0; i<2;i++) { if (slots[i].stackSize <= 0) { slots[i] = new ItemStack(slots[i].getItem().setFull3D()); }else{ slots[i].stackSize--; } if(slots[i].stackSize<=0) { slots[i] = null; } } } } public boolean canExtractItem(int i, ItemStack itemstack, int j) { return j != 0 || i != 1; } public int getInventoryStackLimit() {return 64;} private boolean canCycle() { // TODO: Restore energy requirement if (slots[0] == null || slots[1] == null){ return false; } ItemStack is = ProcessorRecipes.getOutput(slots[0].getItem(), slots[1].getItem()); if (is==null){return false;} if(slots[2]==null){return true;} if(!slots[2].isItemEqual(is)){return false;} //if (energy.getEnergyStored() < 800) {return false;} if(slots[2].stackSize < getInventoryStackLimit() && slots[3].stackSize < slots[3].getMaxStackSize()){ return true;} else{return false;} } public int[] getAccessibleSlotsFromSide(int i) { return i == 0 ? slots_bottom : slots_top; } public boolean canConnectEnergy(ForgeDirection fd) {return true;} public int receiveEnergy(ForgeDirection fd, int i, boolean b) { return energy.receiveEnergy(i,b); } public int getEnergyStored(ForgeDirection fd) { return energy.getEnergyStored(); } public int getMaxEnergyStored(ForgeDirection fd) { return energy.getMaxEnergyStored(); } public ItemStack decrStackSize(int i, int j) { if(this.slots[i] != null){ ItemStack is; if(this.slots[i].stackSize <= j ){ is = this.slots[i]; this.slots[i] = null; return is; }else{ is = this.slots[i].splitStack(j); if(this.slots[i].stackSize == 0) { this.slots[i] = null; } return is; } }else{ return null; } } public boolean isItemValidForSlot(int i, ItemStack is) {return i!=2;} public boolean canInsertItem(int i, ItemStack is, int j) { return this.isItemValidForSlot(i, is); } public void setInventorySlotContents(int i, ItemStack is) { slots[i] = is; if (is != null && is.stackSize > this.getInventoryStackLimit()) { is.stackSize = this.getInventoryStackLimit(); } } public String getInventoryName(){return "container.processor";} public boolean hasCustomInventoryName(){return customName != null && customName.length() > 0;} public ItemStack getStackInSlotOnClosing(int i) { if (slots[i] != null) { ItemStack is = slots[i]; slots[i] = null; return is; }else{ return null; } } public boolean isUseableByPlayer(EntityPlayer p) { if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { return false; }else{ return p.getDistanceSq((double)xCoord+0.5D,(double)yCoord+0.5D,(double)zCoord+0.5D) <= 64; } } public ItemStack getStackInSlot(int i) { return slots[i]; } public int getSizeInventory() {return slots.length;} public void openInventory(){} public void closeInventory(){} }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.