• Recently Browsing

    No registered users viewing this page.

  • Posts

    • When I run @Override onItemRightClick it works just fine returning list of items around me @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { playerIn.swingArm(handIn); double x = playerIn.getPosX() ; double y = playerIn.getPosY() /*+ 1.0d*/; double z = playerIn.getPosZ(); AxisAlignedBB playerRange = new AxisAlignedBB(x - 3.0f, y - 3.0f, z - 3.0f, x + 3.0f,y + 3.0f,z + 3.0f); System.out.println(playerIn.getEntityWorld().getEntitiesWithinAABB(ItemEntity.class,playerRange));   But when I try same thing using @SubscribeEvent I get empty list, why? @SubscribeEvent public static void RightClickItem(PlayerInteractEvent.RightClickItem event) { double x = event.getPlayer().getPosX() ; double y = event.getPlayer().getPosX() /*+ 1.0d*/; double z = event.getPlayer().getPosX(); AxisAlignedBB playerRange = new AxisAlignedBB(x - 3.0f, y - 3.0f, z - 3.0f, x + 3.0f,y + 3.0f,z + 3.0f); System.out.println(event.getWorld().getEntitiesWithinAABB(ItemEntity.class,playerRange));  
    • So recently I have been trying to make a block which has multiple pages of slots, and getting to the next page and going back a page will just be a simple click of a button. However I am experiencing some issues where the slot index will be out of bounds. So from what I can tell(its quite hard to see whats actually happening), I am able to go from Page 1(first page) to Page 2 perfectly fine, and visa versa. However if I then try to go to Page 3, I get an error and the game crashes with an ArrayOutOfBoundsException. However, if I close the GUI, then re-open it, and go from Page 2 to Page 3 it works fine. Here is my code for switching pages:  public void onRecieved(Supplier<NetworkEvent.Context> context) { context.get().enqueueWork(() -> { if (context.get().getSender().openContainer instanceof SiloContainer) { SiloContainer container = (SiloContainer) context.get().getSender().openContainer; if (this.option == 0) { int index = 36; container.currentPage.set(container.currentPage.get() - 1); for (Slot slot : container.inventorySlots) { System.out.println("index: " + (slot.getSlotIndex() - (104 * container.currentPage.get()))); if (slot instanceof SlotItemHandler) { container.inventorySlots.set(index, new SlotItemHandler( container.tileEntity.getHandler().orElse(container.tileEntity.createHandler()), ((SlotItemHandler) slot).getSlotIndex() - (104 * container.currentPage.get()), ((SlotItemHandler) slot).xPos, ((SlotItemHandler) slot).yPos)); index++; } } container.detectAndSendChanges(); } else if (this.option == 1) { int index = 36; container.currentPage.set(container.currentPage.get() + 1); for (Slot slot : container.inventorySlots) { System.out.println("index: " + (slot.getSlotIndex() + (104 * container.currentPage.get()))); if (slot instanceof SlotItemHandler) { container.inventorySlots.set(index, new SlotItemHandler( container.tileEntity.getHandler().orElse(container.tileEntity.createHandler()), ((SlotItemHandler) slot).getSlotIndex() + (104 * container.currentPage.get()), ((SlotItemHandler) slot).xPos, ((SlotItemHandler) slot).yPos)); index++; } } container.detectAndSendChanges(); } } }); context.get().setPacketHandled(true); } I have been trying to figure this out for hours(over the course of many days) so forgive me if something I am doing here is horribly stupid. This is also my 9th or 10th rewrite of the code, so yea, I'm starting to get very tired with this xD. Note: I have been trying to figure this out for hours(over the course of many days) so forgive me if something I am doing here is horribly stupid. This is also my 9th or 10th rewrite of the code, so yea, I'm starting to get very tired with this xD. Also, I should note, there are 5 pages, and 104 slots per page(so the ItemHandler has a size of 520).  Here is the latest log(which includes the crash): https://hatebin.com/krsedhysky And here is a video of what i did to produce this crash(it crashed when the video ends): Also, ignore the fact that the page number doesn't update correctly, I know why, I just haven't got around to fixing it yet.    If there is any other code you need to see, just ask and I will send, cause I'm not really sure what other code would be relevant.   In advance, many thanks. TurtyWurty.
    • Hi, I have a weird issue, I dont know why but when I hold left click with a Gun Item(to aim) in the main hand, looking at grass, flowers, or torches, the player gets stuck and cant move until I stop holding left click or stop looking at the grass, flower, torch, etc,....    How could I fix this? I think i've checked all the methods from the Gun class and all the events that relate to this issue, but none is making this happen.   PD: in creative mode it has a different, it just causes the player movement to lag, and its triggered by holding left click with any block.   Here's the repo:    Gun class   Footage:  
    • So I just created a custom purple campfire. I have a few problems I've registered the block (Code attached to the bottom). But for some reason it doesn't act like a campfire at all.   The problems are that there is: no smoke no recipes working (the items stay raw) the inputted items don't render on the block the campfire doesn't re-light (with flint and steel) after it is put out   public static final RegistryObject<Block> PURPLE_CAMPFIRE = BLOCKS.register("purple_campfire", () -> new CampfireBlock(false, 3, AbstractBlock.Properties.create(Material.WOOD, MaterialColor.OBSIDIAN) .hardnessAndResistance(2.0F) .sound(SoundType.WOOD) .setLightLevel(getLightValueLit(10)) .notSolid())); private static ToIntFunction<BlockState> getLightValueLit(int lightValue) { return (block) -> { return block.get(BlockStateProperties.LIT) ? lightValue : 0; }; }  
    • There's no ready to do this, you can just call CauldronRecipe.getAllCauldronRecipes() any time you need them. If you just want a shorthand, make recipes static. This is unused.   "For all required ingredients: If the stack in slot 0 is not the ingredient: Recipe is not matched."   Uh...
  • Topics

  • Who's Online (See full list)