Jump to content

Overriding all projectile motion to match server changes


njny

Recommended Posts

Hello! I am the owner of a server network, and we have been patching our version of Bukkit to add support for cool features. Our latest feature requires replicating arrow shooting physics underwater to match above ground. The change is as simple as commenting out 1 line in Bukkit (changing the value multiplied across each axis of motion), however: The client appears to run its own arrow simulation. This causes something we're trying to fix using an (optional) game mod: When a player shoots, the arrow droops down underwater and then teleports to where the server believes it should be.

 

None of us are completely familiar with Forge. I have set up the Intellij workspace as detailed in the main tutorial, and have located the NMS code I need to change. My question: What steps should I take towards overriding the default entity?

 

I've been doing a lot of searching on how to do this, but it appears that overriding entities is highly discouraged and usually involves ASM (which I'd like to avoid due to the complexity...). Could someone please point me towards the resources I should look into? Should I extend the class, register a new entity, and try to spawn it in everywhere (not sure if the event system here allows that).

 

Sorry if this question is basic and very obvious. Again, we all come from the server side of things, and aren't completely familiar with modding in general.

 

Thanks in advance for your time!

 

Edit: The server supports version 1.8.7-1.8.9 I believe, and I set up my workspace using the 1.8-11.14.4.1563 setup

Link to comment
Share on other sites

If i am i am understanding this correctly what you could do in bukkit if you can send update packets send update packets for the projectiles. If this is not an option you can subscribe to EntityJoinedWorldEvent or EntityConstructingEvent probably the prior and check if it is an instanceof EntityProjectile and then edit the motion there. If that doesn not fix it you will need to create a new Entity extending the current ones aka EntityArrow/EntitySnowball. And replace the entity in one of the events i mentioned earlier.

 

*Edit if extending override setMotionAndHeading (I think that is what it is called if not it is similar).

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

If i am i am understanding this correctly what you could do in bukkit if you can send update packets send update packets for the projectiles. If this is not an option you can subscribe to EntityJoinedWorldEvent or EntityConstructingEvent probably the prior and check if it is an instanceof EntityProjectile and then edit the motion there. If that doesn not fix it you will need to create a new Entity extending the current ones aka EntityArrow/EntitySnowball. And replace the entity in one of the events i mentioned earlier.

 

*Edit if extending override setMotionAndHeading (I think that is what it is called if not it is similar).

 

Thanks for the reply! Our Bukkit changes directly alter NMS code motion, so the issue is not the sending of update packets. The issue is that, to prevent lag, Minecraft simulates physics of Arrows on the client and simply checks that they match the server's authoritative packets.

 

I took a look at EntityJoinWorldEvent, the issue is that I need to override a method entirely (to change 1 local variable in the method EntityArrow#onUpdate()

Is there a clean way to do that using EntityJoinWorldEvent? If not, then how exactly do I replace the entity cleanly? Do I need to find a way to instantiate the class with all the information from the player, or ..?

 

Also does the fact that the players will get the entity through a chest affect how EntityJoinWorldEvent in Forge are registered, or is it based off of received packets?

 

Thanks again for your time!

Link to comment
Share on other sites

The entity system in minecraft is a little complex both the server and the client have a list of entities the server handles/syncs entity data. You will register and create a new Entity that extends lets say EntityArrow. In this new Entity class override onUpdate for physics calculations. If all you are changing is the speed at which it comes out just multiply the motion x/z in EntityJoinedWorldEvent. For more clarification search EntityJoinedWorldEvent and EntityConstructingEvent to find out where they are called from.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

The entity system in minecraft is a little complex both the server and the client have a list of entities the server handles/syncs entity data. You will register and create a new Entity that extends lets say EntityArrow. In this new Entity class override onUpdate for physics calculations. If all you are changing is the speed at which it comes out just multiply the motion x/z in EntityJoinedWorldEvent. For more clarification search EntityJoinedWorldEvent and EntityConstructingEvent to find out where they are called from.

 

Thanks for all the info! Okay, so I've created my event handler and I think the logic is fine. How should I register my customized entity? I tried

 

EntityRegistry.registerGlobalEntityID(UnderwaterEntityArrow.class, "Arrow", 262);

 

But this causes some unclear error (stacktrace doesn't yield helpful information, but I'm going to assume ID clash, I tried to use the ID of an arrow... what param should I use instead? some arbitrary large number?), any ideas? I can't seem to find examples of replacing entities, and so I'm not sure what ID I should use (or even if I'm using the right registry class).

 

Edit:

 

I got it to register like this (I think... at least it didn't error):

EntityRegistry.registerModEntity(UnderwaterEntityArrow.class, "Arrow", 262, this, 100, 100, true);

 

Here's my code for the event:

    @SubscribeEvent
    public void entityJoinWorldEvent(EntityJoinWorldEvent event) {
        if(event.entity instanceof EntityArrow) {
            UnderwaterEntityArrow replacement = new UnderwaterEntityArrow(event.world);
            Entity shooter = ((EntityArrow) event.entity).shootingEntity;
            replacement.setLocationAndAngles(shooter.posX, shooter.posY + (double)shooter.getEyeHeight(), shooter.posZ, shooter.rotationYaw, shooter.rotationPitch);
            event.world.spawnEntityInWorld(replacement);
            event.entity.setDead();
        }
    }

 

Unfortunately I get an NPE at line 43. Shooter is the only possible null thing (as replacement is instantiated just above it), what should I do? My guess would be that custom arrow isn't having its data set... Not really sure what to do. Also, is shootingEntity of EntityArrow referring to the Bow or the source (Player, Skeleton, dispenser, etc)?

 

Link to comment
Share on other sites

The entity system in minecraft is a little complex both the server and the client have a list of entities the server handles/syncs entity data. You will register and create a new Entity that extends lets say EntityArrow. In this new Entity class override onUpdate for physics calculations. If all you are changing is the speed at which it comes out just multiply the motion x/z in EntityJoinedWorldEvent. For more clarification search EntityJoinedWorldEvent and EntityConstructingEvent to find out where they are called from.

 

Thanks for all the info! Okay, so I've created my event handler and I think the logic is fine. How should I register my customized entity? I tried

 

EntityRegistry.registerGlobalEntityID(UnderwaterEntityArrow.class, "Arrow", 262);

 

But this causes some unclear error (stacktrace doesn't yield helpful information, but I'm going to assume ID clash, I tried to use the ID of an arrow... what param should I use instead? some arbitrary large number?), any ideas? I can't seem to find examples of replacing entities, and so I'm not sure what ID I should use (or even if I'm using the right registry class).

 

Edit:

 

I got it to register like this (I think... at least it didn't error):

EntityRegistry.registerModEntity(UnderwaterEntityArrow.class, "Arrow", 262, this, 100, 100, true);

 

Here's my code for the event:

    @SubscribeEvent
    public void entityJoinWorldEvent(EntityJoinWorldEvent event) {
        if(event.entity instanceof EntityArrow) {
            UnderwaterEntityArrow replacement = new UnderwaterEntityArrow(event.world);
            Entity shooter = ((EntityArrow) event.entity).shootingEntity;
            replacement.setLocationAndAngles(shooter.posX, shooter.posY + (double)shooter.getEyeHeight(), shooter.posZ, shooter.rotationYaw, shooter.rotationPitch);
            event.world.spawnEntityInWorld(replacement);
            event.entity.setDead();
        }
    }

 

Unfortunately I get an NPE at line 43. Shooter is the only possible null thing (as replacement is instantiated just above it), what should I do? My guess would be that custom arrow isn't having its data set... Not really sure what to do. Also, is shootingEntity of EntityArrow referring to the Bow or the source (Player, Skeleton, dispenser, etc)?

Im not sure what constructor you should be using look at ItemBow for which constructor it uses you will also need to set it's Motion and heading before you spawn it.

 

*Edit Isnt shootingEntity a private field.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Before I can even start:

 

Do you want to have modified Bukkit server without Forge and client-only Forge Mod on client that will modify client's arrows to fit Bukkit server ones?

OR

You actually have Forge on server and client and we are talking about normal Forge modding (without outdated, dead and all bad stuff Bukkit things)?

 

p.s: Going sleep soon. :P

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Before I can even start:

 

Do you want to have modified Bukkit server without Forge and client-only Forge Mod on client that will modify client's arrows to fit Bukkit server ones?

OR

You actually have Forge on server and client and we are talking about normal Forge modding (without outdated, dead and all bad stuff Bukkit things)?

 

p.s: Going sleep soon. :P

 

Ah, I should have specified! Sorry! It's just Bukkit without Forge, I think it would be best to modify client to fit Bukkit because this mod will be optional on our server (if the visual aspect of the arrow not matching is bothersome, players will be allowed to use our mod to correct their client).

 

If you suggest something else, however, I'll definitely consider it. This just seems like the most straightforward choice.

 

Thanks for your reply!

 

I haven't had any progress since the last person to reply however. Currently I tried just spawning in my extended class on EntityJoinWorldEvent, and removing the original entity. It just freezes the game and dies. Any idea on the proper way to do this?

Link to comment
Share on other sites

The entity system in minecraft is a little complex both the server and the client have a list of entities the server handles/syncs entity data. You will register and create a new Entity that extends lets say EntityArrow. In this new Entity class override onUpdate for physics calculations. If all you are changing is the speed at which it comes out just multiply the motion x/z in EntityJoinedWorldEvent. For more clarification search EntityJoinedWorldEvent and EntityConstructingEvent to find out where they are called from.

 

Thanks for all the info! Okay, so I've created my event handler and I think the logic is fine. How should I register my customized entity? I tried

 

EntityRegistry.registerGlobalEntityID(UnderwaterEntityArrow.class, "Arrow", 262);

 

But this causes some unclear error (stacktrace doesn't yield helpful information, but I'm going to assume ID clash, I tried to use the ID of an arrow... what param should I use instead? some arbitrary large number?), any ideas? I can't seem to find examples of replacing entities, and so I'm not sure what ID I should use (or even if I'm using the right registry class).

 

Edit:

 

I got it to register like this (I think... at least it didn't error):

EntityRegistry.registerModEntity(UnderwaterEntityArrow.class, "Arrow", 262, this, 100, 100, true);

 

Here's my code for the event:

    @SubscribeEvent
    public void entityJoinWorldEvent(EntityJoinWorldEvent event) {
        if(event.entity instanceof EntityArrow) {
            UnderwaterEntityArrow replacement = new UnderwaterEntityArrow(event.world);
            Entity shooter = ((EntityArrow) event.entity).shootingEntity;
            replacement.setLocationAndAngles(shooter.posX, shooter.posY + (double)shooter.getEyeHeight(), shooter.posZ, shooter.rotationYaw, shooter.rotationPitch);
            event.world.spawnEntityInWorld(replacement);
            event.entity.setDead();
        }
    }

 

Unfortunately I get an NPE at line 43. Shooter is the only possible null thing (as replacement is instantiated just above it), what should I do? My guess would be that custom arrow isn't having its data set... Not really sure what to do. Also, is shootingEntity of EntityArrow referring to the Bow or the source (Player, Skeleton, dispenser, etc)?

Im not sure what constructor you should be using look at ItemBow for which constructor it uses you will also need to set it's Motion and heading before you spawn it.

 

*Edit Isnt shootingEntity a private field.

shootingEntity is public, though it looks like it's always null (not sure why?).

How should I feed it heading information if I can't really get info from the shooter? Any way to cleanly copy all data from old arrow over to the new one?

Link to comment
Share on other sites

The motionX motionY motionZ yaw and pitch setMotionAndHeading or similar is called right before it was created look into that for information in general.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Global entity ids are deprecated, use registerModEntity instead; ids for mod entities only have to be unique within the mod, rather than globally.

 

What line is line 43, and is the NPE client-side or server-side?

 

Hello, thanks for the info. I'll set it as 0 then because this mod registers nothing else.

 

43 is

 

replacement.setLocationAndAngles(shooter.posX, shooter.posY + (double)shooter.getEyeHeight(), shooter.posZ, shooter.rotationYaw, shooter.rotationPitch);

 

Sorry about that, I really should have specified (wasn't thinking).

 

Not sure what you mean server-side/client-side. Still very new to client modding, I was under the impression that all the work I'm doing right now is client side changes. I'll try to replicate the error right now.

 

Here's the stack of the error:

[23:38:39] [server thread/ERROR] [FML]: Index: 3 Listeners:
[23:38:39] [server thread/ERROR] [FML]: 0: HIGHEST
[23:38:39] [server thread/ERROR] [FML]: 1: ASM: net.minecraftforge.common.ForgeInternalHandler@2f5a23c1 onEntityJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
[23:38:39] [server thread/ERROR] [FML]: 2: NORMAL
[23:38:39] [server thread/ERROR] [FML]: 3: ASM: net.hungerstruck.arrowphysics.ArrowPhysicsMod@1bae8e5e entityJoinWorldEvent(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
[23:38:39] [server thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.event.entity.EntityJoinWorldEvent@b8047f5:
java.lang.NullPointerException
        at net.hungerstruck.arrowphysics.ArrowPhysicsMod.entityJoinWorldEvent(ArrowPhysicsMod.java:53) ~[ArrowPhysicsMod.class:?]
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_ArrowPhysicsMod_entityJoinWorldEvent_EntityJoinWorldEvent.invoke(.dynamic) ~[?:?]
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) ~[ASMEventHandler.class:?]
        at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) [EventBus.class:?]
        at net.minecraft.world.World.spawnEntityInWorld(World.java:1230) ~[World.class:?]
        at net.hungerstruck.arrowphysics.ArrowPhysicsMod.entityJoinWorldEvent(ArrowPhysicsMod.java:54) ~[ArrowPhysicsMod.class:?]
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_ArrowPhysicsMod_entityJoinWorldEvent_EntityJoinWorldEvent.invoke(.dynamic) ~[?:?]
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) ~[ASMEventHandler.class:?]
        at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) [EventBus.class:?]
        at net.minecraft.world.World.spawnEntityInWorld(World.java:1230) [World.class:?]
        at net.minecraft.item.ItemBow.onPlayerStoppedUsing(ItemBow.java:95) [itemBow.class:?]
        at net.minecraft.item.ItemStack.onPlayerStoppedUsing(ItemStack.java:530) [itemStack.class:?]
        at net.minecraft.entity.player.EntityPlayer.stopUsingItem(EntityPlayer.java:232) [EntityPlayer.class:?]
        at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:525) [NetHandlerPlayServer.class:?]
        at net.minecraft.network.play.client.C07PacketPlayerDigging.processPacket(C07PacketPlayerDigging.java:53) [C07PacketPlayerDigging.class:?]
        at net.minecraft.network.play.client.C07PacketPlayerDigging.processPacket(C07PacketPlayerDigging.java:76) [C07PacketPlayerDigging.class:?]
        at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:24) [PacketThreadUtil$1.class:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_65]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_65]
        at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714) [FMLCommonHandler.class:?]
        at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:727) [MinecraftServer.class:?]
        at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) [MinecraftServer.class:?]
        at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) [integratedServer.class:?]
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_65]
[23:38:39] [server thread/ERROR] [FML]: Index: 3 Listeners:
[23:38:39] [server thread/ERROR] [FML]: 0: HIGHEST
[23:38:39] [server thread/ERROR] [FML]: 1: ASM: net.minecraftforge.common.ForgeInternalHandler@2f5a23c1 onEntityJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
[23:38:39] [server thread/ERROR] [FML]: 2: NORMAL
[23:38:39] [server thread/ERROR] [FML]: 3: ASM: net.hungerstruck.arrowphysics.ArrowPhysicsMod@1bae8e5e entityJoinWorldEvent(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
[23:38:39] [server thread/FATAL] [FML]: Exception caught executing FutureTask: java.util.concurrent.ExecutionException: java.lang.NullPointerException
java.util.concurrent.ExecutionException: java.lang.NullPointerException
        at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_65]
        at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_65]
        at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:715) [FMLCommonHandler.class:?]
        at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:727) [MinecraftServer.class:?]
        at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) [MinecraftServer.class:?]
        at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) [integratedServer.class:?]
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_65]
Caused by: java.lang.NullPointerException
        at net.hungerstruck.arrowphysics.ArrowPhysicsMod.entityJoinWorldEvent(ArrowPhysicsMod.java:53) ~[ArrowPhysicsMod.class:?]
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_ArrowPhysicsMod_entityJoinWorldEvent_EntityJoinWorldEvent.invoke(.dynamic) ~[?:?]
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) ~[ASMEventHandler.class:?]
        at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) ~[EventBus.class:?]
        at net.minecraft.world.World.spawnEntityInWorld(World.java:1230) ~[World.class:?]
        at net.hungerstruck.arrowphysics.ArrowPhysicsMod.entityJoinWorldEvent(ArrowPhysicsMod.java:54) ~[ArrowPhysicsMod.class:?]
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_ArrowPhysicsMod_entityJoinWorldEvent_EntityJoinWorldEvent.invoke(.dynamic) ~[?:?]
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) ~[ASMEventHandler.class:?]
        at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) ~[EventBus.class:?]
        at net.minecraft.world.World.spawnEntityInWorld(World.java:1230) ~[World.class:?]
        at net.minecraft.item.ItemBow.onPlayerStoppedUsing(ItemBow.java:95) ~[itemBow.class:?]
        at net.minecraft.item.ItemStack.onPlayerStoppedUsing(ItemStack.java:530) ~[itemStack.class:?]
        at net.minecraft.entity.player.EntityPlayer.stopUsingItem(EntityPlayer.java:232) ~[EntityPlayer.class:?]
        at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:525) ~[NetHandlerPlayServer.class:?]
        at net.minecraft.network.play.client.C07PacketPlayerDigging.processPacket(C07PacketPlayerDigging.java:53) ~[C07PacketPlayerDigging.class:?]
        at net.minecraft.network.play.client.C07PacketPlayerDigging.processPacket(C07PacketPlayerDigging.java:76) ~[C07PacketPlayerDigging.class:?]
        at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:24) ~[PacketThreadUtil$1.class:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_65]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_65]
        at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714) ~[FMLCommonHandler.class:?]
        ... 5 more

 

 

Line references have changed: 53 is pointing to the line

            replacement.setLocationAndAngles(shooter.posX, shooter.posY + (double)shooter.getEyeHeight(), shooter.posZ, shooter.rotationYaw, shooter.rotationPitch);

Link to comment
Share on other sites

The motionX motionY motionZ yaw and pitch setMotionAndHeading or similar is called right before it was created look into that for information in general.

 

It seems to be called in the constructor using information from the shooter, which I can't get. What else could I do?

Link to comment
Share on other sites

Fk my last post. This is what happens when you try to apply logic to retarded fixes (read: Bukkit).

 

If you won't solve it in next 6h+, call me Skype (ernio333) and maybe TeamViewer so I can skim through code fast (you are outdated).

 

Challenge-Accepted-Face-01.jpg

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

so the arrows don't lag/glitch/jerk before hitting the ground:

 

private static void register(Class cls, String name)
{
	EntityRegistry.registerModEntity(cls, name, id++, Guru.getInstance(), 128, 214, true);
}

 

128,214 is enough to where if you throw/fire something from the player it wont jerk before hitting something or the ground. I can't stand how vanilla arrows and snowballs jerk while flying through the air.

Makes keeping up with flight patterns a pain.

 

If you were to make a custom entity you could just remove the water movement handling, or adjust it.

Link to comment
Share on other sites

so the arrows don't lag/glitch/jerk before hitting the ground:

 

private static void register(Class cls, String name)
{
	EntityRegistry.registerModEntity(cls, name, id++, Guru.getInstance(), 128, 214, true);
}

 

128,214 is enough to where if you throw/fire something from the player it wont jerk before hitting something or the ground. I can't stand how vanilla arrows and snowballs jerk while flying through the air.

Makes keeping up with flight patterns a pain.

 

If you were to make a custom entity you could just remove the water movement handling, or adjust it.

If I have read through the code correctly then increasing updateFrequency should increase the time (please correct me if I am wrong provide location in code please). Considering it uses % to check aka updateCounter % updateFrequency == 0 send packet. This will make it smoother, but that is De-syncing the entity as the entity is not receiving many position updates. But this should be ignored if it is airborne or it is dirty(needing to be saved). The 128(trackingRange) is definitely good because if you look at Minecraft entities they go up to 256(EntityEnderCrystal). While some do go over 20 that includes EntityHanging, EntityAreaEffectCloud, and EntityEnderCrystal they all use the value of Integer.MAX_VALUE (aka. 2,147,483,647). This is probably because hanging entities do not need position updates, (not quite sure what EntityAreaEffectCloud is), and EntityEnderCrystal also only needs one sync. They only need one because they do not move at least not normally.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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