mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-24 13:57:59 +01:00
Muffins now float in water, as they should
This commit is contained in:
parent
448df32720
commit
a878fd0d6c
1 changed files with 25 additions and 0 deletions
|
@ -13,6 +13,7 @@ import net.minecraft.entity.MovementType;
|
||||||
import net.minecraft.entity.data.DataTracker;
|
import net.minecraft.entity.data.DataTracker;
|
||||||
import net.minecraft.entity.data.TrackedData;
|
import net.minecraft.entity.data.TrackedData;
|
||||||
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.projectile.PersistentProjectileEntity;
|
import net.minecraft.entity.projectile.PersistentProjectileEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
@ -32,6 +33,8 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
||||||
private static final TrackedData<ItemStack> ITEM = DataTracker.registerData(PhysicsBodyProjectileEntity.class, TrackedDataHandlerRegistry.ITEM_STACK);
|
private static final TrackedData<ItemStack> ITEM = DataTracker.registerData(PhysicsBodyProjectileEntity.class, TrackedDataHandlerRegistry.ITEM_STACK);
|
||||||
private static final TrackedData<Boolean> BOUNCY = DataTracker.registerData(PhysicsBodyProjectileEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
|
private static final TrackedData<Boolean> BOUNCY = DataTracker.registerData(PhysicsBodyProjectileEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||||
|
|
||||||
|
private int inWaterTime;
|
||||||
|
|
||||||
public PhysicsBodyProjectileEntity(EntityType<PhysicsBodyProjectileEntity> type, World world) {
|
public PhysicsBodyProjectileEntity(EntityType<PhysicsBodyProjectileEntity> type, World world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
}
|
}
|
||||||
|
@ -85,6 +88,28 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
||||||
setVelocity(vel.multiply(0.3));
|
setVelocity(vel.multiply(0.3));
|
||||||
addVelocity(0, -0.025, 0);
|
addVelocity(0, -0.025, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isBouncy() && isInsideWaterOrBubbleColumn()) {
|
||||||
|
setVelocity(getVelocity().multiply(0.3).add(0, 0.05125, 0));
|
||||||
|
inWaterTime++;
|
||||||
|
} else {
|
||||||
|
inWaterTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerCollision(PlayerEntity player) {
|
||||||
|
|
||||||
|
if (world.isClient || isNoClip() || shake > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inWaterTime <= 0) {
|
||||||
|
super.onPlayerCollision(player);
|
||||||
|
} else if (tryPickup(player)) {
|
||||||
|
player.sendPickup(this, 1);
|
||||||
|
discard();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue