
ashjack
Members-
Posts
102 -
Joined
-
Last visited
Everything posted by ashjack
-
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; }
-
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.
-
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.
-
[1.7.10] Problem with Built Mod NoDefClassFoundError
ashjack replied to grand_mind1's topic in Modder Support
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. -
[1.7.10] How do I load an external texture onto an Entity?
ashjack replied to ashjack's topic in Modder Support
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. -
[1.7.10] How do I load an external texture onto an Entity?
ashjack replied to ashjack's topic in Modder Support
Oh, I reflected the wrong field. I reflected Minecraft.class' instance of DefaultResourcePack -
[1.7.10] How do I load an external texture onto an Entity?
ashjack replied to ashjack's topic in Modder Support
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. -
How do I get the EntityPlayer on the Server Side?
ashjack replied to ashjack's topic in Modder Support
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 -
How do I get the EntityPlayer on the Server Side?
ashjack replied to ashjack's topic in Modder Support
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. -
[1.7.10] How do I load an external texture onto an Entity?
ashjack replied to ashjack's topic in Modder Support
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. -
How do I get the EntityPlayer on the Server Side?
ashjack replied to ashjack's topic in Modder Support
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) -
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)?
-
How do I get the EntityPlayer on the Server Side?
ashjack replied to ashjack's topic in Modder Support
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. -
How do I get the EntityPlayer on the Server Side?
ashjack replied to ashjack's topic in Modder Support
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. -
How do I get the EntityPlayer on the Server Side?
ashjack replied to ashjack's topic in Modder Support
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. -
How do I get the EntityPlayer on the Server Side?
ashjack replied to ashjack's topic in Modder Support
To find a random location in the world that is close to the player. -
It does belong. It closes the add recipe function.
-
How do I get the EntityPlayer on the Server Side?
ashjack replied to ashjack's topic in Modder Support
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? -
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?