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

OrangeVillager61

Members
  • Posts

    339
  • Joined

  • Last visited

Everything posted by OrangeVillager61

  1. Oh, that's how you debugged it? I debugged it by checking the boolean has_venom below: CompoundNBT nbtvenom = itemstack1.getOrCreateChildTag(MoDrops.modid + "has_bee_venom"); boolean has_venom = nbtvenom.getBoolean(MoDrops.modid + "has_bee_venom"); MoDrops.logger.debug(has_venom); I (clearly falsely) assumed that if it was there, it would pass that check. Since the tag is there how would I access the tag correctly?
  2. I'm currently working on figuring out how to make the itemhandler work. Also here's the repo: https://github.com/Orange1861/1.15.2-MoDrops/tree/1.15.2-MoDrops-Beta_Three
  3. Alright, so I started implementing the changes, but copying the itemstack still doesn't solve the problem of the tag not applying: (Still trying to figure out how to implement the itemhandler so that's not in yet) public void updateRepairOutput() { ItemStack itemstack = this.inputSlots.getStackInSlot(0); if (itemstack.isEmpty()) { this.outputSlot.setInventorySlotContents(0, ItemStack.EMPTY); } else { ItemStack itemstack1 = EnhancementContainer.this.inputSlots.getStackInSlot(0).copy(); ItemStack itemstack2 = EnhancementContainer.this.inputSlots.getStackInSlot(1); CompoundNBT nbtvenom = itemstack1.getOrCreateChildTag(MoDrops.modid + "has_bee_venom"); boolean has_venom = nbtvenom.getBoolean(MoDrops.modid + "has_bee_venom"); if (!itemstack2.isEmpty() && itemstack2.getCount() > 0 && !has_venom == true && itemstack2.getItem() == ItemList.bee_venom) { if(itemstack2.getCount() > 0 && itemstack2.getCount() < 4) { CompoundNBT nbt = itemstack1.getOrCreateTag(); nbt.putBoolean(MoDrops.modid + "has_bee_venom", true); nbt.putInt(MoDrops.modid + "bee_venom_strength", itemstack2.getCount()); itemstack1.setTag(nbt); EnhancementContainer.this.outputSlot.setInventorySlotContents(1, itemstack1); } else { CompoundNBT nbt = itemstack1.getOrCreateTag(); nbt.putBoolean(MoDrops.modid + "has_bee_venom", true); nbt.putInt(MoDrops.modid + "bee_venom_strength", 1); itemstack1.write(nbt); itemstack1.setTag(nbt); EnhancementContainer.this.outputSlot.setInventorySlotContents(1, itemstack1); } } } }
  4. I'll definitely prefix the NBT tags, but what exactly do you mean by handling the boolean tag with two separate items?
  5. Regarding the separate items and tags, I am trying to add data to items, in case, add bee venom to weapons so that they deal poison damage on hit (handled in an event). Should I use a capability instead of nbt tags and if so, how do I attach the capability to items in this container? Thanks for letting me know to get rid of write, switch IItemHandler, and clone the itemstack I'll definitely go do so.
  6. Hello! In my code, I am trying to add an nbt tag when an item is taken from my machine. Problem is that the item is not getting the tag, which I know due to how the machine doesn't accept items that have the tag set to a certain value. (Condensed code) public class EnhancementContainer extends Container{ public void updateRepairOutput() { ItemStack itemstack = this.inputSlots.getStackInSlot(0); if (itemstack.isEmpty()) { this.outputSlot.setInventorySlotContents(0, ItemStack.EMPTY); } else { ItemStack itemstack1 = EnhancementContainer.this.inputSlots.getStackInSlot(0); ItemStack itemstack2 = EnhancementContainer.this.inputSlots.getStackInSlot(1); CompoundNBT nbtvenom = itemstack1.getOrCreateChildTag("has_bee_venom"); boolean has_venom = nbtvenom.getBoolean("has_bee_venom"); if (!itemstack2.isEmpty() && itemstack2.getCount() > 0 && !has_venom == true && itemstack2.getItem() == ItemList.bee_venom) { if(itemstack2.getCount() > 0 && itemstack2.getCount() < 4) { CompoundNBT nbt = itemstack1.getOrCreateTag(); nbt.putBoolean("has_bee_venom", true); nbt.putInt("bee_venom_strength", itemstack2.getCount()); itemstack1.write(nbt); itemstack1.setTag(nbt); EnhancementContainer.this.outputSlot.setInventorySlotContents(1, itemstack1); } else { CompoundNBT nbt = itemstack1.getOrCreateTag(); nbt.putBoolean("has_bee_venom", true); nbt.putInt("bee_venom_strength", 1); itemstack1.write(nbt); itemstack1.setTag(nbt); EnhancementContainer.this.outputSlot.setInventorySlotContents(1, itemstack1); } } } } }
  7. Are you coding a mod yourself? If not, you should go post the full crash log (this is a tiny snippet) with this in the Support and Bug Reports chat.
  8. Well, I'm wondering what holds the function so I can implement it such as, something.something.rendertypelookup.
  9. This is pretty helpful for me too, but what uses the RenderTypeLookup method in FMLClientSetupEvent? I can't find the method using the event or the block.
  10. Yeah, I probably made a mistake somewhere, I did a clean reinstall and it fixed the problem. Thanks!
  11. It is already the latest version, do you mean that I should try a wipe and reinstall?
  12. Hello! I am starting to mod in 1.14.4 and I am having this issue: This is happening to about half of the source files and this makes it far harder to read and understand the files. Does anyone have any suggestions to try to fix this? Thanks so much!
  13. Eh, the modding community is still bouncing back from the 1.8 debacle so I'm not so sure on that.
  14. In 1.9, Mojang changed armor calculation to a different, more convoluted system. I was reading through the internet and I couldn't find anything about this new system in the modded world. So could someone explain how Forge handles the armor bars along with the toughness attribute or is it the same as the vanilla system?
  15. How do I add/modify trades for villagers? I have an entity that extends EntityVillager so I can override needed methods.
  16. I tried to do the same thing but the only way I could find to do it is to replace the MapGenVillage with my own. Would be great if someone had another solution.
  17. For some reason, when I open my GUI, it moves the items in the player's inventory to different places. I don't know why this happens and this did not happen with code from 1.11.2. Is there some change from 1.11.2 to 1.12 for this to be the case? public ContainerIvVillagerInfo(IvVillager villager, IInventory playerInv){ this.villager = villager; this.handler = this.villager.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); int xPos = 8; int yPos = 153; for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(playerInv, x + y * 9 + 9, xPos + x * 18, yPos + y * 18)); } } for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(playerInv, x, xPos + x * 18, yPos + 58)); } } @Override public boolean canInteractWith(EntityPlayer player) { return villager.getDistanceToEntity(player) < 8; } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) { ItemStack previous = ItemStack.EMPTY; Slot slot = (Slot) this.inventorySlots.get(fromSlot); if (slot != null && slot.getHasStack()) { ItemStack current = slot.getStack(); previous = current.copy(); if (fromSlot < this.handler.getSlots()) { // From the block breaker inventory to player's inventory if (!this.mergeItemStack(current, handler.getSlots(), handler.getSlots() + 36, true)) return ItemStack.EMPTY; } else { // From the player's inventory to block breaker's inventory if (!this.mergeItemStack(current, 0, handler.getSlots(), false)) return ItemStack.EMPTY; } if (current.getCount() == 0) //Use func_190916_E() instead of stackSize 1.11 only 1.11.2 use getCount() slot.putStack(ItemStack.EMPTY); //Use ItemStack.field_190927_a instead of (ItemStack)null for a blank item stack. In 1.11.2 use ItemStack.EMPTY else slot.onSlotChanged(); if (current.getCount() == previous.getCount()) slot.onTake(playerIn, current); } return previous; } }
  18. Forgot to post crash report: [22:25:54] [Server thread/INFO] [STDOUT]: [orangeVillager61.ImprovedVillagers.Entities.IvVillager:setAdditionalAItasks:806]: Villager will now harvest meat. [22:25:54] [Server thread/INFO]: Preparing spawn area: 53% [22:25:54] [Server thread/INFO] [STDOUT]: [orangeVillager61.ImprovedVillagers.Entities.AI.VillagerAIHarvestMeat:shouldExecute:46]: Should Execute started. [22:25:54] [Server thread/INFO] [STDOUT]: [orangeVillager61.ImprovedVillagers.Entities.AI.VillagerAIHarvestMeat:startExecuting:113]: Butcher task approved. [22:25:54] [Server thread/INFO] [STDOUT]: [orangeVillager61.ImprovedVillagers.Entities.AI.VillagerAIHarvestMeat:updateTask:149]: Butcher to animal. [22:25:54] [Server thread/ERROR]: Encountered an unexpected exception net.minecraft.util.ReportedException: Ticking entity at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:740) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) ~[IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:589) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_121] Caused by: java.lang.NullPointerException at net.minecraft.entity.Entity.getDistanceSqToEntity(Entity.java:1627) ~[Entity.class:?] at orangeVillager61.ImprovedVillagers.Entities.AI.VillagerAIHarvestMeat.updateTask(VillagerAIHarvestMeat.java:150) ~[VillagerAIHarvestMeat.class:?] at net.minecraft.entity.ai.EntityAITasks.onUpdateTasks(EntityAITasks.java:114) ~[EntityAITasks.class:?] at net.minecraft.entity.EntityLiving.updateEntityActionState(EntityLiving.java:843) ~[EntityLiving.class:?] at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2565) ~[EntityLivingBase.class:?] at net.minecraft.entity.EntityLiving.onLivingUpdate(EntityLiving.java:647) ~[EntityLiving.class:?] at net.minecraft.entity.EntityAgeable.onLivingUpdate(EntityAgeable.java:201) ~[EntityAgeable.class:?] at orangeVillager61.ImprovedVillagers.Entities.IvVillager.onLivingUpdate(IvVillager.java:619) ~[IvVillager.class:?] at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2381) ~[EntityLivingBase.class:?] at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:346) ~[EntityLiving.class:?] at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2141) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:872) ~[WorldServer.class:?] at net.minecraft.world.World.updateEntity(World.java:2101) ~[World.class:?] at net.minecraft.world.World.updateEntities(World.java:1912) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:644) ~[WorldServer.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:836) ~[MinecraftServer.class:?] ... 4 more
  19. Hmm, after further testing. MC tries to run the AI after a relog but it crashes on the attempt to do so: public class VillagerAIHarvestMeat extends EntityAIBase { private final IvVillager villagerObj; private EntityAnimal animal; int mateAgain; protected Random rand = new Random(); private World world; String animal_type; int delayCounter; public VillagerAIHarvestMeat(IvVillager villagerIn) { this.villagerObj = villagerIn; this.world = villagerIn.world; this.setMutexBits(1); } /** * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { System.out.println("Should Execute started."); if (this.villagerObj.getGrowingAge() != 0) { System.out.println("Isn't adult"); return false; } else if (this.villagerObj.wantsMoreFood() == false) { System.out.println("Doesn't want food"); return false; } else if (this.villagerObj.getProfession() != 4) { System.out.println("Is not a butcher"); return false; } else { EntityAnimal entity = (EntityAnimal) this.world.findNearestEntityWithinAABB(EntityAnimal.class, this.villagerObj.getEntityBoundingBox().expand(100.0D, 7.0D, 100.0D), this.villagerObj); if (entity == null) { System.out.println("Entity is null"); return false; } if (this.villagerObj.world.getWorldTime() - entity.getCapability(HarvestTimeProvider.CAPABILITY_HARVEST_ANIMAL_TIME, null).get_time() < 24000 && entity.getCapability(HarvestTimeProvider.CAPABILITY_HARVEST_ANIMAL_TIME, null).get_time() != 0) { System.out.println("Entity has been harvested"); return false; } if (entity.getGrowingAge() < 0) { System.out.println("Entity is not adult"); return false; } if (entity instanceof EntityCow) { this.animal_type = "Cow"; entity = this.animal; return true; } else if (entity instanceof EntityPig) { this.animal_type = "Pig"; entity = this.animal; return true; } else if (entity instanceof EntitySheep) { this.animal_type = "Sheep"; entity = this.animal; return true; } else if (entity instanceof EntityChicken) { this.animal_type = "Chicken"; entity = this.animal; return true; } else { System.out.println("Entity is not harvestable"); return false; } } } /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { System.out.println("Butcher task approved."); this.delayCounter = 0; } /** * Returns whether an in-progress EntityAIBase should continue executing */ public boolean continueExecuting() { if (!this.animal.isEntityAlive()) { return false; } else if (this.villagerObj.getNavigator().noPath()) { return false; } else { System.out.println("Butcher task allowed to continue."); return true; } } /** * Resets the task */ public void resetTask() { this.villagerObj.getNavigator().clearPathEntity(); this.delayCounter = 5; } /** * Updates the task */ public void updateTask() { System.out.println(this.animal); if (this.villagerObj.getDistanceSqToEntity(this.animal) > 2.25D) { if (--this.delayCounter <= 0) { this.delayCounter = 10; this.villagerObj.getNavigator().tryMoveToEntityLiving(this.animal, 0.53D); } } else { this.getMeat(); } } private void getMeat() { if (this.animal_type == "Cow") { this.animal.dropItem(Items.COOKED_BEEF, 1); } else if (this.animal_type == "Pig") { this.animal.dropItem(Items.COOKED_PORKCHOP, 1); } else if (this.animal_type == "Sheep") { this.animal.dropItem(Items.COOKED_MUTTON, 1); } else if (this.animal_type == "Chicken") { this.animal.dropItem(Items.COOKED_CHICKEN, 1); } System.out.println("Butcher got the meat."); this.villagerObj.setWorkTicks(200); this.animal.getCapability(HarvestTimeProvider.CAPABILITY_HARVEST_ANIMAL_TIME, null).setTime(this.animal.world.getWorldTime()); } }
  20. Hmm, actually it is getting called. Still not working though. To summarize my current issue, I can't figure out why my task is either not getting called (I may have fixed it) or the task stops before shouldExecute is called.
  21. Okay, it looks like the addTask isn't being called. I can't find the issue though. protected void setAdditionalAItasks() { if (!this.areAdditionalTasksSet) { this.areAdditionalTasksSet = true; if (this.isChild()) { this.tasks.addTask(8, new EntityAIPlay(this, 0.32D)); } else if (this.getProfessionForge() == PROFESSION_FARMER || this.getProfession() == 0) { this.tasks.addTask(5, new EntityAIHarvestFarmland(this, 0.6D)); } else if (this.getProfession() == 4 || this.getProfessionForge() == PROFESSION_BUTCHER) { this.tasks.addTask(5, new VillagerAIHarvestMeat(this)); System.out.println("Villager will now harvest meat."); } if (this.getHired()) { this.tasks.addTask(5, new VillagerFollowOwner(this, 0.9D, 6.0F, 1.5F)); } } } I know that the function is being called since the farming task is working fine.
  22. Even though it still doesn't do anything but crash the game.
×
×
  • Create New...

Important Information

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