Jump to content

Squirtle8459

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by Squirtle8459

  1. EnumFacing.getDirectionFromEntityLiving(blockPos, player).getOpposite(); <- this seems to do what I want.. Solution found.. thanks for the help!
  2. I've been trying to figure out how to return the EnumFacing Direction of the side the player is looking at.. whilst mining it.. The image posted is the general idea of what I am trying to say..
  3. I've tried doing some things only to mess up the code.. it seems no matter how I approach this it doesnt wish to sync properly..
  4. [09:20:49] [Server thread/INFO] [STDOUT]: [squirtle8459.passivepowerproduction.tileentity.TileEntityMatterInterpreter:writeToNBT:72]: [WRITE] ITEMS: {Size:1,Items:[{Slot:0,id:"minecraft:nether_star",Count:1b,Damage:0s}]} [09:20:49] [main/INFO] [STDOUT]: [squirtle8459.passivepowerproduction.tileentity.TileEntityMatterInterpreter:readFromNBT:81]: [READ] ITEMS: {Size:1,Items:[{Slot:0,id:"minecraft:nether_star",Count:1b,Damage:0s}]} When I reload the world.. The ReadFromNBT returns [09:22:00] [Server thread/INFO] [STDOUT]: [squirtle8459.passivepowerproduction.tileentity.TileEntityMatterInterpreter:readFromNBT:81]: [READ] ITEMS: {}
  5. For some odd reason, my TileEntity is not saving the item it stores when I reload my world, what am I doing wrong? TileEntity: package squirtle8459.passivepowerproduction.tileentity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; import squirtle8459.passivepowerproduction.handler.powerGenHandler; public class TileEntityMatterInterpreter extends TileEntityEnergyBase implements ITickable { public TileEntityMatterInterpreter() { } public TileEntityMatterInterpreter(int capacity, int maxReceive, int maxExtract) { super(capacity, maxReceive, maxExtract); } public static final int SIZE = 1; public ItemStackHandler itemStackHandler = new ItemStackHandler(SIZE) { @Override protected void onContentsChanged(int slot) { sendUpdates(); } }; private void sendUpdates() { world.markBlockRangeForRenderUpdate(pos, pos); world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 3); world.scheduleBlockUpdate(pos,this.getBlockType(), 0, 0); TileEntityMatterInterpreter.this.markDirty(); } @Override public SPacketUpdateTileEntity getUpdatePacket() { BlockPos blockPos=getPos();; return new SPacketUpdateTileEntity(blockPos, 3, getUpdateTag()); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { NBTTagCompound nbtTagCompound=pkt.getNbtCompound(); super.readFromNBT(nbtTagCompound); readFromNBT(nbtTagCompound); } @Override public NBTTagCompound getUpdateTag() { NBTTagCompound supertag=super.getUpdateTag(); writeToNBT(supertag); return supertag; } @Override public void handleUpdateTag(NBTTagCompound tag) { super.handleUpdateTag(tag); readFromNBT(tag); } @Override public NBTTagCompound writeToNBT(NBTTagCompound tag) { if(tag == null) tag = new NBTTagCompound(); tag.setTag("Items", itemStackHandler.serializeNBT()); return tag; } @Override public void readFromNBT(NBTTagCompound tag) { itemStackHandler.deserializeNBT(tag.getCompoundTag("Items")); if(tag.hasKey("energy")) this.energy = tag.getInteger("energy"); } public boolean canInteractWith(EntityPlayer playerIn) { return !isInvalid() && playerIn.getDistanceSq(pos.add(0.5D, 0.5D, 0.5D)) <= 64D; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return true; } return super.hasCapability(capability, facing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) itemStackHandler; } return super.getCapability(capability, facing); } public void update() { if(this.world == null) return; ItemStack stack = itemStackHandler.getStackInSlot(0); int RF = powerGenHandler.getRFBase(stack); powerGenHandler.sendPower(world, pos, energy, capacity, RF); } } There's probably a bunch of redundant code in there somewhere
×
×
  • Create New...

Important Information

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