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.

fr3qu3ncy

Members
  • Joined

  • Last visited

Everything posted by fr3qu3ncy

  1. No, it‘s for an entity from another mod
  2. How can I get the used ItemStack from SpecialSpawn? I want to do things based on if a mob was spawned by a special spawn egg. I tried adding a CompoundNBT with this hierachy: EntityTag - ForgeData - MyTag - true to make it merge this data into the persistentData of the entity, but it's always empty.
  3. @diesieben07 debug.log Had to upload it to Google Drive since the debug.log is too large for pastebin.
  4. Hey guys, I'm trying to run the dev env with two mods (Alexs Mobs and Citadel), therefore I copied their build.gradle because there's a lot of mixin stuff: build.gradle: https://pastebin.com/PUef70eP The server boots up normally when I use the old mappings, but when I change to Mojang's mappings, I get this error on startup: java.lang.BootstrapMethodError: java.lang.ClassFormatError: Duplicate method name "isFood" with signature "(Lnet.minecraft.item.ItemStack;)Z" in class file com/github/alexthe666/alexsmobs/entity/EntityRaccoon I already use fg.deof to match the mappings of the mods to my mappings, what else could be the reason for this error?
  5. Hey! I created a library for coding mods and would like to include that in my jar, it's located on a maven repository. What is the right way to do so? I tried shadowJar, and changed jar.finalizedBy to shadowJar.finalizedBy, but still get NoSuchMethodExceptions. Is there any other way to do it, so that it also works with runClient and runServer? Edit: This works on a real client, but throws NoClassDefFoundError when started from runClient: https://pastebin.com/eFUqejaL
  6. Hey! I get this error when trying to load my mod together with a few others: de.fr3qu3ncy.shadowmobs.caps.BooleanCapability cannot be cast to com.robertx22.age_of_exile.dimension.dungeon_data.WorldDungeonCap at com.robertx22.age_of_exile.uncommon.datasaving.Load.dungeonData(Load.java:38) ~[mmorpg:?] {re:classloading} at com.robertx22.age_of_exile.event_hooks.ontick.OnTickDungeonWorld.onEndTick(OnTickDungeonWorld.java:13) ~[mmorpg:?] {re:classloading} How can the other mod access my (BooleanCapability) cap? It is loaded by World#getCapability and the capability has a unique resource location, both caps are attached in CapabilityAttachEvent<World>. The BooleanCapability class doesn't even exist in age_of_exile. Other mod's code: https://github.com/RobertSkalko/Age-of-Exile/blob/c5740a9cca788b8d02d904ca5230f34381e25d43/src/main/java/com/robertx22/age_of_exile/uncommon/datasaving/Load.java#L36 My code: https://pastebin.com/KknmYrpc
  7. For anyone trying to do the same: I copied PiglinAi and edited the findNearestValidTarget method, got it working now.
  8. Is there a way I can make a custom piglin not attack or pathfind players? I tried overriding setTarget, didn't work. Also tried clearing some memories from the brain, worked somehow but made the piglins move around weird. Am I missing some easy way?
  9. Hey, is it possible to change the tool break sound? I tried PlaySoundAtEntityEvent, but it's not called for the break sound. And in PlaySoundSourceEvent, I cannot get the entity to compare the held item with my custom item.
  10. Hey, is there any way to get the player (maybe just the UUID?) that caused a loot drop? I want to change the loot based on a capability that is attached to the ItemStack the player is holding while mining blocks or killing mobs.
  11. I figured it out, didn't register correctly. Thank you!
  12. Okay, so this is my code now: public class CIContainer extends AbstractContainerMenu { public final IItemHandler handler; public static CIContainer fromNetwork(final int windowId, final Inventory playerInventory, FriendlyByteBuf data) { return new CIContainer(windowId, playerInventory, new ItemStackHandler(27)); } public CIContainer(final int windowId, final Inventory playerInventory, IItemHandler handler) { super(BannedTools.CI_CONTAINER.get(), windowId); this.handler = handler; addPlayerSlots(playerInventory); addMySlots(); } private void addPlayerSlots(Inventory playerInventory) { int originX = 7; int originY = 67; //Hotbar for (int col = 0; col < 9; col++) { int x = originX + col * 18; int y = originY + 58; this.addSlot(new Slot(playerInventory, col, x+1, y+1)); } //Player Inventory for (int row = 0; row < 3; row++) { for (int col = 0; col < 9; col++) { int x = originX + col * 18; int y = originY + row * 18; int index = (col + row * 9) + 9; this.addSlot(new Slot(playerInventory, index, x+1, y+1)); } } } private void addMySlots() { if (this.handler == null) return; int cols = 9; int rows = 3; int slot_index = 0; for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { int x = 7 + col * 18; int y = 17 + row * 18; this.addSlot(new SlotItemHandler(this.handler, slot_index, x + 1, y + 1)); slot_index++; if (slot_index >= 27) break; } } } @Override public void clicked(int slot, int dragType, ClickType clickTypeIn, Player player) { getSlot(slot).container.setChanged(); super.clicked(slot, dragType, clickTypeIn, player); } @Override public boolean stillValid(Player player) { return true; } @Override @Nonnull public ItemStack quickMoveStack(@Nonnull Player playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.slots.get(index); if (slot.hasItem()) { int bagslotcount = this.slots.size(); ItemStack itemstack1 = slot.getItem(); itemstack = itemstack1.copy(); if (index < playerIn.getInventory().items.size()) { if (!this.moveItemStackTo(itemstack1, playerIn.getInventory().items.size(), bagslotcount, false)) return ItemStack.EMPTY; } else if (!this.moveItemStackTo(itemstack1, 0, playerIn.getInventory().items.size(), false)) { return ItemStack.EMPTY; } if (itemstack1.isEmpty()) slot.set(ItemStack.EMPTY); else slot.setChanged(); } return itemstack; } } Registering: private static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, MODID); public static final RegistryObject<MenuType<CIContainer>> CI_CONTAINER = CONTAINERS.register("ci_container", () -> IForgeMenuType.create(CIContainer::fromNetwork)); And this is how I open the inventory: @SubscribeEvent public void onRightClick(PlayerInteractEvent.RightClickItem event) { if (!(event.getItemStack().is(this))) return; if (event.getSide() == LogicalSide.CLIENT) return; ItemStack item = event.getItemStack(); ServerPlayer player = (ServerPlayer) event.getPlayer(); LazyOptional<IItemHandler> cap = item.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY); if (cap.isPresent()) { IItemHandler itemHandler = cap.resolve().get(); NetworkHooks.openGui(player, new SimpleMenuProvider( (windowId, playerInventory, playerEntity) -> new CIContainer(windowId, playerInventory, itemHandler), new TextComponent("Test"))); } } openGui() is executed, but nothing happens.
  13. @SubscribeEvent public void onSetup(FMLClientSetupEvent event) { event.enqueueWork(() -> { MenuScreens.register(ChestItemMenu.CHEST_ITEM_MENU, ContainerScreen::new); }); } And this is how I register it. How can I open that GUI now?
  14. Like this? public class ChestItemMenu implements IForgeMenuType<ChestMenu> { private static final MenuType<ChestMenu> CHEST_ITEM_MENU = register("chest_item_menu", ChestMenu::threeRows); private static <T extends AbstractContainerMenu> MenuType<T> register(String p_39989_, MenuType.MenuSupplier<T> p_39990_) { return Registry.register(Registry.MENU, p_39989_, new MenuType<>(p_39990_)); } @Override public ChestMenu create(int windowId, Inventory playerInv, FriendlyByteBuf extraData) { return ChestMenu.threeRows(windowId, playerInv); } }
  15. Can I use the ItemStackHandler's serialization like this? public class ChestItemProvider implements ICapabilityProvider, INBTSerializable<CompoundTag> { private final Capability<IItemHandler> capability; private final LazyOptional<IItemHandler> implementation; public ChestItemProvider(Capability<IItemHandler> capability, LazyOptional<IItemHandler> implementation) { this.capability = capability; this.implementation = implementation; } public static ChestItemProvider from(Capability<IItemHandler> cap, NonNullSupplier<IItemHandler> impl) { return new ChestItemProvider(cap, LazyOptional.of(impl)); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return implementation.cast(); } return LazyOptional.empty(); } @Override public CompoundTag serializeNBT() { AtomicReference<CompoundTag> tag = new AtomicReference<>(new CompoundTag()); implementation.resolve().ifPresent(itemHandler -> { tag.set(((ItemStackHandler) itemHandler).serializeNBT()); }); return tag.get(); } @Override public void deserializeNBT(CompoundTag nbt) { implementation.resolve().ifPresent(itemHandler -> { ((ItemStackHandler) itemHandler).deserializeNBT(nbt); }); } }
  16. Hey! So, following: I want to create backpacks that open when you right click with my custom item. This is in my custom item class: @Nullable @Override public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { ItemStackHandler itemHandler = new ItemStackHandler(27); return ChestItemProvider.from(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, () -> itemHandler); } This is my ChestItemProvider: public class ChestItemProvider implements ICapabilityProvider { private final Capability<IItemHandler> capability; private final LazyOptional<IItemHandler> implementation; public ChestItemProvider(Capability<IItemHandler> capability, LazyOptional<IItemHandler> implementation) { this.capability = capability; this.implementation = implementation; } public static ChestItemProvider from(Capability<IItemHandler> cap, NonNullSupplier<IItemHandler> impl) { return new ChestItemProvider(cap, LazyOptional.of(impl)); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return implementation.cast(); } return LazyOptional.empty(); } } So, a few questions: Is this implementation correct to this point? How do I open a gui with IItemHandler and how do I save the changed contents? This is what I have now: @SubscribeEvent public void onRightClick(PlayerInteractEvent.RightClickItem event) { if (!(event.getItemStack().is(this))) return; if (event.getSide() == LogicalSide.CLIENT) return; ItemStack item = event.getItemStack(); ServerPlayer player = (ServerPlayer) event.getPlayer(); LazyOptional<IItemHandler> cap = item.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY); if (cap.isPresent()) { NetworkHooks.openGui(((ServerPlayer) event.getPlayer()), new SimpleMenuProvider((windowId, playerInventory, playerEntity) -> ChestMenu.threeRows(1, new Inventory(player)), new TextComponent("Test"))); } } But this just opens a blank inventory, I could copy the IItemHandler's content to a new Inventory instance, but is this really the way you do it?
  17. This is my LootModifier: My global_loot_modifiers.json: Which exact debugger do you mean?
  18. Hey! So I tried changing loot drops to diamonds, whenever a custom emerald tool is used. This is my json: { "conditions": [ { "condition": "minecraft:alternative", "terms": [ { "condition": "minecraft:match_tool", "predicate": { "item": "bannedtools:emerald_shovel" } }, { "condition": "minecraft:match_tool", "predicate": { "item": "bannedtools:emerald_pickaxe" } } ] } ], "replacement": "minecraft:diamond" } It kinda works, but it seems like the condition always passes, because every drop is now a diamond, no matter which tool you use. Any idea why it's not working correctly?
  19. Hey guys, I am trying to implement a custom pickaxe and I am trying to override mineBlock, so I can do some stuff when a player is mining. Problem is that I cannot send particles, because it seems like mineBlock() in DiggerItem is not called on the client, is that true? I put some debug messages into it and didn't get them in the client log. Version 1.17.1

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.