Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

tommyte

Members
  • Posts

    30
  • Joined

  • Last visited

tommyte's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. You are, like the error report is saying, referencing a field that doesn't exist in your this class : at mcjty.theoneprobe.network.PacketGetInfo$Handler.handle(PacketGetInfo.java:110) ~[PacketGetInfo$Handler.class:?] Maybe you can solve it yourself now. Otherwise I'll need to see that class to help you further (:
  2. You could, of course, just check if the returned itemstack is empty or not, and then check if it is a glass bottle. I'm not exactly sure what it is you want to do here though. So maybe you could give us a little more information about that (:
  3. player.getEntityWorld(); (or something like that) you can use this: PacketDispatcher.sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range)); Just set the range to a value that would make sure no one outside it can hover over the block.
  4. You can get the singleplayer player by calling Minecraft.getMinecraft().player.
  5. I usually do it like this: data.setIntArray("ints", new int[]{pos.getX(), pos.getY(), pos.getZ(), amount}); Here I set an array of integers with the three coords of the tile entity and the number i'd like to transfer. int[] values = message.data.getIntArray("ints"); final String name = message.data.getString("string"); final BlockPos pos = new BlockPos(values[0], values[1], values[2]); final int amount = values[3]; Then in the messagehandler I read these values like this. TileEntity entity = theplayer.getEntityWorld().getTileEntity(pos); if(entity != null && entity.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) { //here do something like entity.getCapability(etc., etc.).setEnergy(amount); } You'd put something like this into your run method.
  6. There you go This method, as the name implies detects and sends changes (on server side) and sends them to the client. This then only occurs when the container is activated, aka when the player open the gui. You should set up your own networking to sync properly between server and client. Here is an article about in on the docs: https://mcforge.readthedocs.io/en/latest/networking/ Read all the articles there about networking and then you should be good to go
  7. I can't find any networking here. I'd really like to see where you are syncing up your client side with your server side. You are, logically, only changing the amount of energy stored on server side, so the client side, what waila is displaying (I think), doesn't know of any changes in the amount of energy stored until you send a packet there
  8. If I were to guess I'd say it's a syncing issue. Are you by chance syncing up your server and client tileentity the moment you open the gui / right click the block? In any case I would like to see the block and tileentity classes (:
  9. This is an example with the energy capability: public NBTBase serializeNBT() { NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("energy", energy.getEnergyStored()); return nbt; } public void deserializeNBT(NBTBase nbt) { if(((NBTTagCompound) nbt).hasKey("energy")) { energy.setEnergy(((NBTTagCompound) nbt).getInteger("energy")); } } Notice that you can only store the info from the capability here. So in your case you'd save the items in the inventory of your item here. If, however, you want to store more info on the nbt of the itemstack, you should use ItemStack::getTagCompound() to retrieve and alter the nbt tag compound of your item. Call this where ever you find it useful. Maybe you want to update the nbt every tick? Then call it in the update method. If you want to update it every time the item is right-clicked? Use the onItemRightClick method.
  10. capacidaddealmacenamiento xt = (capacidaddealmacenamiento) itemstack.getCapability(capacidaddealmacenamiento, EnumFacing.UP); should be: capacidaddealmacenamiento xt = (capacidaddealmacenamiento) itemstack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP); Furthermore, you'd need a capabilityprovider for this item: public static class ExampleProvider implements ICapabilityProvider, ICapabilitySerializable { @Override public NBTBase serializeNBT() { //Retrieve data here return null; } @Override public void deserializeNBT(NBTBase nbt) { //Do your saving here } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return true; } return false; } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) new ItemStackHandler(2/**the amount of slots you want*/); //This is the default implementation by forge, but you'll likely want to make your own by overriding. } return null; } } Serialize and deserialize nbt will be called for you when the world respectively starts or closes. You can save your stored items here using the ItemStackHelper class. I don't quite get the purpose of this either: playerIn.setActiveHand(handIn); But, if you'd try explaining us a little more what exactly it is you want to achieve, I'm sure we could help you out a little better (:
  11. False alarm, I figured it out already. My 'getCoreEntity()' method didn't work properly. I wonder why it didn't spit out an error, but o well. Thanks anyways!
  12. Hello everyone, I'm working on a multiblock structure with a core tile entity that should store all the data, like items. I got another tile entity in the multiblock that should be able to in- and output items to and from the inventory of that core tile entity. I tried to achieve this by returning the instance of the ItemStackHandler of the core tile entity in the getCapability method in the other tile entity. It looks like this: //The class that should in and output to the core tile entity public class TileEntityMultiblockItemHandler extends TileEntity implements IMultiblockTileEntity{ private TSMultiblock block; public TileEntityMultiblockItemHandler() { } @Override public TSMultiblock getMultiblock() { return ((IMultiblockBlock)world.getBlockState(pos).getBlock()).getMultiblock(world, pos); } @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) getMultiblock().getCoreEntity().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing); } return super.getCapability(capability, facing); } @Override public void onMultiblockLoad() { } } And //The core tile entity public class TileEntityFabricator extends TileEntityMachineBasic implements ITickable, IInteractionObject, ITileEntityInterface{ private int currentFormTime; private int totalFormTime; private int energyConsumption; private TSEnergyStorage energy; private TSItemStorage inventory; public TileEntityFabricator() { totalFormTime = TSConfigHandler.runtimeFabricator; currentFormTime = 0; energyConsumption = TSConfigHandler.fabricatorConsumption; energy = new TSEnergyStorage(10000, 0, 0); inventory = new TSItemStorage(10); } //I left a bunch of methods out here @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if (capability == CapabilityEnergy.ENERGY) { return true; } 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 == CapabilityEnergy.ENERGY) { return (T) energy; } if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) inventory; } return super.getCapability(capability, facing); } } The problem: when I attach a hopper to the itemhandler tile entity, it inputs items, but I can't see them on the gui. Furthermore, I can get the items I put in out again with a hopper, but the items inside that I can see and access through the gui stay put. What have I done wrong?
  13. private void setMultiblockAndRotate() { Hashtable<BlockPos, Block> blocks = new Hashtable<BlockPos, Block>(); Hashtable<BlockPos, TileEntity> entities = new Hashtable<BlockPos, TileEntity>(); int offset = getFacingOffset(facing); for(int x = bx; x <= ex; x++) { for(int y = by; y <= ey; y++) { for(int z = bz; z <= ez; z++) { BlockPos oldpos = new BlockPos(x,y,z); //this puts the blockpos in a 2d vector and rotates it, so it will face correctly Vector2d vec = new Vector2d(oldpos.getX(), oldpos.getZ()); vec = Util.getNormalVector(vec, offset); BlockPos newpos = new BlockPos(vec.x, oldpos.getY(), vec.y); if(newpos.equals(BlockPos.ORIGIN)) { blocks.put(newpos, BlockRegistry.basicmachine); } else //'blocks' is a hashtable simelar to blocks in this method. But, that table already has values that I set earlier. if(this.blocks.containsKey(oldpos)) { blocks.put(newpos, this.blocks.get(oldpos)); } else { blocks.put(newpos, fillerBlock); //fillerBlock is a block that I also defined earlier. Its just there so that I dont have to put those blocks at a position. This code just assumes that everything that isnt defined should be this block } if(this.tileentities.containsKey(oldpos)) { entities.put(newpos, this.tileentities.get(oldpos)); } } } } frame = blocks; tileentities = entities; } This is how I've done it. It works by indexing blocks by their relative blockpositions (relative to the controller). Later you'd check if all the blocks defined in 'frame' are actually in the world, and if so, it'll form the multiblock. This way you could also add new tileEntities to handle things like in- and outputting liquids.
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.