mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +01:00
Fixed muffins and rocks appearing invisible when thrown
This commit is contained in:
parent
2422938dab
commit
d54d644146
3 changed files with 17 additions and 10 deletions
|
@ -19,8 +19,8 @@ public class HeavyProjectileItem extends ProjectileItem {
|
|||
@Override
|
||||
public PhysicsBodyProjectileEntity createProjectile(ItemStack stack, World world, @Nullable PlayerEntity player) {
|
||||
PhysicsBodyProjectileEntity projectile = player == null
|
||||
? new PhysicsBodyProjectileEntity(world, stack.copyWithCount(1))
|
||||
: new PhysicsBodyProjectileEntity(world, player, stack.copyWithCount(1));
|
||||
? new PhysicsBodyProjectileEntity(world, stack)
|
||||
: new PhysicsBodyProjectileEntity(world, player, stack);
|
||||
if (player != null) {
|
||||
projectile.setVelocity(player, player.getPitch(), player.getYaw(), 0, 1.5F, 1);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
|||
|
||||
public PhysicsBodyProjectileEntity(EntityType<PhysicsBodyProjectileEntity> type, World world, ItemStack stack) {
|
||||
super(type, world, stack);
|
||||
setStack(stack);
|
||||
}
|
||||
|
||||
public PhysicsBodyProjectileEntity(World world, ItemStack stack) {
|
||||
|
@ -65,6 +66,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
|||
|
||||
public PhysicsBodyProjectileEntity(World world, @Nullable LivingEntity thrower, ItemStack stack) {
|
||||
super(UEntities.MUFFIN, thrower, world, stack);
|
||||
setStack(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,7 +77,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
|||
}
|
||||
|
||||
public void setStack(ItemStack stack) {
|
||||
getDataTracker().set(ITEM, stack);
|
||||
getDataTracker().set(ITEM, stack.copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,6 +91,11 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
|||
|
||||
@Override
|
||||
protected ItemStack asItemStack() {
|
||||
return getStack().copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return getStack();
|
||||
}
|
||||
|
||||
|
@ -273,7 +280,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
|||
super.writeCustomDataToNbt(nbt);
|
||||
ItemStack stack = getStack();
|
||||
if (!stack.isEmpty()) {
|
||||
nbt.put("Item", stack.writeNbt(new NbtCompound()));
|
||||
nbt.put("item", stack.writeNbt(new NbtCompound()));
|
||||
}
|
||||
nbt.putString("damageType", damageType.getValue().toString());
|
||||
}
|
||||
|
@ -281,7 +288,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
|||
@Override
|
||||
public void readCustomDataFromNbt(NbtCompound nbt) {
|
||||
super.readCustomDataFromNbt(nbt);
|
||||
setStack(ItemStack.fromNbt(nbt.getCompound("Item")));
|
||||
setStack(ItemStack.fromNbt(nbt.getCompound("item")));
|
||||
if (nbt.contains("damageType", NbtElement.STRING_TYPE)) {
|
||||
Optional.ofNullable(Identifier.tryParse(nbt.getString("damageType"))).ifPresent(id -> {
|
||||
setDamageType(RegistryKey.of(RegistryKeys.DAMAGE_TYPE, id));
|
||||
|
|
|
@ -38,12 +38,12 @@ public interface Projectile extends ItemConvertible {
|
|||
default TypedActionResult<ItemStack> triggerThrow(World world, PlayerEntity player, Hand hand) {
|
||||
ItemStack stack = player.getStackInHand(hand);
|
||||
|
||||
if (!world.isClient) {
|
||||
SoundEmitter.playSoundAt(player,
|
||||
getThrowSound(stack), SoundCategory.NEUTRAL,
|
||||
0.5F,
|
||||
0.4F / (world.random.nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if (!world.isClient) {
|
||||
world.spawnEntity(createProjectile(stack.copyWithCount(1), world, player));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue