Jump to content

Triphion

Members
  • Posts

    122
  • Joined

  • Last visited

Everything posted by Triphion

  1. Worked for me. A massive thanks to everyone who helped me! :D
  2. I do have a logger function, but only one that gets called preinit. If i want the logger function to get called, this way of doing it does work when im on singleplayer, however in server window, the log function never gets mentioned? @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if (!worldIn.isRemote) { EntityLivingBase player = ((EntityLivingBase)playerIn); RayTraceResult pos = player.rayTrace(22.0D, 20.0F); double x = pos.getBlockPos().getX(); double y = pos.getBlockPos().getY() + 1.0D; double z = pos.getBlockPos().getZ(); Utils.getLogger().info("Raytrace: " + pos.toString().substring(5)); if (player.attemptTeleport(x, y, z)) { player.getHeldItem(handIn).damageItem(1, playerIn); } } else{ return new ActionResult(EnumActionResult.PASS, playerIn.getHeldItem(handIn)); } return new ActionResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); }
  3. Found it. java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: net.minecraft.entity.EntityLivingBase.rayTrace(DF)Lnet/minecraft/util/math/RayTraceResult; at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_151] at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_151] at net.minecraft.util.Util.runTask(Util.java:30) [Util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:754) [MinecraftServer.class:?] at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:402) [DedicatedServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:699) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:548) [MinecraftServer.class:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151] Caused by: java.lang.NoSuchMethodError: net.minecraft.entity.EntityLivingBase.rayTrace(DF)Lnet/minecraft/util/math/RayTraceResult; at com.triphion.ancient.items.ItemTheCosmician.onItemRightClick(ItemTheCosmician.java:45) ~[ItemTheCosmician.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:213) ~[ItemStack.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClick(PlayerInteractionManager.java:387) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processTryUseItem(NetHandlerPlayServer.java:739) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:43) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:9) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_151] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_151] at net.minecraft.util.Util.runTask(Util.java:29) ~[Util.class:?] ... 5 more [14:11:24] [Server thread/FATAL]: Error executing task This is the error and i have no idea how to fix it. The line that is the problem is the raytracing line that i talked about but i don't know more than this. This is line 45: RayTraceResult pos = player.rayTrace(22.0D, 20.0F); Any ideas?
  4. Yes, that is the one. But now i realize the if(!worldIn.isRemote) but the raytracing isn't working serverside. Anything i'm missing? Also, i added added a cast to the player saying it's an entitylivingbase, although the player class does extend entitylivingbase but i thought it could help just being even more specific.
  5. So i tried with console-printing and when im on the server it doesn't get called after the if(!worldIn.isRemote) check for some reason. @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { scala.Console.print("Gets called. "); if (!worldIn.isRemote) { scala.Console.print("worki. "); RayTraceResult pos = playerIn.rayTrace(22.0D, 0.0F); double x = pos.getBlockPos().getX(); double y = pos.getBlockPos().getY() + 1.0D; double z = pos.getBlockPos().getZ(); if (playerIn.attemptTeleport(x, y, z)) { scala.Console.print("Teleported. "); playerIn.getHeldItem(handIn).damageItem(1, playerIn); } } else{ return new ActionResult(EnumActionResult.FAIL, playerIn.getHeldItem(handIn)); } return new ActionResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } Anything that seems to doesn't work on server here? EDIT: I got a message from the server window that there's a problem with my raytracing apparently? Doesn't that get called correctly on server side, am i missing some important raytracing check for serverside?
  6. What is that? I have no idea what that is. Could you explain it to me? EDIT: Oh, i realized that you meant the Minecraft item, sorry about that. I'll take a look.
  7. Tried it, but server won't activate my item. And if i add the "else if(worldIn.isRemote)" i'm back where i started. This is a gyazo gif of what happens: https://gyazo.com/789d6fcf8c9f3c05c3fcdfc191aa96a7
  8. @Override public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if(!playerIn.world.isRemote) { RayTraceResult pos = playerIn.rayTrace(22.0D, 0.0F); double x = pos.getBlockPos().getX(); double y = pos.getBlockPos().getY() + 1.0D; double z = pos.getBlockPos().getZ(); playerIn.setPositionAndUpdate(x, y, z); playerIn.getHeldItem(handIn).damageItem(1, playerIn); return new ActionResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } return new ActionResult(EnumActionResult.FAIL, playerIn.getHeldItem(handIn)); } I tried this, but now it doesn't work at all in server. Also tried with only checking if(!worldIn.isremote) but doesn't work in servers either.
  9. But i don't understand that part, i can still teleport if i look into the ground like 5 blocks forward, but not any more than that. Why is that? As you can see, my raytrace is far more than 5 blocks.
  10. So to get rid of a misunderstanding here, i can use the item, and it does teleport me if i click on the ground or something like 5 blocks away. However if i click beyond that then i will teleport to the position im looking at but right after the server will teleport me straight back to my beginning-position. It works on singleplayer, and the raytrace is further away than 5 blocks, it's actually a raytrace distance of 22 blocks. Any help would be much appreciated. @Override public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if(!playerIn.world.isRemote) { RayTraceResult pos = playerIn.rayTrace(22.0D, 0.0F); double x = pos.getBlockPos().getX(); double y = pos.getBlockPos().getY() + 1.0D; double z = pos.getBlockPos().getZ(); playerIn.setPositionAndUpdate(x, y, z); worldIn.updateEntities(); playerIn.getHeldItem(handIn).damageItem(1, playerIn); return new ActionResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } else if(playerIn.world.isRemote) { RayTraceResult pos = playerIn.rayTrace(22.0D, 0.0F); double x = pos.getBlockPos().getX(); double y = pos.getBlockPos().getY() + 1.0D; double z = pos.getBlockPos().getZ(); playerIn.setPositionAndUpdate(x, y, z); worldIn.updateEntities(); playerIn.getHeldItem(handIn).damageItem(1, playerIn); return new ActionResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } return new ActionResult(EnumActionResult.FAIL, playerIn.getHeldItem(handIn)); }
  11. I got it to work! Thanks for all your help everyone! ?
  12. I know. I want to know what i can do to initialize it properly? Because i know how to reference classes overall, but not this specific undead.
  13. Okay, so if i want the one i click on, i need to do it another way? This doesn't work unless i initialize it, but how do i initialize it properly? @Override public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer playerIn, EntityLivingBase entity, EnumHand hand) { if (entity.world.isRemote) { return false; } if (entity instanceof EntityUndead) { EntityUndead undead; undead.becomeAlly(); return true; } return false; } I can't initialize it like i did before right? Since that'll not be called for the one i chose.
  14. This is the code that i use to call the function in the entityclass. I use this in the itemclass. I think this is server only? Or is it the other way around? @Override public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer playerIn, EntityLivingBase entity, EnumHand hand) { EntityUndead undead; undead = new EntityUndead(entity.world); World world; if (entity.world.isRemote) { return false; } if (entity instanceof EntityUndead) { undead.becomeAlly(); return true; } return false; }
  15. Well, the thing is that the for statement isn't getting executed. However the function gets executed as i wrote earlier. How would i execute the for statement properly? public void becomeAlly() { for(Object task : this.targetTasks.taskEntries.toArray()) { EntityAIBase ai = ((EntityAITaskEntry) task).action; if(ai instanceof EntityAINearestAttackableTarget) this.targetTasks.removeTask(ai); } this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntityMob.class, false)); } Tested a bit more and realized that the task that i added isn't getting added. Do i have to do this some other way altogether since the tasks doesn't seem to get updated?
  16. I'm doing that since the item that i use is supposed to turn a hostile undead into a friendly undead that attacks other mobs. That is why it needs to be alive, if i wanted it to be every new entity then that wouldn't be a problem but it needs to convert when i click the item.
  17. The reason i know that the "becomeAlly" function is getting called is because i checked through console-printing. So i'm completely sure that the function gets called. I have also tried putting brackets after the "if" such as this. if(ai instanceof EntityAINearestAttackableTarget){ this.targetTasks.removeTask(ai);} But that doesn't make any difference.
  18. Im calling the "becomeAlly" function when i right-click a certain item. The rightclicking does work and the function does get called, but the main remove-task method doesn't get called within my function.
  19. So, the problem lies in the code specifically since i can get access to the main function, but it won't remove or add my tasks. Here is the function: public void becomeAlly() { scala.Console.print("Success! "); for(Object task : this.targetTasks.taskEntries.toArray()) { EntityAIBase ai = ((EntityAITaskEntry) task).action; if(ai instanceof EntityAINearestAttackableTarget) this.targetTasks.removeTask(ai); } this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMob.class, false)); }
  20. Is there a way to change the position and size of where the texture is being read? I'd really like to change it to something like the ghasts texture lineup without the need to change the model. I've been trying to change this for a while, but to no prevail. Any help is greatly appreciated. ^^ The model and render gist - https://gist.github.com/triphion/a74e19a63f2522885da61adcb77617de EDIT: Could be worth pointing out that the model itself is like a square but a bit shorter in height. Also, the texture i have, is not the actual texture, but a test texture to see where the texture is being read.
  21. Like this? LootPool pool = new LootPool(new LootEntry[] {entry = new LootEntryItem(itemIn, weightIn, qualityIn, functionsIn, conditionsIn, entryName)}, new LootCondition[0], 3, 2, "scrolls_pool"); Well, i don't understand why new LootEntryItem is the way to go though. Also, what is the "function" parameter? This gives me a bunch of errors LootPool pool = new LootPool(new LootEntry[] {entry = new LootEntryItem(ModScrolls.scroll, 0, 0, 0, new LootCondition[0], "scroll")}, new LootCondition[0], 3, 2, "scrolls_pool"); Lol, im hopeless, wow.
  22. Okay, that's pretty neat. Well, i'm sort of stuck here. LootPool pool = new LootPool(new LootEntry[] {entry}, new LootCondition[0], 3, 2, "scrolls_pool"); I do not know what to put in the new LootEntry[] {entry}
  23. Okey, what would i do if i wanted the "dungeon_scrolls" loot table to spawn in all possible chests? Not just in the "simple_dungeon". Would that be to use the switch function which Botania used? Or is there another method?
  24. Aight, then what exactly does all the other parameters mean? Such as Like, what does that to my loot table? And what should i put in? Would this be valid? @SubscribeEvent public void lootLoad(LootTableLoadEvent evt) { /* do stuff with evt.getTable() like LootTable table = evt.getTable(); LootTable merge = MyCustomTable; table.mergePool(merge.getPool("main"); evt.setTable(table); */ String prefix = "minecraft:chests/"; String name = evt.getName().toString(); if (name.startsWith(prefix)) { String file = name.substring(name.indexOf(prefix) + prefix.length()); switch (file) { case "abandoned_mineshaft": case "desert_pyramid": case "jungle_temple": case "simple_dungeon": evt.getTable().addPool(getInjectPool(file)); break; case "spawn_bonus_chest": case "stronghold_corridor": case "village_blacksmith": evt.getTable().addPool(getInjectPool(file)); break; default: break; } } } private LootPool getInjectPool(String entryName) { return new LootPool(new LootEntry[] { getInjectEntry(entryName, 1) }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "dungeon_scrolls_pool"); } private LootEntryTable getInjectEntry(String name, int weight) { return new LootEntryTable(new ResourceLocation(Reference.MODID, "scrolls/" + name), weight, 0, new LootCondition[0], "dungeon_scrolls_entry"); } I do not quite understand the break function still tho.
×
×
  • Create New...

Important Information

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