mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-24 05:47:59 +01:00
Merge branch '1.20.4' into 1.21
# Conflicts: # src/main/java/com/minelittlepony/unicopia/projectile/PhysicsBodyProjectileEntity.java
This commit is contained in:
commit
58c342442d
3 changed files with 15 additions and 10 deletions
|
@ -20,8 +20,8 @@ public class HeavyProjectileItem extends ProjectileItem {
|
||||||
@Override
|
@Override
|
||||||
public PhysicsBodyProjectileEntity createProjectile(ItemStack stack, World world, @Nullable PlayerEntity player) {
|
public PhysicsBodyProjectileEntity createProjectile(ItemStack stack, World world, @Nullable PlayerEntity player) {
|
||||||
PhysicsBodyProjectileEntity projectile = player == null
|
PhysicsBodyProjectileEntity projectile = player == null
|
||||||
? new PhysicsBodyProjectileEntity(world, stack.copyWithCount(1))
|
? new PhysicsBodyProjectileEntity(world, stack)
|
||||||
: new PhysicsBodyProjectileEntity(world, player, stack.copyWithCount(1));
|
: new PhysicsBodyProjectileEntity(world, player, stack);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
projectile.setVelocity(player, player.getPitch(), player.getYaw(), 0, 1.5F, 1);
|
projectile.setVelocity(player, player.getPitch(), player.getYaw(), 0, 1.5F, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStack(ItemStack stack) {
|
public void setStack(ItemStack stack) {
|
||||||
getDataTracker().set(ITEM, stack);
|
getDataTracker().set(ITEM, stack.isEmpty() ? getDefaultItemStack() : stack.copy());
|
||||||
super.setStack(stack);
|
super.setStack(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,11 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack asItemStack() {
|
protected ItemStack asItemStack() {
|
||||||
|
return getStack().copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItemStack() {
|
||||||
return getStack();
|
return getStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +296,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
||||||
super.writeCustomDataToNbt(nbt);
|
super.writeCustomDataToNbt(nbt);
|
||||||
ItemStack stack = getStack();
|
ItemStack stack = getStack();
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
ItemStack.CODEC.encodeStart(NbtOps.INSTANCE, stack).result().ifPresent(item -> nbt.put("Item", item));
|
ItemStack.CODEC.encodeStart(NbtOps.INSTANCE, stack).result().ifPresent(item -> nbt.put("item", item));
|
||||||
}
|
}
|
||||||
nbt.putString("damageType", damageType.getValue().toString());
|
nbt.putString("damageType", damageType.getValue().toString());
|
||||||
}
|
}
|
||||||
|
@ -299,7 +304,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
||||||
@Override
|
@Override
|
||||||
public void readCustomDataFromNbt(NbtCompound nbt) {
|
public void readCustomDataFromNbt(NbtCompound nbt) {
|
||||||
super.readCustomDataFromNbt(nbt);
|
super.readCustomDataFromNbt(nbt);
|
||||||
setStack(ItemStack.fromNbtOrEmpty(getRegistryManager(), nbt.getCompound("Item")));
|
setStack(ItemStack.fromNbtOrEmpty(getRegistryManager(), nbt.getCompound("item")));
|
||||||
if (nbt.contains("damageType", NbtElement.STRING_TYPE)) {
|
if (nbt.contains("damageType", NbtElement.STRING_TYPE)) {
|
||||||
Optional.ofNullable(Identifier.tryParse(nbt.getString("damageType"))).ifPresent(id -> {
|
Optional.ofNullable(Identifier.tryParse(nbt.getString("damageType"))).ifPresent(id -> {
|
||||||
setDamageType(RegistryKey.of(RegistryKeys.DAMAGE_TYPE, id));
|
setDamageType(RegistryKey.of(RegistryKeys.DAMAGE_TYPE, id));
|
||||||
|
|
|
@ -43,12 +43,12 @@ public interface Projectile extends ItemConvertible, ProjectileItem {
|
||||||
default TypedActionResult<ItemStack> triggerThrow(World world, PlayerEntity player, Hand hand) {
|
default TypedActionResult<ItemStack> triggerThrow(World world, PlayerEntity player, Hand hand) {
|
||||||
ItemStack stack = player.getStackInHand(hand);
|
ItemStack stack = player.getStackInHand(hand);
|
||||||
|
|
||||||
|
if (!world.isClient) {
|
||||||
SoundEmitter.playSoundAt(player,
|
SoundEmitter.playSoundAt(player,
|
||||||
getThrowSound(stack), SoundCategory.NEUTRAL,
|
getThrowSound(stack), SoundCategory.NEUTRAL,
|
||||||
0.5F,
|
0.5F,
|
||||||
0.4F / (world.random.nextFloat() * 0.4F + 0.8F));
|
0.4F / (world.random.nextFloat() * 0.4F + 0.8F));
|
||||||
|
|
||||||
if (!world.isClient) {
|
|
||||||
world.spawnEntity(createProjectile(stack.copyWithCount(1), world, player));
|
world.spawnEntity(createProjectile(stack.copyWithCount(1), world, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue