43 lines
1.1 KiB
Java
43 lines
1.1 KiB
Java
![]() |
package net.pivipi.ball;
|
||
|
|
||
|
import net.minestom.server.entity.Entity;
|
||
|
import net.minestom.server.entity.EntityType;
|
||
|
import net.minestom.server.entity.metadata.other.FallingBlockMeta;
|
||
|
import net.minestom.server.instance.block.Block;
|
||
|
import net.pivipi.physics.Physics;
|
||
|
|
||
|
public class Ball extends Entity {
|
||
|
private long lastTick;
|
||
|
private final Physics physics = new Physics(this);
|
||
|
|
||
|
public Ball(Block block) {
|
||
|
super(EntityType.FALLING_BLOCK); // not block display because its movement lags for some reason
|
||
|
|
||
|
this.setBoundingBox(0.625, 0.625, 0.625);
|
||
|
this.setNoGravity(true);
|
||
|
this.setGlowing(true);
|
||
|
|
||
|
this.editEntityMeta(FallingBlockMeta.class, meta -> {
|
||
|
meta.setBlock(block);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
public Ball() {
|
||
|
this(Block.WHITE_WOOL);
|
||
|
}
|
||
|
|
||
|
|
||
|
public void tick(long time) { // I don't know if change that to update
|
||
|
if (this.lastTick == 0) {
|
||
|
this.lastTick = time;
|
||
|
}
|
||
|
|
||
|
long delay = time - this.lastTick;
|
||
|
|
||
|
physics.applyPhysics();
|
||
|
|
||
|
this.lastTick = time;
|
||
|
}
|
||
|
|
||
|
}
|