Jump to content

Draco18s

Members
  • Posts

    16559
  • Joined

  • Last visited

  • Days Won

    156

Everything posted by Draco18s

  1. @ObjectHolder annotations. If the mod is loaded and the block exists, the annotated field will be populated with a value.
  2. 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.
  3. 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?
  4. The code you posted did not make that clear. He answered your question with a useage of orElse(0) Which I have agreed with.
  5. 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.
  6. 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?
  7. Cancel the event. I believe that that event is one that is cancelable, and if canceled, does not process the placement effect.
  8. 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*/ } );
  9. Yes, that's why its called a lazy optional. https://en.wikipedia.org/wiki/Lazy_initialization
  10. You forgot to include a folder with your mod ID.
  11. It also doesn't do much.
  12. Its complicated. You need a structure, structure start, and structure pieces. Its registered like anything else.
  13. Add half a block?
  14. 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.
  15. Complain to TrapCraft
  16. You can't modify an array while iterating over it.
  17. ItemStack is a vanilla class. It represents a (enchant-able, stack-able, damage-able) form of an Item (which is a prototypical singleton).
  18. 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).
  19. That lets other mods be notified about fog and change it if they want.
  20. 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).
  21. 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.
  22. NBT data I believe EnchantmentHelper is what you're looking for. That or ItemStack#addEnchantment. Been a while since I messed with it.
  23. ifPresent() takes a lambda operator. Anything that would go inside your if(val != null) block goes directly into that lambda.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.