2021-02-23 18:02:23 +01:00
|
|
|
package com.minelittlepony.unicopia.entity;
|
|
|
|
|
|
|
|
import net.minecraft.entity.ItemEntity;
|
|
|
|
|
2021-03-04 21:35:49 +01:00
|
|
|
class ItemPhysics extends EntityPhysics<ItemEntity> {
|
|
|
|
public ItemPhysics(ItemEntity entity) {
|
|
|
|
super(entity, ItemImpl.ITEM_GRAVITY, false);
|
2021-02-23 18:02:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void tick() {
|
|
|
|
super.tick();
|
|
|
|
|
2021-03-04 21:35:49 +01:00
|
|
|
if (isGravityNegative() && !entity.getStack().isEmpty()) {
|
|
|
|
entity.setNoGravity(true);
|
|
|
|
entity.addVelocity(
|
2021-02-23 18:02:23 +01:00
|
|
|
0,
|
|
|
|
0.04
|
|
|
|
+ calcGravity(-0.04D), // apply our own
|
|
|
|
0
|
|
|
|
);
|
|
|
|
|
2021-03-04 21:35:49 +01:00
|
|
|
if (!entity.isOnGround()
|
2021-08-04 15:38:03 +02:00
|
|
|
|| entity.getVelocity().horizontalLengthSquared() > 9.999999747378752E-6D) {
|
2021-02-23 18:02:23 +01:00
|
|
|
|
|
|
|
float above = 0.98f;
|
2021-03-04 21:35:49 +01:00
|
|
|
if (entity.verticalCollision) {
|
|
|
|
above *= entity.world.getBlockState(entity.getBlockPos().up()).getBlock().getSlipperiness();
|
2021-02-23 18:02:23 +01:00
|
|
|
//above /= 9;
|
|
|
|
}
|
|
|
|
|
2021-03-04 21:35:49 +01:00
|
|
|
entity.setVelocity(entity.getVelocity().multiply(above, 1, above));
|
2021-02-23 18:02:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onGravitychanged() {
|
2021-03-04 21:35:49 +01:00
|
|
|
if (!entity.world.isClient) {
|
2021-02-23 18:02:23 +01:00
|
|
|
float gravity = this.getBaseGravityModifier();
|
|
|
|
setBaseGravityModifier(gravity == 0 ? 1 : gravity * 2);
|
|
|
|
setBaseGravityModifier(gravity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|