-
Content Count
220 -
Joined
-
Last visited
-
Days Won
6
vemerion last won the day on November 17 2020
vemerion had the most liked content!
Community Reputation
56 ExcellentAbout vemerion
-
Rank
Creeper Killer
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
You are right. I opted for the easy and wrong answer, and then tried to explain it away. I have updated my original answer, and I hope you can find it in your heart to forgive me! What you should do is change the type of your instance field to the type LazyOptional<IState>, which you should initialize to LazyOptional.of(() -> STATE_CAPABILITY.getDefaultInstance()), to avoid creating a new LazyOptional every time getCapability() is called. Note that you might have to slightly change some of your other methods to accommodate for the fact that instance now is a LazyOptional. Here is another thread which also discusses why you should cache the capability. I would also recommend taking a look at the LazyOptional class (easiest done via your IDE), since it includes a lot of documentation about why/how it is used.
-
Of course you are right! However I wanted to provide a as simple solution as possible, which is why I left out that part.
-
I usually do it like this: return STATE_CAPABILITY.orEmpty(capability, LazyOptional.of(() -> instance)); EDIT: This is the simple but very wrong answer! As diesieben07 points out further down in the thread, you should absolutely cache the LazyOptional in a field to avoid creating a new LazyOptional every time getCapability() is called.
-
You don't need an interface, you could use the ChunkValue class only, without an interface.
-
I recommend looking into the Global loot modifiers system.
-
If it is your own custom item, you could use the renderHelmetOverlay() method instead of an event.
-
How do I add custom trades to the Wandering Trader?
vemerion replied to Moomallowz's topic in Modder Support
What exactly are you having trouble with? This line of code: event.getGenericTrades().add(new BasicTrade(5, new ItemStack(Items.ENCHANTED_GOLDEN_APPLE, 5), 2, 10)); would add a new trade that costs 5 emeralds and gives you 5 enchanted golden apples in return. -
Do you mean that you want to know where the vanilla code is for creating the enchantment tooltips? If so, it is in the getTooltip() and the addEnchantmentTooltips() methods in the ItemStack class. If you want to add your own custom tooltip to an item, you can do so via the addInformation() method in the Item class if it is for your own custom item, or via the ItemTooltipEvent event if it is for a vanilla item.
-
How do I add custom trades to the Wandering Trader?
vemerion replied to Moomallowz's topic in Modder Support
Call the WandererTradesEvent event and add your own custom ITrades to the list in the event. -
You can't really add new dataparamaters to vanilla entities. You should instead use capabilities.
-
It looks like you spelled 'stick' wrong in the recipes.
-
[1.15.2] Teleport Player to Nearest "Safe" Spot
vemerion replied to ModMCdl's topic in Modder Support
If you look at the call hierarchy of the placeEntity() method, you can see that the entity it returns is in fact the entity that is teleported. Therefore, to change the position of the entity you would only need to change the position of the entity you return before returning it. -
[1.15.2] Teleport Player to Nearest "Safe" Spot
vemerion replied to ModMCdl's topic in Modder Support
I think the method makePortal() in the Teleporter class is where vanilla tries to find a nearby valid position to create the portal in. However, it is kind of a large and unreadable method, so I don't know if it is realistic to try and replicate it. Another possibility would be to do something similar to how the locate command works. I am not too familiar with world generation, but if your islands are generated similar to how vanilla structures are generated, then this could work. -
I don't think there is a direct equivalent of CountRangeConfig, see this thread for more details.
-
Here is what I would do: override the canInteractWith() method in your custom container, and return false if the player is no longer holding your storage item.
- 1 reply
-
- 1
-