Giter VIP home page Giter VIP logo

mcme-entities's People

Contributors

erioleandur avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mcme-entities's Issues

Entity packets do not get updated correctly

Turns out the changes introduced in #5 and #6 do not work as intended due to some packets relying on being updated every tick to maintain synchronization with the entity they're linked to.

Specifically:

  • BoneMetaPacket checks flags updated every tick to detect changes to the entity and has an internal queue for head positions,
  • BoneInitPacket checks flags updated every tick to detect changes to the entity,
  • SimpleEntityMovePacket checks flags updated every tick to detect changes to the entity,
  • others?

Personally, I'd argue that this polling approach is wasteful, both because it needs to query the entity every tick to detect changes, and because it makes it difficult to prevent unnecessary updates to the packets in situations where the entity is not visible to any players or the state it contains hasn't actually changed.

This is made worse by two factors:

  • MCME's lack of reuse of ProtocolLib objects (see #9 for an example),
  • and ProtocolLib accessing the packets through reflection, making the update operations more expensive than native writes.

A lot of this is out of scope for me right now, but we should address what this issue is actually about: packets not getting updated. There are two ways to move forward:

  • improve the way packet updates are handled, allowing these changes to stay (edit: see #10), or
  • revert the commits on development until the above is implemented.

I'm attempting to do the former (writing this issue in part serves as research), but I'm a little afraid to touch this in fear of breaking it. I've also been forced to put this off for long enough that I feel it's important to acknowledge this issue in case someone runs into it.

Rotation Matrices

Concerning https://github.com/MCME/MCME-Entities/blob/master/src/main/java/com/mcmiddleearth/entities/util/RotationMatrix.java , it might be beneficial to decouple the matrix from the internal bukkit system completely. Using a double/float array (float[]) or double array (float[][]) will result in faster calculations because of memory colocation and skipping jit optimizations completely (getter inlining). See https://math.nist.gov/javanumerics/jama/doc/ implementations for instance.

public static Vector fastRotateY(Vector vector, float angle) {
looks like a simple euler rotation, which may result in gimbal lock. (See https://gamedev.stackexchange.com/questions/45292/how-is-the-gimbal-locked-problem-solved-using-accumulative-matrix-transformation)

public RotationMatrix multiply(RotationMatrix other) {
shouldn't return null if its not implemented but throw an UnsupportedOperationException. https://docs.oracle.com/javase/8/docs/api/java/lang/UnsupportedOperationException.html

Projectiles without shooter cause a NullPointerException

player.world.spawn(player.location, Firework.class);

Above code causes the following exception to be thrown:

[17:25:40 ERROR]: Could not pass event ProjectileLaunchEvent to MCME-Entities v1.0
java.lang.NullPointerException: Cannot invoke "com.mcmiddleearth.entities.entities.McmeEntity.getEntityId()" because "shooter" is null
	at com.mcmiddleearth.entities.protocol.packets.simple.ProjectileSpawnPacket.(ProjectileSpawnPacket.java:24) ~[MCME-Entities-1.0.jar:?]
	at com.mcmiddleearth.entities.entities.Projectile.(Projectile.java:45) ~[MCME-Entities-1.0.jar:?]
	at com.mcmiddleearth.entities.api.VirtualEntityFactory.build(VirtualEntityFactory.java:572) ~[MCME-Entities-1.0.jar:?]
	at com.mcmiddleearth.entities.server.SyncEntityServer.spawnEntity(SyncEntityServer.java:145) ~[MCME-Entities-1.0.jar:?]
	at com.mcmiddleearth.entities.events.listener.ProjectileListener.onProjectileLaunch(ProjectileListener.java:49) ~[MCME-Entities-1.0.jar:?]
	at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor8.execute(Unknown Source) ~[?:?]
	at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
	at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:git-Paper-317]
	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:669) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callProjectileLaunchEvent(CraftEventFactory.java:1398) ~[paper-1.18.2.jar:git-Paper-317]
	at org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.doEntityAddEventCalling(CraftEventFactory.java:649) ~[paper-1.18.2.jar:git-Paper-317]
	at net.minecraft.server.level.ServerLevel.addEntity(ServerLevel.java:1422) ~[?:?]
	at net.minecraft.server.level.ServerLevel.addFreshEntity(ServerLevel.java:1331) ~[?:?]
	at org.bukkit.craftbukkit.v1_18_R2.CraftWorld.addEntityToWorld(CraftWorld.java:1063) ~[paper-1.18.2.jar:git-Paper-317]
	at org.bukkit.craftbukkit.v1_18_R2.CraftRegionAccessor.addEntity(CraftRegionAccessor.java:523) ~[paper-1.18.2.jar:git-Paper-317]
	at org.bukkit.craftbukkit.v1_18_R2.CraftRegionAccessor.spawn(CraftRegionAccessor.java:499) ~[paper-1.18.2.jar:git-Paper-317]
	at org.bukkit.craftbukkit.v1_18_R2.CraftRegionAccessor.spawn(CraftRegionAccessor.java:493) ~[paper-1.18.2.jar:git-Paper-317]
	at org.bukkit.craftbukkit.v1_18_R2.CraftRegionAccessor.spawn(CraftRegionAccessor.java:484) ~[paper-1.18.2.jar:git-Paper-317]
        [snip]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.