multimodal
This commit is contained in:
@@ -4,12 +4,13 @@
|
||||
|
||||
== Entity IDs
|
||||
|
||||
Entities are the dynamic movable objects in the game. Minecraft tracks every entity with a unique
|
||||
ID number. Whenever an entity is added to the game world, a global counter is incremented
|
||||
and the new entity is assigned the current value.
|
||||
Entities are the dynamic movable objects in the game. Minecraft tracks every entity with a unique ID
|
||||
number. Whenever an entity is added to the game world, a global counter is incremented and the new
|
||||
entity is assigned the current value.
|
||||
|
||||
A large number of game objects are tracked in this way, and so creating any one of them will increment that global
|
||||
counter. To reiterate, *this is a global counter, shared for all entities in the game*.
|
||||
A large number of game objects are tracked in this way, and so creating any one of them will
|
||||
increment that global counter. To reiterate, *this is a global counter, shared for all entities in
|
||||
the game*.
|
||||
|
||||
== Stationary Item Optimization
|
||||
|
||||
@@ -22,45 +23,28 @@ Here is the relevant code path for the optimization.
|
||||
#note[ `onGround` is only ever updated from `move()`, and this branch is the *only* place that
|
||||
`move()` is called. ]
|
||||
|
||||
```java
|
||||
public class ItemEntity extends Entity {
|
||||
public void tick() {
|
||||
...
|
||||
if (this.onGround() && !(this.getDeltaMovement().horizontalDistanceSqr() > (double)1.0E-5F) && (this.tickCount + this.getId()) % 4 != 0) {
|
||||
...
|
||||
} else {
|
||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||
...
|
||||
}
|
||||
...
|
||||
}
|
||||
}
|
||||
```java public class ItemEntity extends Entity { public void tick() { ... if (this.onGround() &&
|
||||
!(this.getDeltaMovement().horizontalDistanceSqr() > (double)1.0E-5F) && (this.tickCount +
|
||||
this.getId()) % 4 != 0) { ... } else { this.move(MoverType.SELF, this.getDeltaMovement()); ... } ...
|
||||
} }
|
||||
|
||||
public class Entity {
|
||||
public void move(final MoverType moverType, Vec3 delta) {
|
||||
...
|
||||
this.setOnGroundWithMovement(this.verticalCollisionBelow, this.horizontalCollision, movement);
|
||||
...
|
||||
}
|
||||
public class Entity { public void move(final MoverType moverType, Vec3 delta) { ...
|
||||
this.setOnGroundWithMovement(this.verticalCollisionBelow, this.horizontalCollision, movement); ... }
|
||||
|
||||
public void setOnGroundWithMovement(final boolean onGround, final boolean horizontalCollision, final Vec3 movement) {
|
||||
this.onGround = onGround;
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
public void setOnGroundWithMovement(final boolean onGround, final boolean horizontalCollision,
|
||||
final Vec3 movement) { this.onGround = onGround; ... } } ```
|
||||
|
||||
== Observable Drop Delay
|
||||
|
||||
The effect is that if the item is on a block and has negligible horizontal momentum, it *cannot
|
||||
fall* until the condition is satisfied, even if it's no longer on the ground. It can fall early if
|
||||
it gains horizontal momentum or is pushed.
|
||||
fall* until the condition is satisfied, even if it's no longer on the ground. It can only fall early
|
||||
if it gains horizontal momentum or is pushed.
|
||||
|
||||
#tip[ You can rewrite the condition as `(age % 4 == (-id) % 4)` ]
|
||||
|
||||
#todo[ An animation. Spawn a few items, note their ID and age. Let them settle on a block,
|
||||
then remove that supporting block. There will be a few ticks where the item hovers in place before
|
||||
it falls. ]
|
||||
#todo[ An animation. Spawn a few items, note their ID and age. Let them settle on a block, then
|
||||
remove that supporting block. There will be a few ticks where the item hovers in place before it
|
||||
falls. ]
|
||||
|
||||
For simplicity, suppose we spawn all our items on the same tick. Then `this.tickCount` will be the
|
||||
same for all of them, and we only need to consider the ID.
|
||||
|
||||
Reference in New Issue
Block a user