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.

Luis_ST

Members
  • Joined

  • Last visited

Everything posted by Luis_ST

  1. I'm currently trying to write a mod that enables the gamemode Bedwars with all special items, blocks, ..., and a capability that includes the player values such as the position of the bed, the respawn position, whether the player has a bed, etc. But when I try to output the values, they have a different value every tick, for example a boolean value has the following values on the console: first true then false then true again and so on... I'm sure I did something wrong or something is missing, but I don't know what exactly this is the repo of my mod and that the two most important classes: capability interface capability class and the event in which I set the values does someone have an idea what is missing / wrong?
  2. 1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
  3. okay thanks i changed the capability to IItemHandlerModifiable and now it works do I have to clone the capability in another event?
  4. updated and changed the things you mentioned
  5. Update: I have changed a few things / tried but in most cases I get a ClassCastException, because I cannot cast the CombinedInvWrapper to an ItemStackHandler, although my capability should return an ItemStackHandler if I specify a direction. that is the important part of my capability provider: private EnderChestItemStackHandler inventory = new EnderChestItemStackHandler(27); private PlayerEntity player; private LazyOptional<EnderChestItemStackHandler> lazyOptional = LazyOptional.of(() -> inventory); private LazyOptional<CombinedInvWrapper> optional = LazyOptional.of(() -> { EnderChestInventory enderChestInventory = player.getInventoryEnderChest(); InvWrapper invWrapper = new InvWrapper(enderChestInventory); CombinedInvWrapper combinedInvWrapper = new CombinedInvWrapper(invWrapper, inventory); return combinedInvWrapper; }); @Override @SuppressWarnings({ "unchecked" }) public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { LazyOptional<?> ret = side == null ? optional : lazyOptional; return cap == ENDERCHEST && cap != null ? (LazyOptional<T>) ret : LazyOptional.empty(); } and how I am currently trying to get the capability (I have to use IItemHandlerModifiable first because, as already said, I cannot cast the CombinedInvWrapper to an ItemStackHandler and it should actually work anyway because getCapability should return an extension of the ItemStackHandler in this case) original.getCapability(EnderChestCapability.ENDERCHEST, Direction.WEST).ifPresent(oldEnderChest -> { IItemHandlerModifiable oldItemModifiable = oldEnderChest; ItemStackHandler oldItemHandler = (ItemStackHandler) oldItemModifiable; CompoundNBT nbt = oldItemHandler.serializeNBT(); player.getCapability(EnderChestCapability.ENDERCHEST, Direction.WEST).ifPresent(newEnderChest -> { IItemHandlerModifiable newItemModifiable = newEnderChest; ItemStackHandler newItemHandler = (ItemStackHandler) newItemModifiable; newItemHandler.deserializeNBT(nbt); }); }); what do i have to change?
  6. @EventBusSubscriber and @SubscribeEvent are missing in the Ore generation class
  7. okay this is my capability class now when I try to get the capability on the way: original.getCapability(EnderChestCapability.ENDERCHEST, Direction.WEST).ifPresent(oldEnderChest -> { CompoundNBT nbt = ((ItemStackHandler) oldEnderChest).serializeNBT(); player.getCapability(EnderChestCapability.ENDERCHEST, Direction.WEST).ifPresent(newEnderChest -> { ((ItemStackHandler) newEnderChest).deserializeNBT(nbt); }); }); eclipse gives me the following error: "Cannot cast from CombinedInvWrapper to ItemStackHandler"
  8. how do I do that with my extended enderchest inventory the capability contains a CombinedInvWrapper this is the class of enderchest capability
  9. like that: original.getCapability(BackpackCapability.BACKPACK, null).ifPresent(oldBackpack -> { CompoundNBT nbt = ((ItemStackHandler) oldBackpack).serializeNBT(); player.getCapability(BackpackCapability.BACKPACK, null).ifPresent(newBackpack -> { ((ItemStackHandler) newBackpack).deserializeNBT(nbt); }); });
  10. yes because with getCapability I get an extension of IItemHandlerModifiable and no ItemStackHandler can I cast it to ItemStackHandler?
  11. you explained to me how to create a capability (here at the forum) this is my capability class since this was my first approach, and it turned out to be wrong
  12. since my capability does not contain a get/set method i have to create it first do i create this in my provider because it contains the LazyOptional and BackpackItemStackHandler or in the actual capability class? and in which class does vanilla make this? since the enderchest inventory and the player invantar are actually only capabilities or that's not true then I could understand how exactly I clone the capability and could then transfer this to my two capabilities, which are only one extension of the ItemStackHandler B😄
  13. okay i think i can use here serializeNBT and deserializeNBT of the capability provider right? if so how do I get the provider from my capability? if not what methods should i use instead?
  14. okay i got that, but i'm just too stupid for the rest of it. which methods do I need to clone the capability? Edit: do I have to create a new capability for the new player and then put the old ones into it? update: I looked at a few github mods that also use capabilities, from which I created this: original.getCapability(BackpackCapability.BACKPACK, null).ifPresent(oldBackpack -> { player.getCapability(BackpackCapability.BACKPACK, null).ifPresent(newBackpack -> { newBackpack = oldBackpack; }); });
  15. you could also use a gamerule
  16. I know, but how? how exactly do I have to hand over my capability? is it enough if I create a new one? or do I have to replace the capability <IBackpackItemHandler> in my capability class .
  17. yes like this: PlayerEntity original = event.getOriginal(); PlayerEntity player = event.getPlayer(); IBackpackItemHandler oldBackpackHandler = original.getCapability(BackpackCapability.BACKPACK, null) .orElseThrow(() -> new NullPointerException("The mod Capability<IBackpackItemHandler> is null")); CombinedInvWrapper oldEnderChestHandler = original.getCapability(EnderChestCapability.ENDERCHEST, null) .orElseThrow(() -> new NullPointerException("The mod Capability<CombinedInvWrapper<IEnderChestItemHandler>> is null")); IBackpackItemHandler newBackpackHandler = player.getCapability(BackpackCapability.BACKPACK, null).orElse(null); CombinedInvWrapper newEnderChestHandler = player.getCapability(EnderChestCapability.ENDERCHEST, null).orElse(null); newBackpackHandler = oldBackpackHandler; newEnderChestHandler = oldEnderChestHandler; what i don't understand is how to give the new one back to the game? because somehow I have to tell the game that something has changed
  18. I've already thought that, but how do I copy the capability from one player to the other since there is no setCapability method?
  19. Some time ago I created a capability that expands the enderchest inventory, now I have encountered the following problem: if the player dies or uses the end portal, the inventory is deleted. I know that I have to use the PlayerEvent#Clone to clone the capability now my questions: Do I need another event in which I have to clone / transfer the capability? how do i clone the capability exactly? that is my beginning with which i tried it: @SubscribeEvent public static void PlayerClone(PlayerEvent.Clone event) { PlayerEntity original = event.getOriginal(); PlayerEntity player = event.getPlayer(); IBackpackItemHandler backpackHandler = original.getCapability(BackpackCapability.BACKPACK, null) .orElseThrow(() -> new NullPointerException("The mod Capability<IBackpackItemHandler> is null")); IEnderChestItemHandler enderChestHandler = original.getCapability(EnderChestCapability.ENDERCHEST, null) .orElseThrow(() -> new NullPointerException("The mod Capability<IBackpackItemHandler> is null")); player.getCapability(BackpackCapability.BACKPACK, null).orElseGet(() -> backpackHandler); player.getCapability(EnderChestCapability.ENDERCHEST, null).orElseGet(() -> enderChestHandler); }
  20. Well, I thought that it would work now, I was probably too happy about that. i have changed a few other things, at first i thought it was because i have reversed the changes but i still can't get on the server. I don't get an error on either side (server and client). The only thing I get is an error screen that says "Failed to connect to the server" "Failed to login: Invalid session (try restarting the game or the luncher)" here are the logs from server and client Client.log Server.log
  21. create a block and use the method onBlockActivated to spawn an item when you right click the block if you want to spawn a random item create a list with the items you want to spawn
  22. that's because I removed the additional folder from my reop and then didn't take over the existing gitignore file edit: if you have to clone my repo again, there might still be a few problems because I want to fix that with the gitignore file how or where do I have to register this I currently register the simplechanel in the mod class, I have to move it to an external class
  23. the most important classes are: AbstractArrowEntity ArrowItem a class that you could also look into would be the class of the bow
  24. I've now tried the mod in my ide but I don't get any errors these are the logs from server and client client.logserver.log

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.