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


  • Posts

  • Joined

  • Last visited

Everything posted by Meldexun

  1. I have a block with a tileentity and a gui that opens when the block is right clicked. When the tileentity is loaded on client side it sends a packet to the server which requests that the data from the server tileentity is send with a packet to the client. And then when pressing DONE in the gui it sends a packet with the data from the gui to the server. That seemed to be the most efficient way.
  2. That's why i asked for help. And i will look at scheduled tasks. Thanks. Isn't that what i'm doing in my latest post? When the packet is received client side (what i check with ctx#side#isClient()) then i use my proxy and when recieved on server side i directly access the world.
  3. So now i got this: And now it's working. When received on a client side it now uses @SidedProxy because using Minecraft#getMinecraft()#world directly would obviously crash the server. And when received on a server side i doesn't use @SidedProxy because in singleplayer it would give me the the world of the client and not of the logical server. Maybe there is a better solution?
  4. The problem is that i want to send a packet from the client to the server and then when the packet is received on the server in need the world of the server. But when i send the packet in singleplayer it always picks the world of the client and not of the server when using SidedProxy. It seems logical but doesn't achieve what i want. My MessageHandler: My ClientProxy: My ServerProxy: This should work with a dedicated server and a dedicated client. But in singleplayer it always gives the world of the client side and not of the logical server side.
  5. I also tried to work with the proxy: World world = CrystalicVoid.proxy.getWorld(message, ctx); But then in singleplayer it uses the ClientProxy.
  6. So i want to send a packet from the server the the client and when receiving the message i need the client world. But when starting a server the server crashes because the Minecraft class does not exist on the server. But the message should just be received on the client side. Now i don't really know how to solve the problem. MessageHandler: public class CPacketSyncEntitySpawnerHandler implements IMessageHandler<PacketSyncEntitySpawner, IMessage> { @Override public IMessage onMessage(PacketSyncEntitySpawner message, MessageContext ctx) { World world = Minecraft.getMinecraft().world; TileEntity tileEntity = world.getTileEntity(new BlockPos(message.getX(), message.getY(), message.getZ())); if (tileEntity instanceof TileEntityEntitySpawner) { TileEntityEntitySpawner t = (TileEntityEntitySpawner) tileEntity; t.setEntityID(message.getEntityID()); } return null; } } And that is how i registered my Message: CrystalicVoid.CONNECTION.registerMessage(CPacketSyncEntitySpawnerHandler.class, PacketSyncEntitySpawner.class, 0, Side.CLIENT);
  7. I tried to save an Entity as NBTTagCompound and then create a new Entity from that NBTTagCompound when hitting an Entity with my item. This is what i have: @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { if (!player.world.isRemote ) { NBTTagCompound ttt = entity.writeToNBT(new NBTTagCompound()); Entity eee = EntityList.createEntityFromNBT(ttt, player.world); if (eee != null) { eee.setPosition(player.posX, player.posX, player.posX); player.world.spawnEntity(eee); } } return true; } But i just get this: [minecraft/EntityList]: Skipping Entity with id minecraft:
  8. I would just use DamageSource#getImmediateSource(). Because otherwise when you shot an arrow with your bow and swap to the item that increases the drop chance. You would get the increased drop chance without using the item.
  9. I changed the keys and now it's working.
  10. I created a TileEntity but after leaving the world and rejoining no data is saved. That's the class: private String entityID = ""; private String helmetID = ""; private String chestplateID = ""; private String leggingsID = ""; private String bootsID = ""; private String weaponID = ""; @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setString("id", entityID); compound.setString("helm", helmetID); compound.setString("chest", chestplateID); compound.setString("legs", leggingsID); compound.setString("feet", bootsID); compound.setString("weapon", weaponID); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.entityID = compound.getString("id"); this.helmetID = compound.getString("helm"); this.chestplateID = compound.getString("chest"); this.leggingsID = compound.getString("legs"); this.bootsID = compound.getString("feet"); this.weaponID = compound.getString("weapon"); } @Override public void onLoad() { System.out.println(this.entityID); } When the tile entity is loaded it should print the saved entityID but it always prints an empty string. What am i missing?
  11. Ok let's just stick with the second option. I want to type a entity name (for example minecraft:zombie) in a gui and when i close it a packet should be sent to the server with the x, y, z coordinates and the entity name. But i don't know how to save a String in the toBytes method and how to load it in the fromBytes method. Currently i have this: @Override public void fromBytes(ByteBuf buf) { this.x = buf.readInt(); this.y = buf.readInt(); this.z = buf.readInt(); this.entityID = buf.toString(); } @Override public void toBytes(ByteBuf buf) { buf.writeInt(x); buf.writeInt(y); buf.writeInt(z); buf.writeBytes(entityID.getBytes()); } But this seems to be that i just don't understand java correctly. I will also look somewhere else how to read/write Strings in a ByteBuf. But you can still help me if you want.
  12. Hi there, i want to spawn an entity from the given id. The only way i found is EntityList#createEntityByID but this method is client side only and so will crash on server. How can i spawn an entity from an id on server side? Edit: Or you can help me how i can send a String from the client to server. I tried creating a packet which implements IMessage but i can't seem to be able to save a String there.
  13. Hi there, I'm searching for a method of TileEntities which is called every tick. Something like a onTick method or something similar. But I can't find it. Can someone tell me what the method name is? Thank you in advance.
  14. I don't know that much about programming and so i don't know how Minecraft is coded. But i heard that it's bad coded. I atleast try to make my mods as good as possible. Hoped Forge at least tries to do the same.
  15. Yes it's doing the same thing but the method attackEntityFrom is called twice and also the LivingAttackEvent. It's working but it's a bit redundant code.
  16. I would like to make a sword with a custom damage source. It's the only way i found to achieve this.
  17. I would like to be able to modify the damage source in the LivingAttackEvent. Because now i have to cancel the event and call attackEntityFrom with the new damage source.
  18. Does anyone know how to change the overall brightness? I want that to change it similar to the night vision potion. But just applying the night vision effect is no a solution, because i want that the game is brighter and darker and just a bit not just the fixed brighter of night vision. It may also help if you just tell me how the night vision potion affects the brightness. Thanks for any help.
  19. So instead of setting the density with the event i now use GL11.glFogf(GL11.GL_FOG_DENSITY, 0.025f + 0.0025f * blocksUnderWater(event.getEntity())); If i'm missing something please tell me.
  • Create New...

Important Information

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