-
Posts
16559 -
Joined
-
Last visited
-
Days Won
156
Everything posted by Draco18s
-
[1.15.2] Access another mod's Block without having to import it
Draco18s replied to squidlex's topic in Modder Support
@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
Draco18s replied to BlockyPenguin's topic in Modder Support
Show more code. -
[1.14.4] Using .containerItem() to leave behind an item with NBT data?
Draco18s replied to JayZX535's topic in Modder Support
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
Draco18s replied to Novârch's topic in Modder Support
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? -
The code you posted did not make that clear. He answered your question with a useage of orElse(0) Which I have agreed with.
-
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.
-
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
Draco18s replied to martiblq's topic in Modder Support
Cancel the event. I believe that that event is one that is cancelable, and if canceled, does not process the placement effect. -
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
Draco18s replied to martiblq's topic in Modder Support
Show your code. -
Yes, that's why its called a lazy optional. https://en.wikipedia.org/wiki/Lazy_initialization
-
You forgot to include a folder with your mod ID.
-
It also doesn't do much.
-
Its complicated. You need a structure, structure start, and structure pieces. Its registered like anything else.
-
Add half a block?
-
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.
-
Complain to TrapCraft
- 1 reply
-
- 1
-
-
[1.15.2] Removing Duration off of Potion Effects
Draco18s replied to TheRedWaffle's topic in Modder Support
You can't modify an array while iterating over it. -
Seeking useful documentation on ItemStack usage
Draco18s replied to Cerezo's topic in Modder Support
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
Draco18s replied to Cerezo's topic in Modder Support
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). -
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?
Draco18s replied to Acryt's topic in Modder Support
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). -
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
Draco18s replied to Cryotron's topic in Modder Support
NBT data I believe EnchantmentHelper is what you're looking for. That or ItemStack#addEnchantment. Been a while since I messed with it. -
ifPresent() takes a lambda operator. Anything that would go inside your if(val != null) block goes directly into that lambda.