Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Squander

Members
  • Joined

  • Last visited

Everything posted by Squander

  1. @SubscribeEvent public static void offers(VillagerTradesEvent event){ if(event.getType() == VillagerProfession.FLETCHER){ event.getTrades().put(1, Collections.singletonList(new BasicItemListing(32, new ItemStack(ModItems.EXPLOSIVE_ARROW.get()), 3, 5, 0.03f))); } } It works. But for tier one, only my offer is loaded, and vanilla is not. How to fix it?
  2. How to add custom offers to existing job types e.g. farmer.
  3. When you right-click, the container and nests will open normally. But when he wants to put items in his backpack, the items start to duplicate. What did I do wrong? public class BackpackItem extends Item implements MenuProvider, ICapabilityProvider { private final ItemStackHandler itemStackHandler = new ItemStackHandler(15); private final LazyOptional<IItemHandler> lazyOptional = LazyOptional.of(() -> itemStackHandler); public BackpackItem(Properties pProperties) { super(pProperties); } @Override public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand hand) { if(!pLevel.isClientSide()){ if(hand == InteractionHand.MAIN_HAND){ NetworkHooks.openGui(((ServerPlayer) pPlayer), this); } } return InteractionResultHolder.success(pPlayer.getItemInHand(hand)); } @Override public Component getDisplayName() { return new TextComponent("Backpack"); } @Nullable @Override public AbstractContainerMenu createMenu(int pContainerId, Inventory pInventory, Player pPlayer) { return new BackpackMenu(pContainerId, pInventory, pPlayer.getMainHandItem()); } @NotNull @Override public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) { if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY){ return lazyOptional.cast(); } return null; } public class BackpackMenu extends AbstractContainerMenu { private final ItemStack backpack; private final Level level; public BackpackMenu(int id, Inventory inventory, FriendlyByteBuf buf){ this(id, inventory, inventory.player.getMainHandItem()); } public BackpackMenu(int pContainerId, Inventory inventory, ItemStack item) { super(ModMenuType.BACKPACK.get(), pContainerId); this.level = inventory.player.level; this.backpack = item; BackpackItem item1 = (BackpackItem) this.backpack.getItem(); item1.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(handler -> { for(int i = 0; i < 3; ++i) { for(int j = 0; j < 5; ++j) { this.addSlot(new SlotItemHandler(handler, j + i * 3, 44 + j * 18, 16 + i * 18)); } } }); this.addPlayerHotbar(inventory); this.addPlayerInventory(inventory); } @Override public boolean stillValid(Player pPlayer) { return pPlayer.getMainHandItem().is(this.backpack.getItem()); } private void addPlayerInventory(Inventory inv){ for(int i = 0; i < 3; ++i) { for(int j = 0; j < 9; ++j) { this.addSlot(new Slot(inv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } } private void addPlayerHotbar(Inventory inv){ for(int k = 0; k < 9; ++k) { this.addSlot(new Slot(inv, k, 8 + k * 18, 142)); } } @Override public ItemStack quickMoveStack(Player pPlayer, int pIndex) { ItemStack toReturn = ItemStack.EMPTY; Slot slot = this.getSlot(pIndex); if(slot != null && slot.hasItem()){ ItemStack stack = slot.getItem(); toReturn = stack.copy(); if(pIndex < 15){ if(!this.moveItemStackTo(stack, 15, this.slots.size(), true)){ return ItemStack.EMPTY; } }else if(!this.moveItemStackTo(stack, 0, 15, false)){ return ItemStack.EMPTY; } if(!stack.isEmpty()){ slot.set(ItemStack.EMPTY); }else{ slot.setChanged(); } } return toReturn; } }
  4. Error java.lang.NullPointerException: Cannot invoke "net.minecraft.client.renderer.entity.EntityRenderer.shouldRender(net.minecraft.world.entity.Entity, net.minecraft.client.renderer.culling.Frustum, double, double, double)" because "entityrenderer" is null at net.minecraft.client.renderer.entity.EntityRenderDispatcher.shouldRender(EntityRenderDispatcher.java:117) ~[forge-1.18.1-39.0.9_mapped_parchment_2021.12.19-1.18.1-recomp.jar%2377!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.LevelRenderer.renderLevel(LevelRenderer.java:1233) ~[forge-1.18.1-39.0.9_mapped_parchment_2021.12.19-1.18.1-recomp.jar%2377!:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.renderLevel(GameRenderer.java:1068) ~[forge-1.18.1-39.0.9_mapped_parchment_2021.12.19-1.18.1-recomp.jar%2377!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:843) ~[forge-1.18.1-39.0.9_mapped_parchment_2021.12.19-1.18.1-recomp.jar%2377!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runTick(Minecraft.java:1066) ~[forge-1.18.1-39.0.9_mapped_parchment_2021.12.19-1.18.1-recomp.jar%2377!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:665) ~[forge-1.18.1-39.0.9_mapped_parchment_2021.12.19-1.18.1-recomp.jar%2377!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:205) ~[forge-1.18.1-39.0.9_mapped_parchment_2021.12.19-1.18.1-recomp.jar%2377!:?] {re:classloading,pl:runtimedistcleaner:A} at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {} at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {} at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {} at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {} at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:38) ~[fmlloader-1.18.1-39.0.9.jar%230!:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.21.jar%2310!:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.21.jar%2310!:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.21.jar%2310!:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.21.jar%2310!:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.21.jar%2310!:?] {} at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.21.jar%2310!:?] {} at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.21.jar%2310!:?] {} at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) [bootstraplauncher-0.1.17.jar:?] {} Event @Mod.EventBusSubscriber(modid = AnyMod.MOD_ID) public class ModEntityRenderEvent { @SubscribeEvent public static void entityRender(EntityRenderersEvent.RegisterRenderers event){ event.registerEntityRenderer(ModEntityType.THROWN_BOMB.get(), ThrownItemRenderer::new); } }
  5. For a special one that I created Here is the code @Override public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) { ItemStack itemStack = pPlayer.getItemInHand(pHand); if(itemStack.is(Items.DIAMOND)){ LightningBolt bolt = new LightningBolt(EntityType.LIGHTNING_BOLT, pLevel); bolt.setPos(pPos.getX(), pPos.getY(), pPos.getZ()); pLevel.addFreshEntity(bolt); }else pPlayer.sendMessage(new TextComponent("You have no diamond!"), Util.NIL_UUID); return InteractionResult.SUCCESS; }
  6. Hello, I would like to create a furnace in which you can only use fuel from my mod, but I have no idea how to do it.
  7. so 0.1f that would be a 10% chance
  8. What's wrong with this code public static final RegistryObject<Item> TEST_FOOD = ITEMS.register("food", () -> new Item(new Item.Properties().tab(ItemGroupTM2.ITEMS_GROUP) .food(new Food.Builder() .effect(() -> new EffectInstance(Effects.REGENERATION, 200, 1), 0f) .effect(() -> new EffectInstance(Effects.SATURATION, 200, 1), 0f) .nutrition(12).saturationMod(0.1f).build())));

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.