-
Posts
16559 -
Joined
-
Last visited
-
Days Won
156
Everything posted by Draco18s
-
[Solved] 1.16 Storing ArrayList<BlockPos> to NBT
Draco18s replied to Titmar's topic in Modder Support
To serialize: Store the length of the array. Push all serialized BlockPos values. To deserialize: Read the length of the array. Deserialize that many BlockPos values. -
[1.15.2] Opening a different container with the same itemstack
Draco18s replied to NindyBun's topic in Modder Support
Oy vey. This will always return true. As will this and this. Use orElseThrow here, that's why it exists. You know what Capabilities are and yet, you did this. Your tool is effective on nothing. This is an unchecked cast. Other mods may have items with an inventories too. This code will crash the server if you hold one of their inventory-capable items and use your keybind. -
Yeah, that's wrong. https://github.com/Draco18s/ReasonableRealism/tree/1.14.4/src/main/resources/data/harderores
-
The first build of 1.16.5 is 1.16.5-36.0.0 Official mappings were added in 1.16.5-36.0.48:
-
You almost certainly don't want to pass null.
-
How to make sure that two BlockStates are the same block
Draco18s replied to Zemelua's topic in Modder Support
state1.getBlock() == state2.getBlock() -
[1.16.5] Changing Properties of Vanilla Items
Draco18s replied to notdeadbro's topic in Modder Support
Why -
Variables aren't fucking magic. You want the player's position in a shorthand local variable? Then get the player's position and store it to a shorthand local variable.
-
item in hotbar checker (idk how to phrase it)
Draco18s replied to vanilla______'s topic in Modder Support
Lets say you buy a book on Amazon. And then you order a second copy. When they arrive you place one on your coffee table and one in your bookshelf. Are they the same object? No, of course not, you have TWO books. The one on your coffee table is definitely not the same one on your bookshelf. They are identical but they are not the same object. They are two different instances of that book. The itemstack in the player's inventory is the book on the bookshelf. The itemstack you created in your code is the book on the coffee table. And you just asked you if the two stacks are the same object. Only what you're trying to do is go through your bookshelf and find the other copy of the book that is on your coffee table. So how would you do that? By reading the titles. -
item in hotbar checker (idk how to phrase it)
Draco18s replied to vanilla______'s topic in Modder Support
(1) Why are i and I not the same variable. Please explain this. (2) Items are not Blocks, ItemStacks are not Items. -
So...go look at the available constructors and pass the parameters they want... As for the others, they got renamed. Go look at the available methods and make a best guess.
-
Did you try it?
-
*Deadpan* Don't use state.randomTick, that fires the vanilla logic again. You want to make the crop grow if your random returns true, set the event's result to ALLOW. https://github.com/MinecraftForge/MinecraftForge/blob/5f9e6f3b567565a38a46c7ccdf5a09c720b974bc/src/main/java/net/minecraftforge/event/world/BlockEvent.java#L345
-
How to find an entity the player is attacking in an event? - 1.16.5
Draco18s replied to BliX5's topic in Modder Support
You're right, I did. Whoops, not enough morning caffeine. -
How to find an entity the player is attacking in an event? - 1.16.5
Draco18s replied to BliX5's topic in Modder Support
No. I don't even know why you'd think so. Two separate computers on two separate sides of the country do not share the same JVM. You can't magically entangle the RAM of both machines to send data from one to the other without using the internet. -
ItemStackHandler inven = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseThrow(() => new Exception("WTF How does the player not have an inventory?"); ItemStack doesntFit = inven.insertStack(stack, true); if(!doesntFit.isEmpty() { /*inventory is full */ }
-
Why do you have both of these lines? Why did you change this line? I told you that method was correct. By returning what's IN the slot you allow item duplication (remember, you're trying to create ghosts! Players can't acquire ghosts!) Why do you have this method? You (1) aren't using it and (2) you aren't using imports and (3) you can just inline it's contents anywhere you would reference it. OrElseThrow() is a thing. So is ifPresent(), which would obliviate the need for this static method anyway. Jesus H Christ why are you comparing strings here. And of course the rest of that if-stack is a bunch of absolutely nonsense. You're checking if the player's held stack is equal to any of the upgrades already applied or if the held stack is Fortune or Silk Touch and that one of the existing upgrades is the other (so either (a) there's an identical upgrade applied or (b) you generate a Fortune/Silk Touch pair) then if the held stack is an upgrade (why was this not checked first?) and the held stack has the same item as the selected inventory slot's item, return true. If any of that is false, prevent insertion. Not only are all of those checks fucking nonsense, and done out of order, but what if the slot is empty? Your method returns false if the slot is empty, preventing the slot from ever being not-empty.
-
Show your code. Would be best if you posted a link to a git repo.
-
[1.16.5] Increasing float in capability over time
Draco18s replied to BlockyPenguin's topic in Modder Support
*Cough* It does. -
I did "ghost" items once, and this is the ItemStackHandler subclass: https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/industry/inventory/FilterStackHandler.java Looking at it now, I think line 23 is wrong, should be return stack.copy() (or pass a copy to super and return the original). But I haven't messed with it in a while. The extract method is correct though.
-
[1.16.5]Determine the block that the player is looking at.
Draco18s replied to NoClipMonster's topic in Modder Support
Go look at the function? Also, this code is still client side due to the call to Minecraft.getInstance() -
That code only deals with tracking the statistics.