2021-02-23 18:02:23 +01:00
|
|
|
package com.minelittlepony.unicopia.entity;
|
|
|
|
|
2024-05-20 21:56:44 +02:00
|
|
|
import com.minelittlepony.unicopia.network.track.DataTracker;
|
|
|
|
|
2021-02-23 18:02:23 +01:00
|
|
|
import net.minecraft.entity.ItemEntity;
|
|
|
|
|
2021-03-04 21:35:49 +01:00
|
|
|
class ItemPhysics extends EntityPhysics<ItemEntity> {
|
2024-05-20 21:56:44 +02:00
|
|
|
public ItemPhysics(ItemEntity entity, DataTracker tracker) {
|
|
|
|
super(entity, tracker);
|
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) {
|
2023-06-03 13:40:54 +02:00
|
|
|
above *= entity.getWorld().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() {
|
2023-06-03 13:40:54 +02:00
|
|
|
if (!entity.getWorld().isClient) {
|
|
|
|
float gravity = getBaseGravityModifier();
|
2021-02-23 18:02:23 +01:00
|
|
|
setBaseGravityModifier(gravity == 0 ? 1 : gravity * 2);
|
|
|
|
setBaseGravityModifier(gravity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|