Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

transfarmer

Members
  • Content Count

    15
  • Joined

  • Last visited

Everything posted by transfarmer

  1. You can make an invisible entity that deals damage if it hits an enemy within a certain range.
  2. I am trying to update a capability on player death. I use PlayerEvent.Clone and check if isWasDeath() to send a packet to the client to update that capability. My Clone event handler first copies the original PlayerEntity's capability values to the PlayerEntity in the logical server and then sends a packet to the client, which uses Minecraft#player. The server-side capability is updated without issues, but it is not even present in the client. Both sides use LazyOptional<X>#ifPresent. links: Clone event handler, client packet Why does this occur? edit: reconnecting
  3. I have a PlayerEntity capability and a packet class for updating that capability in clients that is sent by the server on player login. I also have a method that listens to PlayerTickEvent and removes items from PlayerEntitys' inventories if a field that they have (SoulWeapons.WeaponType weaponType) is null. When I enter a world, set the field to a non-null value, and reconnect, my capability fields are reset and the items are removed on the client side (they are still in the inventory and I can drop them, but their slots are blank), but the server has the correct information. Is the issue wit
  4. Thank you for your assistance; your code was very helpful. I also looked at the post that you linked. My issue is now solved.
  5. I pushed my changes to the GitHub repository that I mentioned earlier. I will check these resources when I return home.
  6. Thank you. So I did. Currently, I handle packets sent to a client and packets sent to the server inside the same function, separated by a check on FMLEnvironment.dist. Is this correct? My client receives information back from the server and does what the server did (it modified a capability), based on its response, and my client appears synchronized with the server. However, when the former connects to the latter, the capability seems to have returned to its default state on the client side. Do I have to use something like a UserJoinedEvent to correct this? edit: I used Player
  7. I have a capability whose serializeNBT, writeNBT, deserializeNBT, and readNBT methods are called, and its information is preserved after disconnecting a server; however, the client's information is not updated. It sends a packet to the server after clicking a button in a custom GUI and the server modifies the capability attached to the sender of the packet. Should the server send a packet back? If so, then how? I tried using the shorter method described in the Forge documentation, but instead of a PlayerEntity I need a Supplier<PlayerEntity> and I doubt that I have to make a new class fo
  8. Yes. Then could you explain to me what it does? I'm still not sure about why I need it. Is it a basic instance made for every object to which the capability is attached for NBT storage? Also, I think that my data are not saved after leaving and joining a world. Do I have to do it manually?
  9. I apologize. The issue with writeNBT was that I was trying to use Object.toString() on a value that was null.The provider class is shown below. I agree. Does it have to be initialized? If so, then what should it be?
  10. Loading a world produces a NullPointerExceptionagain. The ICapability instance passed to writeNBT seems to be null:
  11. I already have it: @EventBusSubscriber(modid = Main.MODID, bus = EventBusSubscriber.Bus.MOD) public class ModEventSubscriber { . . . @SubscribeEvent public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof PlayerEntity) { event.addCapability(new ResourceLocation(Main.MODID, "type"), new Provider()); } } . . . } Is something wrong with this code?
  12. Is the capability non-null when it is registered and attached? Otherwise, how can I make it non-null? My PlayerEntity seems to not have it.
  13. The Forge documentation states the following: However, the return type of getCapability is LazyOptional<T>, and I want to use the methods defined in my interface. How should I use getCapability?
  14. I read again the Forge documentation about capabilities. According to the it, the capability is null because it was not registered. Then I made it non-final and tried to properly register it during common setup. The NullPointerException does not occur anymore. However, my keybinding does not load anymore (I set its registration to occur during client setup by FMLClientSetupEvent as I was cleaning up my mod setup). Previously, it loaded but did not function. (It functioned as expected before I implemented the capability.) Should I open a new thread for that? Also, the 1.15.x documentation
  15. Hello. I made a custom capability that should be attached to EntityPlayer. My provider class initializes an instance of Capabilty and sets its value to null and makes a LazyOptional instance of this capability: public static final Capability<ISoulWeapon> TYPE = null; private LazyOptional<ISoulWeapon> instance = LazyOptional.of(TYPE::getDefaultInstance); I assume that this is correct because this is the only way in which I saw this done. However, the instance seems to be null. The game runs until a world is loaded, when it crashes, producing the following stacktrace:
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.