Everything posted by Draco18s
-
[1.15.2] Access another mod's Block without having to import it
@ObjectHolder annotations. If the mod is loaded and the block exists, the annotated field will be populated with a value.
-
[Solved] Loop through all entities standing on block
Show more code.
-
[1.14.4] Using .containerItem() to leave behind an item with NBT data?
You didn't bother checking the class's parents and interfaces, though. Check the class's interfaces. I'm sure one of them will have it.
-
[SOLVED][1.15.2] Can't remove effect from entity in ClientTickEvent
Also, what happens if there are two players, both set their effect active, and then one sets it inactive? What should happen? How does your code insure this happens?
-
Return value from capability
The code you posted did not make that clear. He answered your question with a useage of orElse(0) Which I have agreed with.
-
Return value from capability
Why would you need to? If isPresent is false, what value are you returning to your caller? Sounds like a great use of orElse(default_value) Or taking whatever your public int getAmount(ICapabilityProvider obj) { ... } method is and shoving that, in its entirety, into the place where it is being called and putting it inside an ifPresent. The only valid use for isPresent is checking to see if the capability exists and doing something with only the information that it exists. You don't care what data is in it, only that it exists.
-
First time modding; missing texture on items
There's already an "item base" class, its called Item and is in the net.minecraft.item package. Any reason you're using a deferred register for your items, but a registry event for your blocks?
-
How to make the block not able to place blocks around it
Cancel the event. I believe that that event is one that is cancelable, and if canceled, does not process the placement effect.
-
Return value from capability
But what if it doesn't HAVE a value? (This can happen if you attempt to get a capability on an object that doesn't have that capability). What do you want it to default to? Do you want to do anything at all? Do you want to ignore it or throw an error? Thus there are three possibilities: ifPresent -> if a value exists, just do something orElse -> get a value, or default value orElesThrow -> get a value, or throw an error val = orElse(null) if(val != null) { /*code*/ } is functionally equivalent to ifPresent(val -> { /*code*/ } );
-
How to make the block not able to place blocks around it
Show your code.
-
Return value from capability
Yes, that's why its called a lazy optional. https://en.wikipedia.org/wiki/Lazy_initialization
-
First time modding; missing texture on items
You forgot to include a folder with your mod ID.
-
Large, random structure generation
It also doesn't do much.
-
Large, random structure generation
Its complicated. You need a structure, structure start, and structure pieces. Its registered like anything else.
-
Two rabbits spawn instead of one
Add half a block?
-
Adding custom properties to blockstates
You need to: Get the current value Subtract 1 Deal with what happens when this makes it go below the minimum allowed value Set the new value Its a vanilla class. Go find it inside your IDE.
-
modpack creation error.
Complain to TrapCraft
-
[1.15.2] Removing Duration off of Potion Effects
You can't modify an array while iterating over it.
-
Seeking useful documentation on ItemStack usage
ItemStack is a vanilla class. It represents a (enchant-able, stack-able, damage-able) form of an Item (which is a prototypical singleton).
-
Seeking useful documentation on ItemStack usage
Depends on what you're doing. If you're using a tool as an "ingredient" and want to damage the tool, yes, you return the same stack that was passed in (after calling AttemptDamage on it).
-
[1.15.2] How is blindness processed?
That lets other mods be notified about fog and change it if they want.
-
How to make a normal Item a BlockItem of a custom block?
You can't. Listen for the PlayerInteract events (there's a specific one that applies here, I just don't remember its name, check the type hierarchy).
-
Best Way to create a bullet
This doesn't actually do what you're thinking of trying to make it do. Its firing 10 rays from the same origin out to a different max distance. If there's an entity/block within the first ray's path, then all ten rays will find the same entity.
-
[1.15.2] Enchantment Weight and Item Stack Transformation
NBT data I believe EnchantmentHelper is what you're looking for. That or ItemStack#addEnchantment. Been a while since I messed with it.
-
Return value from capability
ifPresent() takes a lambda operator. Anything that would go inside your if(val != null) block goes directly into that lambda.
IPS spam blocked by CleanTalk.