尝试修改迫击炮为一般Entity

This commit is contained in:
Atsuihsio 2024-10-31 12:33:30 +08:00
parent 8b2492ff23
commit 6492ec5952
4 changed files with 153 additions and 115 deletions

View file

@ -2,6 +2,7 @@ package net.mcreator.superbwarfare.client.renderer.entity;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis;
import net.mcreator.superbwarfare.entity.MortarEntity; import net.mcreator.superbwarfare.entity.MortarEntity;
import net.mcreator.superbwarfare.entity.layer.MortarLayer; import net.mcreator.superbwarfare.entity.layer.MortarLayer;
import net.mcreator.superbwarfare.entity.model.MortarModel; import net.mcreator.superbwarfare.entity.model.MortarModel;
@ -9,6 +10,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import software.bernie.geckolib.cache.object.BakedGeoModel; import software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.renderer.GeoEntityRenderer; import software.bernie.geckolib.renderer.GeoEntityRenderer;
@ -33,6 +35,14 @@ public class MortarRenderer extends GeoEntityRenderer<MortarEntity> {
super.preRender(poseStack, entity, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha); super.preRender(poseStack, entity, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha);
} }
@Override
public void render(MortarEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) {
poseStack.pushPose();
poseStack.mulPose(Axis.YP.rotationDegrees(-Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot())));
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
poseStack.popPose();
}
@Override @Override
protected float getDeathMaxRotation(MortarEntity entityLivingBaseIn) { protected float getDeathMaxRotation(MortarEntity entityLivingBaseIn) {
return 0.0F; return 0.0F;

View file

@ -8,13 +8,13 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
@ -22,15 +22,11 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.*; import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.ThrownPotion; import net.minecraft.world.entity.projectile.ThrownPotion;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.network.PlayMessages; import net.minecraftforge.network.PlayMessages;
import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.animatable.GeoEntity;
@ -42,7 +38,7 @@ import software.bernie.geckolib.core.animation.RawAnimation;
import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.core.object.PlayState;
import software.bernie.geckolib.util.GeckoLibUtil; import software.bernie.geckolib.util.GeckoLibUtil;
public class MortarEntity extends LivingEntity implements GeoEntity, AnimatedEntity { public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity {
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.STRING); public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.STRING);
public static final EntityDataAccessor<Integer> FIRE_TIME = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.INT); public static final EntityDataAccessor<Integer> FIRE_TIME = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Float> PITCH = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor<Float> PITCH = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.FLOAT);
@ -64,14 +60,14 @@ public class MortarEntity extends LivingEntity implements GeoEntity, AnimatedEnt
@Override @Override
protected void defineSynchedData() { protected void defineSynchedData() {
super.defineSynchedData();
this.entityData.define(ANIMATION, "undefined"); this.entityData.define(ANIMATION, "undefined");
this.entityData.define(FIRE_TIME, 0); this.entityData.define(FIRE_TIME, 0);
this.entityData.define(PITCH, 70f); this.entityData.define(PITCH, 70f);
} }
@Override @Override
protected float getStandingEyeHeight(Pose poseIn, EntityDimensions sizeIn) { protected float getEyeHeight(Pose pPose, EntityDimensions pSize) {
return 0.2F; return 0.2F;
} }
@ -80,35 +76,16 @@ public class MortarEntity extends LivingEntity implements GeoEntity, AnimatedEnt
return NetworkHooks.getEntitySpawningPacket(this); return NetworkHooks.getEntitySpawningPacket(this);
} }
@Override
public MobType getMobType() {
return super.getMobType();
}
@Override @Override
public Iterable<ItemStack> getArmorSlots() { public Iterable<ItemStack> getArmorSlots() {
return NonNullList.withSize(1, ItemStack.EMPTY); return NonNullList.withSize(1, ItemStack.EMPTY);
} }
@Override
public ItemStack getItemBySlot(EquipmentSlot pSlot) {
return ItemStack.EMPTY;
}
@Override @Override
public void setItemSlot(EquipmentSlot pSlot, ItemStack pStack) { public void setItemSlot(EquipmentSlot pSlot, ItemStack pStack) {
} }
@Override
public SoundEvent getHurtSound(DamageSource ds) {
return ModSounds.HIT.get();
}
@Override
public SoundEvent getDeathSound() {
return ModSounds.HIT.get();
}
@Override @Override
public boolean hurt(DamageSource source, float amount) { public boolean hurt(DamageSource source, float amount) {
if (source.is(DamageTypes.IN_FIRE)) if (source.is(DamageTypes.IN_FIRE))
@ -136,14 +113,12 @@ public class MortarEntity extends LivingEntity implements GeoEntity, AnimatedEnt
@Override @Override
public void addAdditionalSaveData(CompoundTag compound) { public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putInt("FireTime", this.entityData.get(FIRE_TIME)); compound.putInt("FireTime", this.entityData.get(FIRE_TIME));
compound.putFloat("Pitch", this.entityData.get(PITCH)); compound.putFloat("Pitch", this.entityData.get(PITCH));
} }
@Override @Override
public void readAdditionalSaveData(CompoundTag compound) { public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
if (compound.contains("FireTime")) { if (compound.contains("FireTime")) {
this.entityData.set(FIRE_TIME, compound.getInt("FireTime")); this.entityData.set(FIRE_TIME, compound.getInt("FireTime"));
} }
@ -153,50 +128,96 @@ public class MortarEntity extends LivingEntity implements GeoEntity, AnimatedEnt
} }
@Override @Override
public InteractionResult interact(Player player, InteractionHand hand) { public InteractionResult interactAt(Player player, Vec3 pVec, InteractionHand pHand) {
ItemStack mainHandItem = player.getMainHandItem();
if (player.isShiftKeyDown()) {
if (mainHandItem.getItem() == ModItems.CROWBAR.get()){
this.discard();
ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.MORTAR_DEPLOYER.get()));
}
this.setYRot(player.getYRot());
this.setXRot(this.getXRot());
this.setYBodyRot(this.getYRot());
this.setYHeadRot(this.getYRot());
this.yRotO = this.getYRot();
this.xRotO = this.getXRot();
this.yBodyRotO = this.getYRot();
this.yHeadRotO = this.getYRot();
}
if (mainHandItem.getItem() == ModItems.MORTAR_SHELLS.get() && !player.isShiftKeyDown() && this.entityData.get(FIRE_TIME) == 0) {
this.entityData.set(FIRE_TIME, 25);
if (!player.isCreative()) { player.displayClientMessage(Component.literal("114"), true);
player.getInventory().clearOrCountMatchingItems(p -> ModItems.MORTAR_SHELLS.get() == p.getItem(), 1, player.inventoryMenu.getCraftSlots()); if (!this.level().isClientSide) {
} ItemStack mainHandItem = player.getMainHandItem();
if (!this.level().isClientSide()) { if (mainHandItem.getItem() == ModItems.MORTAR_SHELLS.get() && !player.isShiftKeyDown() && this.entityData.get(FIRE_TIME) == 0) {
this.level().playSound(null, this.getX(), this.getY(), this.getZ(), ModSounds.MORTAR_LOAD.get(), SoundSource.PLAYERS, 1f, 1f); this.entityData.set(FIRE_TIME, 25);
this.level().playSound(null, this.getX(), this.getY(), this.getZ(), ModSounds.MORTAR_FIRE.get(), SoundSource.PLAYERS, 8f, 1f);
this.level().playSound(null, this.getX(), this.getY(), this.getZ(), ModSounds.MORTAR_DISTANT.get(), SoundSource.PLAYERS, 32f, 1f); if (!player.isCreative()) {
} player.getInventory().clearOrCountMatchingItems(p -> ModItems.MORTAR_SHELLS.get() == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
ModUtils.queueServerWork(20, () -> {
Level level = this.level();
if (level instanceof ServerLevel server) {
MortarShellEntity entityToSpawn = new MortarShellEntity(ModEntities.MORTAR_SHELL.get(), player, level);
entityToSpawn.setPos(this.getX(), this.getEyeY(), this.getZ());
entityToSpawn.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 8, (float) 0.5);
level.addFreshEntity(entityToSpawn);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (this.getX() + 3 * this.getLookAngle().x), (this.getY() + 0.1 + 3 * this.getLookAngle().y), (this.getZ() + 3 * this.getLookAngle().z), 8, 0.4, 0.4, 0.4,
0.007);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY(), this.getZ(), 50, 2, 0.02, 2, 0.0005);
} }
}); if (!this.level().isClientSide()) {
this.level().playSound(null, this.getX(), this.getY(), this.getZ(), ModSounds.MORTAR_LOAD.get(), SoundSource.PLAYERS, 1f, 1f);
this.level().playSound(null, this.getX(), this.getY(), this.getZ(), ModSounds.MORTAR_FIRE.get(), SoundSource.PLAYERS, 8f, 1f);
this.level().playSound(null, this.getX(), this.getY(), this.getZ(), ModSounds.MORTAR_DISTANT.get(), SoundSource.PLAYERS, 32f, 1f);
}
ModUtils.queueServerWork(20, () -> {
Level level = this.level();
if (level instanceof ServerLevel server) {
MortarShellEntity entityToSpawn = new MortarShellEntity(ModEntities.MORTAR_SHELL.get(), player, level);
entityToSpawn.setPos(this.getX(), this.getEyeY(), this.getZ());
entityToSpawn.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 8, (float) 0.5);
level.addFreshEntity(entityToSpawn);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (this.getX() + 3 * this.getLookAngle().x), (this.getY() + 0.1 + 3 * this.getLookAngle().y), (this.getZ() + 3 * this.getLookAngle().z), 8, 0.4, 0.4, 0.4,
0.007);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY(), this.getZ(), 50, 2, 0.02, 2, 0.0005);
}
});
}
} }
return InteractionResult.SUCCESS;
return InteractionResult.sidedSuccess(this.level().isClientSide()); // return InteractionResult.sidedSuccess(this.level().isClientSide());
} }
// @Override
// public InteractionResult interact(Player player, InteractionHand pHand) {
// super.interact(player, pHand);
// player.displayClientMessage(Component.literal("114"), true);
// if (!this.level().isClientSide) {
// ItemStack mainHandItem = player.getMainHandItem();
// if (mainHandItem.getItem() == ModItems.MORTAR_SHELLS.get() && !player.isShiftKeyDown() && this.entityData.get(FIRE_TIME) == 0) {
// this.entityData.set(FIRE_TIME, 25);
//
// if (!player.isCreative()) {
// player.getInventory().clearOrCountMatchingItems(p -> ModItems.MORTAR_SHELLS.get() == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
// }
// if (!this.level().isClientSide()) {
// this.level().playSound(null, this.getX(), this.getY(), this.getZ(), ModSounds.MORTAR_LOAD.get(), SoundSource.PLAYERS, 1f, 1f);
// this.level().playSound(null, this.getX(), this.getY(), this.getZ(), ModSounds.MORTAR_FIRE.get(), SoundSource.PLAYERS, 8f, 1f);
// this.level().playSound(null, this.getX(), this.getY(), this.getZ(), ModSounds.MORTAR_DISTANT.get(), SoundSource.PLAYERS, 32f, 1f);
// }
// ModUtils.queueServerWork(20, () -> {
// Level level = this.level();
// if (level instanceof ServerLevel server) {
// MortarShellEntity entityToSpawn = new MortarShellEntity(ModEntities.MORTAR_SHELL.get(), player, level);
// entityToSpawn.setPos(this.getX(), this.getEyeY(), this.getZ());
// entityToSpawn.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 8, (float) 0.5);
// level.addFreshEntity(entityToSpawn);
// server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (this.getX() + 3 * this.getLookAngle().x), (this.getY() + 0.1 + 3 * this.getLookAngle().y), (this.getZ() + 3 * this.getLookAngle().z), 8, 0.4, 0.4, 0.4,
// 0.007);
// server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY(), this.getZ(), 50, 2, 0.02, 2, 0.0005);
// }
// });
// }
// }
// return InteractionResult.sidedSuccess(this.level().isClientSide());
// }
// @Override
// public InteractionResult interact(Player player, InteractionHand hand) {
// ItemStack mainHandItem = player.getMainHandItem();
// if (player.isShiftKeyDown()) {
// if (mainHandItem.getItem() == ModItems.CROWBAR.get()){
// this.discard();
// ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.MORTAR_DEPLOYER.get()));
// }
// this.setYRot(player.getYRot());
// this.setXRot(this.getXRot());
// this.setYBodyRot(this.getYRot());
// this.setYHeadRot(this.getYRot());
// this.yRotO = this.getYRot();
// this.xRotO = this.getXRot();
//// this.yBodyRotO = this.getYRot();
//// this.yHeadRotO = this.getYRot();
// }
//
//
// return InteractionResult.sidedSuccess(this.level().isClientSide());
// }
@Override @Override
public void lerpTo(double x, double y, double z, float yaw, float pitch, int interpolationSteps, boolean interpolate) { public void lerpTo(double x, double y, double z, float yaw, float pitch, int interpolationSteps, boolean interpolate) {
serverYRot = yaw; serverYRot = yaw;
@ -204,10 +225,15 @@ public class MortarEntity extends LivingEntity implements GeoEntity, AnimatedEnt
this.interpolationSteps = 10; this.interpolationSteps = 10;
} }
@Override // @Override
public void travel(Vec3 dir) { // protected void setRot(float pYRot, float pXRot) {
this.setXRot(-Mth.clamp((float) entityData.get(PITCH), 20, 89)); // super.setRot(pYRot, -Mth.clamp(entityData.get(PITCH), 20, 89));
} // }
// @Override
// public void travel(Vec3 dir) {
// this.setXRot(-Mth.clamp((float) entityData.get(PITCH), 20, 89));
// }
@Override @Override
public void baseTick() { public void baseTick() {
@ -215,6 +241,8 @@ public class MortarEntity extends LivingEntity implements GeoEntity, AnimatedEnt
if (this.entityData.get(FIRE_TIME) > 0) { if (this.entityData.get(FIRE_TIME) > 0) {
this.entityData.set(FIRE_TIME, this.entityData.get(FIRE_TIME) - 1); this.entityData.set(FIRE_TIME, this.entityData.get(FIRE_TIME) - 1);
} }
this.setXRot(-Mth.clamp(entityData.get(PITCH), 20, 89));
this.xRotO = this.getXRot();
this.refreshDimensions(); this.refreshDimensions();
} }
@ -223,28 +251,28 @@ public class MortarEntity extends LivingEntity implements GeoEntity, AnimatedEnt
return false; return false;
} }
@Override // @Override
public HumanoidArm getMainArm() { // public HumanoidArm getMainArm() {
return HumanoidArm.RIGHT; // return HumanoidArm.RIGHT;
} // }
//
// @Override
// protected void doPush(Entity entityIn) {
// }
//
// @Override
// protected void pushEntities() {
// }
@Override // public static AttributeSupplier.Builder createAttributes() {
protected void doPush(Entity entityIn) { // return Mob.createMobAttributes()
} // .add(Attributes.MOVEMENT_SPEED, 0)
// .add(Attributes.MAX_HEALTH, 100)
@Override // .add(Attributes.ARMOR, 0)
protected void pushEntities() { // .add(Attributes.ATTACK_DAMAGE, 0)
} // .add(Attributes.FOLLOW_RANGE, 16)
// .add(Attributes.KNOCKBACK_RESISTANCE, 1);
public static AttributeSupplier.Builder createAttributes() { // }
return Mob.createMobAttributes()
.add(Attributes.MOVEMENT_SPEED, 0)
.add(Attributes.MAX_HEALTH, 100)
.add(Attributes.ARMOR, 0)
.add(Attributes.ATTACK_DAMAGE, 0)
.add(Attributes.FOLLOW_RANGE, 16)
.add(Attributes.KNOCKBACK_RESISTANCE, 1);
}
private PlayState movementPredicate(AnimationState<MortarEntity> event) { private PlayState movementPredicate(AnimationState<MortarEntity> event) {
if (this.animationProcedure.equals("empty")) { if (this.animationProcedure.equals("empty")) {
@ -256,23 +284,23 @@ public class MortarEntity extends LivingEntity implements GeoEntity, AnimatedEnt
return PlayState.STOP; return PlayState.STOP;
} }
@Override // @Override
protected void tickDeath() { // protected void tickDeath() {
++this.deathTime; // ++this.deathTime;
if (this.deathTime == 5) { // if (this.deathTime == 5) {
this.remove(MortarEntity.RemovalReason.KILLED); // this.remove(MortarEntity.RemovalReason.KILLED);
this.dropExperience(); // this.dropExperience();
if (this.level() instanceof ServerLevel level) { // if (this.level() instanceof ServerLevel level) {
var x = this.getX(); // var x = this.getX();
var y = this.getY(); // var y = this.getY();
var z = this.getZ(); // var z = this.getZ();
level.explode(null, x, y, z, 0, Level.ExplosionInteraction.NONE); // level.explode(null, x, y, z, 0, Level.ExplosionInteraction.NONE);
ItemEntity mortar = new ItemEntity(level, x, (y + 1), z, new ItemStack(ModItems.MORTAR_DEPLOYER.get())); // ItemEntity mortar = new ItemEntity(level, x, (y + 1), z, new ItemStack(ModItems.MORTAR_DEPLOYER.get()));
mortar.setPickUpDelay(10); // mortar.setPickUpDelay(10);
level.addFreshEntity(mortar); // level.addFreshEntity(mortar);
} // }
} // }
} // }
@Override @Override
public Vec3 getDeltaMovement() { public Vec3 getDeltaMovement() {

View file

@ -70,7 +70,7 @@ public class ModEntities {
@SubscribeEvent @SubscribeEvent
public static void registerAttributes(EntityAttributeCreationEvent event) { public static void registerAttributes(EntityAttributeCreationEvent event) {
event.put(TARGET.get(), TargetEntity.createAttributes().build()); event.put(TARGET.get(), TargetEntity.createAttributes().build());
event.put(MORTAR.get(), MortarEntity.createAttributes().build()); // event.put(MORTAR.get(), MortarEntity.createAttributes().build());
event.put(SENPAI.get(), SenpaiEntity.createAttributes().build()); event.put(SENPAI.get(), SenpaiEntity.createAttributes().build());
event.put(MK_42.get(), Mk42Entity.createAttributes().build()); event.put(MK_42.get(), Mk42Entity.createAttributes().build());
event.put(DRONE.get(), DroneEntity.createAttributes().build()); event.put(DRONE.get(), DroneEntity.createAttributes().build());

View file

@ -1,6 +1,7 @@
package net.mcreator.superbwarfare.network.message; package net.mcreator.superbwarfare.network.message;
import net.mcreator.superbwarfare.client.gui.RangeHelper; import net.mcreator.superbwarfare.client.gui.RangeHelper;
import net.mcreator.superbwarfare.entity.MortarEntity;
import net.mcreator.superbwarfare.init.ModSounds; import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.tools.SoundTool; import net.mcreator.superbwarfare.tools.SoundTool;
import net.mcreator.superbwarfare.tools.TraceTool; import net.mcreator.superbwarfare.tools.TraceTool;
@ -9,7 +10,6 @@ import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.network.NetworkEvent; import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -43,9 +43,9 @@ public class AdjustMortarAngleMessage {
double angle = 0; double angle = 0;
if (looking instanceof LivingEntity living){ if (looking instanceof MortarEntity mortar){
living.getEntityData().set(PITCH, (float)Mth.clamp(living.getEntityData().get(PITCH) + 0.5 * message.scroll,20,89)); mortar.getEntityData().set(PITCH, (float)Mth.clamp(mortar.getEntityData().get(PITCH) + 0.5 * message.scroll,20,89));
angle = living.getEntityData().get(PITCH); angle = mortar.getEntityData().get(PITCH);
} }
player.displayClientMessage(Component.literal("Angle:" + new java.text.DecimalFormat("##.##").format(angle) + " Range:" + new java.text.DecimalFormat("##.#").format((int) RangeHelper.getRange(angle)) + "M"), true); player.displayClientMessage(Component.literal("Angle:" + new java.text.DecimalFormat("##.##").format(angle) + " Range:" + new java.text.DecimalFormat("##.#").format((int) RangeHelper.getRange(angle)) + "M"), true);