So the code has been updated a bit, apparently it was just the onEntityItemUpdate method that was causing issues.
However, now (and before) I also noticed that when I use the /give command for the item, it gives me two. Is there a solution for this?
In my mod, I needed to create a custom EntityItem so I could detect when it would be destroyed.
However, when I press q to drop the item, it simply floats in place.
This is the class for the custom EntityItem: https://github.com/daPoseidonGuy/Poppets/blob/master/src/main/java/com/tenzinpelletier/poppets/entities/EntityVoodooItem.java
This is the class for the Item using it: https://github.com/daPoseidonGuy/Poppets/blob/master/src/main/java/com/tenzinpelletier/poppets/items/VoodooItem.java
Any help is greatly appreciated.
-- daPoseidonGuy
If I use this for fireEvent it seems to work:
@SubscribeEvent
public static void fireEvent(LivingHurtEvent event) {
boolean found=false;
if ((event.getEntity() instanceof EntityPlayer)&&(event.getSource()==DamageSource.ON_FIRE)) {
EntityPlayer player = (EntityPlayer) event.getEntity();
for(int i=0;i<player.inventory.getSizeInventory();i++) {
if(player.inventory.getStackInSlot(i).getItem() == ModItems.firePoppet) {
player.sendMessage(new TextComponentString("Hoorah!"));
player.inventory.getStackInSlot(i).damageItem(1, player);
found = true;
}
}
}
if (found==true) {
EntityPlayer player = (EntityPlayer) event.getEntity();
player.sendMessage(new TextComponentString("You have been saved from fire"));
player.extinguish();
event.setCanceled(true);
}
}
However I feel there must be a more elegant solution.
Source Code:
https://github.com/daPoseidonGuy/Poppets/tree/master/src/main
Problem:
In this file: https://github.com/daPoseidonGuy/Poppets/blob/master/src/main/java/com/tenzinpelletier/poppets/ForgeEventHandler.java
For fireEvent, the if statement seems to fail if the fire poppet is damaged at all, and I can't seem to figure out why. Am I doing the ItemStack wrong? The function executes fine, and damages the item, but once it is damaged it no longer works.
Any help is appreciated
Wait so no blockstate files are supposed to have capital letters? how come all my other blocks render fine, then?
And isn't the blockstate file name supposed to be identical to the registry and unlocalized names?
I havent changed the blockstate file name and it was working fine before i added the variants.
So I've changed these things, but am still having trouble.
I don't know if I've made other mistakes along the way or something, but it seems the entire blockstate file isn't working, since it doesn't seem to have the particle texture either.
How is it invalid? I'd check myself but my computer broke yesterday (motherboard died).
Thanks for all the comments though, I wouldn't catch a lot of those things by myself.
PencilBlock renders as a pink and black cube,
The console gives an error for literally every block state (facing=up,down, east,west etc.)
However, I'm pretty sure I got everything right in the class itself, and I thought i had stuff right in the json file (now I removed some)
Hi!
I tried adding different blockstates to my block.
However, despite doing my best to follow what I saw in the forge docs and whatnot, I can't seem to set textures for these models. Right now I've rolled back a bit of what I did, but here's my code: https://github.com/daPoseidonGuy/PencilMod
Any help would be greatly appreciated,
Thanks.
Fixed it now. I was using EnumActionResult.SUCCESS instead of EnumActionResult.PASS.
I also added the swingingArm animation since EnumActionResult.PASS wouldn't add it.
I'm guessing EnumActionResult.PASS passes it on to the vanilla code to register stuff serverside instead of just clientside.
Yes, when placed normally, the block stays. Only when placed via the itemPencil Item does it disappear on logout.
Something in the way itemPencil creates the block makes it disappear on logout and impervious to any block updates.
Edit: Updated github: https://github.com/daPoseidonGuy/PencilMod
New update: I realized that upon logging out, my block disappears from the world. This probably has to do with the way my itemPencil places it.
When giving myself the BlockItem via /give and placing it down, it recieves block updates.
So this has something to do with using world.setBlockState() to place my block i guess.