Jump to content

shieldbug1

Forge Modder
  • Posts

    404
  • Joined

  • Last visited

Everything posted by shieldbug1

  1. Your burning and burntime should not be static. This is basic Java - the reason it's affecting all of your fires is because they all share the same class field for burning and burnTime. And to check if something is burning you wouldn't have static methods (unless they're just convenience methods). So to check if it's burning would become TileEntityCampFire tileEntity = (TileEntityCampFire) world.getTileEntity(x, y, z); if(tileEntity.isBurning()) { ... } [/code
  2. Like you said, I think the best thing would be to have a simple 'initialised' boolean field, and just do it in the first updateEntity call.
  3. MinecraftForge isn't a mod though, it just has a dummy mod container. I don't think you can load before it.
  4. You don't actually have to downgrade. This issue has been fixed for at least a month - you just have to update to the latest forge version.
  5. Your implementation of IMessage.
  6. 1. Create two classes, a ClientProxy and a CommonProxy. ClientProxy must extend CommonProxy. You can additionaly create a ServerProxy to also extend CommonProxy. 2. In your main mod file: @SidedProxy(cilentSide = "com.somepackage.ClientProxyClassName", serverSide = "com.somepackage.ServerProxyClassName"); //Fully qualified name of your proxies. public static CommonProxy proxy; 3. Create a method in your CommonProxy that does nothing and takes in your IMessage implementation as a parameter and does nothing. 4. In your IMessageHandlerClass in the onMessage method: MainClass.proxy.yourMethodHere(message); 5. In your client proxy: @Override public void someMethod(YourPacket packet) { Entity entity = FMLClientHandler.instance().getWorldClient().getEntityById(packet.entityID); //Spawn particles here using entity.worldObj and entity.posX, posY and posZ. } Now as for sending the packet, rather than using the actual SimpleNetworkWrapper, what you do is this, in your event handler method if(!event.entityLiving.worldObj.isRemote) //Server! { YourPacket packet = new YourPacket(event.entityLiving.getEntityId()); ((WorldServer)event.entityLiving.worldObj).getEntityTracker().func_151247_a(event.entityLiving, packet); }
  7. Override getSubBlocks or getSubItems (can't remember what it's called) and add the ItemStacks you want to the List parameter you're given.
  8. I don think the launch wrapper automatically applies the source, but you can easily add it to the build path. It's where the launch wrapper itself is saved on your computer.
  9. What you want to do is: 1. Check your conditions on the server in the event. 2. If conditions are right, create a packet containing the entityLiving's entity id, and send it to any clients tracking it. There is a method for that in WorldServer, but I can't remember what it's called of the top of my head. 3. Through your proxy, handle the packet on the client proxy, by getting the entity through World#getEntityById(), and spawn the particles using the entity's posX, posY, and posZ values.
  10. That is a client only method, you have to call it through a proxy.
  11. Alright, I've managed to do it, but it sure feels like a hack around something that could be done more elegantly. @SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { if(event.gui instanceof GuiModList) { ModContainer container = Loader.instance().getIndexedModList().get(UtilModDummy.MOD_ID); ((List<ModContainer>)ReflectionHelper.getPrivateValue(GuiModList.class, (GuiModList)event.gui, "mods")).remove(container); } }
  12. If the LivingHurtEvent is server only, like coolAlias says, then do your checks as usual (on the server), then if you meet the conditions you want, you will have to send packets. Then on the Client, when the packet is received, create your particles.
  13. That should be fine. Is the method being called at all? Put some SOUT statements in the beginning of the method.
  14. Your for-loop should increase to 5, since you want all 4 armour slots. Did you register your event handler?
  15. Update Forge. The latest version of forge is 1225. All version can be found here.
  16. If you use MinecraftServer.getServer().worldServers[0] then it'll always be the overworld, regardless of what dimension you're in. So if you took damage in the Nether, it would try spawn the particles on the overworld - this would cause unexpected behaviour and most likely crashes. In this case, Minecraft.getMinecraft().theWorld is perfectly viable, because particles are only on the client - but every entity has a World object associated with it (Entity#worldObj) - so you don't even need to use Minecraft#theWorld, you can just use LivingHurtEvent#entityLiving.worldObj
  17. I'm not sure about your first question but I know I do this to make sure to prevent unlocalised name clashes: public static void nameItem(Item item, String name) { item.setUnlocalizedName(Reference.MOD_ID + "." + name); item.setTextureName(Reference.MOD_ID + ":" + name); } Same things for blocks too. So instead of item.something.name it's item.modid.something.name, and then I never have to worry about it. Now, for your next question I haven't tried it, but I'd assume you can do: if(GameData.getItemRegistry().contains(unlocalisedName)) { Item item = GameData.getItemRegistry().getObject(unlocalisedName); ItemStack stack = item != null ? new ItemStack(item) : null; String displayName = stack != null ? stack.getDisplayName() : ""; }
  18. Why are you using the MinecraftServer? This is certain to crash on a client! Also why are you checking if it's an instance of EntityLivingBase - it has to be, you're given one! You want something like this: @SubscribeEvent public void onHurt(LivingHurtEvent event) { if(event.entityLiving.worldObj.isRemote) //Client only! { for(int i = 1; i<=4; i++) { ItemStack stack = event.entityLiving.getEquipmentInSlot(i); Item item = stack != null ? stack.getItem() : null; if(item instanceof HELMET || item instanceof BODY || item instanceof LEGGINGS || item instanceof BOOTS) { event.entityLiving.worldObj.spawnParticle(...); } } } }
  19. Update forge to the latest version. Next time, please read the EAQ before posting - there is a very high chance that your problem already has a solution.
  20. You need to create a class to handle the event, and in it you need a method like this: @SubscribeEvent public void anyMethodName(EventTypeYouWant event) { } Then you find out which EventBus the event is posted on, in this case, it's the MinecraftForge event bus - so you register to it like this: MinecraftForge.EVENT_BUS.register(INSTANCE_OF_YOUR_HANDLER_CLASS);
  21. Use the LivingHurtEvent, if the entityLiving is wearing your armour, spawn the particles. Just remember to only spawn the particles on the client.
  22. Not really. I'm pretty sure you'd have to make your own custom implementation of 'ItemStack' and your own custom Container/Inventory.
  23. Check if your itemstack#getItem is returning null first.
  24. I think this has something to do with Items being available and being loaded, etc. I'm assuming the NPE is caused through the getItem method in ItemStack which is used to get the items damage value. Try placing the code in a later loading stage and see if that helps.
  25. Post your preInit method.
×
×
  • Create New...

Important Information

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