Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/21/20 in all areas

  1. What you are looking for is the canEquip method. You can find this inside the forge item extension interface, IForgeItem. You would need to override this method inside your item class
    1 point
  2. I ran into the same error before and they're right about this modpack having a server-specific download. You're trying to launch this modpack with the mod "Ding" in the server mod folders and that specific mod is only client-side.
    1 point
  3. I suggest taking a look at this exhaustive example about projectile entities: https://github.com/TheGreyGhost/MinecraftByExample/tree/working1-16-3/src/main/java/minecraftbyexample/mbe81_entity_projectile StartupClientOnly is the class where the entity type/renderer binding happens
    1 point
  4. Minecraft:sick MC Is Sick lol
    1 point
  5. You need to wait until after tags have been read and generated. There's an event for that too, but I'm blanking on its name. IIRC it doesn't happen until after you start or load a save though.
    1 point
  6. With my system, each capability type that needs to be synced to the client has several sync-related classes: A single update network message (extending UpdateContainerCapabilityMessage) that syncs the capability data for a single slot of a Container. A bulk update network message (extending BulkUpdateContainerCapabilityMessage) that syncs the capability data for all slots of a Container. A "functions" class containing static methods used by both the single and bulk update messages. A container listener class (extending CapabilityContainerListener) that sends the single/bulk update messages when the Container's contents change. A factory function for the container listener is registered with CapabilityContainerListenerManager.registerListenerFactory at startup so that when a player opens a Container, a new listener can be created and added to it. The network messages have the concept of a "data" class, which is a simple POJO (or even a primitive type like int or long) containing only the data that needs to be synced from the server to the client. The base classes for the messages handle the functionality that's common to all capability types, the message classes for each capability just need to provide functions to do the following: On the server: Convert an instance of the capability handler (e.g. IFluidHandlerItem for a fluid tank) to a data object Encode (write) the data object to the packet buffer On the client: Decode (read) the data object from the packet buffer Apply the data from the data object to the capability handler instance These functions could be defined anywhere (they could even be lambdas passed directly to the base class methods), but I keep them as static methods in a "functions" class so they can be shared between the single and bulk messages. The system might be a bit over-engineered, but it means that I can easily add syncing for a new item capability without having to rewrite all the common syncing logic. There are several implementations of this in TestMod3 that you could use as examples: ILastUseTime, which tracks the time at which an item was last used. This is a simple implementation that syncs a single long value to the client, so it uses Long as its data class. Single update message Bulk update message Functions class Container listener Container listener registration (called during FMLCommonSetupEvent) IFluidHandlerItem, Forge's fluid tank capability. This is a slightly more complex implementation that syncs a FluidStack (the tank contents) and an int (the tank capacity), so it uses FluidTankSnapshot as its data class. Single update message Bulk update message Functions class Container listener (only syncs data for my own fluid tank item, to avoid conflicts with other mods' fluid handler items) Container listener registration (called during FMLCommonSetupEvent)
    1 point
  7. Hello there, has anyone figured out how to easily add new trades to existing villager trades? Like add a new crop to the farmer trades for example? I can see the villager traders hashmaps/array, etc but i'm not quite sure how to go about adding to that list correctly and get it registered and noticed by vanilla? if someone has the time to explain how to approach the problem I'd love to learn more about manipulating these so I can add new trades, that'd be amazing! *edit* Another issue I have is when I sort of copy the code to another class just to play about with adding, alot of the VillagerTrades.class functions are locked and private and I know you can use merchant offer to make new trades but its not recognised as an ITrade array, just boggled and confused, so clarity would be nice! Zathrox
    1 point
  8. Ah thanks for this! I basically got the trades working after finding the VillagerTradesEvent myself and between looking at that and other peoples examples for the wandering trader, I got it working buuuuut for the trades, I practically ripped and copied the VillagerTrades class and made it public so finding the BasicTrade class is very useful to know! I can pretty much scrap my own and use that! Nevermind, will stick to my class, when they say basic trade, they really do mean basic! its good if you want to use emeralds to buy something like a sword or other items but not so much for 22 CustomCrop for emeralds, etc
    1 point
  9. You might want to check the VillagerTradesEvent event and the BasicTrade class it refers to. Seems to be Forge devs indicating how you can do what you seem to want to do. There is even a WandererTradesEvent for the wandering trader as that is distinct from regular trading.
    1 point
×
×
  • Create New...

Important Information

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