Jump to content

ashjack

Members
  • Posts

    102
  • Joined

  • Last visited

Everything posted by ashjack

  1. I am trying to create an itemstack in order to get the localised name of an item, but for some reason creating the itemstack causes the game to crash with "java.lang.ClassCastException: net.minecraft.item.ItemStack cannot be cast to net.minecraft.item.Item" I do not understand why this is happening because I am simply creating a new itemstack and using an item with it. I am using the following code: public static List<Item> itemList = new ArrayList<Item>(); public static void learnItems() { itemList.clear(); Iterator iterator = Item.itemRegistry.iterator(); while (iterator.hasNext()) { Item item = (Item)iterator.next(); if (item != null) { item.getSubItems(item, (CreativeTabs)null, itemList); } itemList.add(item); ModLog.log.info("Added " + new ItemStack(item).getDisplayName()); } } public static Item getItemFromMsg(String msg) { for(int i = 0; i < itemList.size(); i++) { if(itemList.get(i) != null) { ItemStack is = new ItemStack(itemList.get(i)); // I tried new ItemStack(itemList.get(i), 1); with same results if(msg.contains(is.getDisplayName())) { return itemList.get(i); } } else { ModLog.log.info("Item is null"); } } return null; }
  2. I have made an event handling class, and have registered it using the following: public class EventManager { @EventHandler public void load(FMLInitializationEvent event) { FMLCommonHandler.instance().bus().register(new EventManager()); } @SubscribeEvent public void onEntitySpawn(EntityJoinWorldEvent event) { MineAILog.log.info("Entity Has Spawned"); if (event.entity instanceof EntityMob) { MineAILog.log.info("Entity is a mob"); assignAI((EntityMob) event.entity, event); } } private void assignAI(EntityMob e, Event ev) { e.tasks.addTask(4, new EntityAIAttackOnCollide(e, EntityAI.class, 1.0D, false)); e.targetTasks.addTask(4, new EntityAINearestAttackableTarget(e, EntityAI.class, 0, true)); } } And yet the event does not fire at all, and the log functions do not run. I have also tried registering the EventManager class in the main mod class, but this has not worked either. I honestly do not know why it is not firing.
  3. Adding the resource pack is once again working thanks to the functions you told me to use, however, I still can't get the texture. I have triple checked every file name, and they match up perfectly.
  4. Here is the source code: https://github.com/ashjack/Sim-U-Kraft-Reloaded-2
  5. Just one thing, I am reflecting and adding to the list in the preinit function. Should I be doing this in a later function?
  6. I did have some uppercase directory names, however, upon correcting them to lowercase the problem still persisted. I have just tried the method (refreshResources()) and the texture is still not found. I am sure that I have spelt the directory and file names correctly
  7. Thanks for your reply. However, I still get a missing texture. I am returning a skin for an entity: return new ResourceLocation("SUK2", "Races/Elf/female3.png"); The whole path is: assets/SUK2/Races/Elf/female3.png
  8. I have successfully reflected the list that Minecraft uses to store resource packs, and I have added a new one programmatically, which adds some external textures to Minecraft. The problem I have, is that after successfully adding this resource pack, it turns out the resource domain is blank. The resource domain is the first string that is required in making an instance of ResourceLocation (new ResourceLocation("ResourceDomain", "Path")). How can I set the resource domain of this resource pack? If you're wandering, the resource pack is an instance of FileResourcePack.
  9. You are not supposed to put other people's API classes on GitHub, therefore he didn't upload it. His crash doesn't refer to IEnergyReceiver. Do what Abastro said and run 'gradlew build'. Once it has built, navigate to the 'build/libs' folder. Here you will find a jar file with your modid in. This is the file that people put into their mods folder.
  10. How do I reflect a list? I googled it, and all the questions are about reflecting the TYPE of list it is, not the actual list field itself.
  11. Oh, I reflected the wrong field. I reflected Minecraft.class' instance of DefaultResourcePack
  12. Ok, so I have successfully reflected mcDefaultResourcePack and have access to it, but I see no way of adding files to it without overwriting the existing ones.
  13. Spawning the NPC near the player is purely for aesthetic purposes. The player is unlikely to travel a far distance from where the NPC spawned, so when the NPC is called by the block, he/she walks out of the woods instead of teleporting. This problem has been solved now
  14. It doesn't actually go to the player, it goes to a block that the player must have interacted with for the entity to need to go there in the first place. If it is too far away, the entity 'warps' with a particle effect. The only reason it needs to spawn near a player is for aesthetic purposes, so any player will suffice.
  15. Call me a noob and what have you, but how could I do this? I have a class that implements IResource, but I see no direct link to the Default Resource Pack class other than the fact that that class also implements IResource.
  16. It needs to spawn within a few chunks of a player so that it can easily make it's way to the player when it needs to (It is an NPC)
  17. I know I have been asking a lot today, but I have quite a few problems. How do I give an entity a texture that was loaded from an external source (A folder in the mods folder)?
  18. I have just realised, I don't need to get the specific player on the server side. I only need to get a random player on the server side, because on multiplayer, I am still only spawning one entity, so it doesn't matter who it spawns near. Thank you everyone for your help.
  19. There are two ways this entity will spawn: By a server command, which I have working as the server command contains information about the player who performed the command And it will spawn on it's own if there is less than a specified amount of this entity. This is where my problem comes in, as I need to get the player manually for this.
  20. When spawning an Entity. This is why I need it on the server side. I even tested using the client side player to see what problems it would cause, but it is null on the server side.
  21. To find a random location in the world that is close to the player.
  22. It does belong. It closes the add recipe function.
  23. I didn't mean instance, I meant I needed to create an instance of it. How do I get the current player from world.playerEntities? Is it the first one in the list?
  24. I know that I can easily get the player using Minecraft.getMinecraft().thePlayer, however, this obviously isn't going to work in multiplayer. How do I get the player instance from the server side?
×
×
  • Create New...

Important Information

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