Everything posted by Luis_ST
-
[1.16.5] Custom capability has weird / wrong values
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?
-
[1.12.2]minecraft not starting
1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
-
[1.16.5] save/transfer of capability
okay thanks i changed the capability to IItemHandlerModifiable and now it works do I have to clone the capability in another event?
-
[1.16.5] save/transfer of capability
updated and changed the things you mentioned
-
[1.16.5] save/transfer of capability
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?
-
My Nether Ore isnt generating
@EventBusSubscriber and @SubscribeEvent are missing in the Ore generation class
-
[1.16.5] save/transfer of capability
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"
-
[1.16.5] save/transfer of capability
how do I do that with my extended enderchest inventory the capability contains a CombinedInvWrapper this is the class of enderchest capability
-
[1.16.5] save/transfer of capability
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); }); });
-
[1.16.5] save/transfer of capability
yes because with getCapability I get an extension of IItemHandlerModifiable and no ItemStackHandler can I cast it to ItemStackHandler?
-
[1.16.5] save/transfer of capability
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
-
[1.16.5] save/transfer of capability
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😄
-
[1.16.5] save/transfer of capability
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?
-
[1.16.5] save/transfer of capability
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; }); });
-
Storing a single boolean
you could also use a gamerule
-
[1.16.5] save/transfer of capability
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 .
-
[1.16.5] save/transfer of capability
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
-
[1.16.5] save/transfer of capability
I've already thought that, but how do I copy the capability from one player to the other since there is no setCapability method?
-
[1.16.5] save/transfer of capability
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); }
-
[1.16.5] Server Error (Modlist not compatible)
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
-
How to make a lootbag?
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
-
[1.16.5] Server Error (Modlist not compatible)
Thanks for your help
-
[1.16.5] Server Error (Modlist not compatible)
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
-
Custom Arrow For Vanilla Bow.
the most important classes are: AbstractArrowEntity ArrowItem a class that you could also look into would be the class of the bow
-
[1.16.5] Server Error (Modlist not compatible)
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
IPS spam blocked by CleanTalk.