diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java index 6008b20ea..a8efd0aa4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java @@ -16,6 +16,7 @@ import software.bernie.geckolib.cache.object.BakedGeoModel; import software.bernie.geckolib.renderer.GeoEntityRenderer; public class Mle1934Renderer extends GeoEntityRenderer { + public Mle1934Renderer(EntityRendererProvider.Context renderManager) { super(renderManager, new Mle1934Model()); this.shadowRadius = 2f; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/CannonHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/CannonHudOverlay.java index d9de4f544..6be9e62ae 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/screens/CannonHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/CannonHudOverlay.java @@ -31,8 +31,10 @@ import java.text.DecimalFormat; @Mod.EventBusSubscriber(value = Dist.CLIENT) public class CannonHudOverlay { + public static float health = 0; public static float maxHealth = 0; + private static final ResourceLocation ARMOR = ModUtils.loc("textures/screens/armor.png"); private static final ResourceLocation HEALTH = ModUtils.loc("textures/screens/armor_value.png"); private static final ResourceLocation HEALTH_FRAME = ModUtils.loc("textures/screens/armor_value_frame.png"); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/DroneEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/DroneEntity.java index 66b910246..da80d5fc8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/DroneEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/DroneEntity.java @@ -59,6 +59,7 @@ import java.util.Objects; import java.util.UUID; public class DroneEntity extends LivingEntity implements GeoEntity { + public static final EntityDataAccessor LINKED = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.BOOLEAN); public static final EntityDataAccessor CONTROLLER = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.STRING); public static final EntityDataAccessor AMMO = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.INT); @@ -74,7 +75,6 @@ public class DroneEntity extends LivingEntity implements GeoEntity { private boolean move = false; public static double lastTickSpeed = 0; - public DroneEntity(PlayMessages.SpawnEntity packet, Level world) { this(ModEntities.DRONE.get(), world); } @@ -174,7 +174,6 @@ public class DroneEntity extends LivingEntity implements GeoEntity { this.entityData.set(ROT_Z, compound.getFloat("rotZ")); } - public Vector3f getForwardDirection() { return new Vector3f( Mth.sin(-getYRot() * ((float) Math.PI / 180)), @@ -183,7 +182,6 @@ public class DroneEntity extends LivingEntity implements GeoEntity { ).normalize(); } - public Vector3f getRightDirection() { return new Vector3f( Mth.cos(-getYRot() * ((float) Math.PI / 180)), @@ -521,7 +519,7 @@ public class DroneEntity extends LivingEntity implements GeoEntity { kamikazeExplosion(source.getEntity()); } - ItemStack stack = new ItemStack(ModItems.RGO_GRENADE.get(),this.entityData.get(AMMO)); + ItemStack stack = new ItemStack(ModItems.RGO_GRENADE.get(), this.entityData.get(AMMO)); if (this.level() instanceof ServerLevel level) { ItemEntity itemEntity = new ItemEntity(level, this.getX(), this.getY(), this.getZ(), stack); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/ICannonEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/ICannonEntity.java index 284996ca7..c15479c59 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/ICannonEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/ICannonEntity.java @@ -3,5 +3,6 @@ package com.atsuishio.superbwarfare.entity; import net.minecraft.world.entity.player.Player; public interface ICannonEntity { + void cannonShoot(Player player); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java index b396332e5..f99317bc4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java @@ -54,7 +54,9 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { public static final EntityDataAccessor COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); + public static final float MAX_HEALTH = CannonConfig.MK42_HP.get(); + protected int interpolationSteps; protected double serverYRot; protected double serverXRot; @@ -164,7 +166,7 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { if (player.isShiftKeyDown()) { if (player.getMainHandItem().is(ModItems.CROWBAR.get()) && this.getFirstPassenger() == null) { ItemStack stack = ContainerBlockItem.createInstance(this); - if (!player.addItem(stack)){ + if (!player.addItem(stack)) { player.drop(stack, false); } @@ -348,7 +350,7 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(20), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) { if (target instanceof ServerPlayer serverPlayer) { - ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(15,15,45, this.getX(), this.getEyeY(), this.getZ())); + ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(15, 15, 45, this.getX(), this.getEyeY(), this.getZ())); } } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java index dce3fcd6c..59f967e62 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java @@ -486,8 +486,6 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { this.clampRotation(entity); } - - private PlayState movementPredicate(AnimationState event) { if (this.entityData.get(COOL_DOWN) > 64) { if (this.entityData.get(TYPE) == 1) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/MortarEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/MortarEntity.java index 5dfa3ffcb..dcb5c938f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/MortarEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/MortarEntity.java @@ -46,6 +46,7 @@ import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity { + public static final EntityDataAccessor FIRE_TIME = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.INT); public static final EntityDataAccessor PITCH = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor Y_ROT = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.FLOAT); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/SenpaiEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/SenpaiEntity.java index f52e55131..c5a04a9af 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/SenpaiEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/SenpaiEntity.java @@ -35,6 +35,7 @@ import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; public class SenpaiEntity extends Monster implements GeoEntity, AnimatedEntity { + private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); public SenpaiEntity(PlayMessages.SpawnEntity packet, Level world) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/layer/Mle1934DamageLayer.java b/src/main/java/com/atsuishio/superbwarfare/entity/layer/Mle1934DamageLayer.java index 02f522744..83546395e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/layer/Mle1934DamageLayer.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/layer/Mle1934DamageLayer.java @@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.entity.layer; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.config.server.CannonConfig; -import com.atsuishio.superbwarfare.entity.Mk42Entity; import com.atsuishio.superbwarfare.entity.Mle1934Entity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; @@ -16,16 +15,17 @@ import software.bernie.geckolib.renderer.GeoRenderer; import software.bernie.geckolib.renderer.layer.GeoRenderLayer; public class Mle1934DamageLayer extends GeoRenderLayer { - private static final ResourceLocation LAYER = new ResourceLocation(ModUtils.MODID, "textures/entity/mle1934_damage.png"); - public Mle1934DamageLayer(GeoRenderer entityRenderer) { - super(entityRenderer); - } + private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/mle1934_damage.png"); - @Override - public void render(PoseStack poseStack, Mle1934Entity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { - RenderType glowRenderType = RenderType.entityTranslucent(LAYER); - float heal = Mth.clamp((0.3f * CannonConfig.MLE1934_HP.get() - animatable.getEntityData().get(Mk42Entity.HEALTH)) * 0.000007f * CannonConfig.MLE1934_HP.get(), 0.1f, 1); - getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, heal); - } + public Mle1934DamageLayer(GeoRenderer entityRenderer) { + super(entityRenderer); + } + + @Override + public void render(PoseStack poseStack, Mle1934Entity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { + RenderType glowRenderType = RenderType.entityTranslucent(LAYER); + float heal = Mth.clamp((0.3f * CannonConfig.MLE1934_HP.get() - animatable.getEntityData().get(Mle1934Entity.HEALTH)) * 0.000007f * CannonConfig.MLE1934_HP.get(), 0.1f, 1); + getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, heal); + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/LaserEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/LaserEntity.java index 56be1a310..bd14d34cd 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/LaserEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/LaserEntity.java @@ -5,6 +5,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; @@ -49,6 +50,23 @@ public class LaserEntity extends AbstractLaserEntity { if (this.tickCount >= this.getCountDown()) { this.calculateEndPos(RADIUS); + + CustomHitResult result = new CustomHitResult(); + result.setBlockHit(this.level().clip(new ClipContext(new Vec3(getX(), getY(), getZ()), new Vec3(endPosX, endPosY, endPosZ), + ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this))); + if (result.getBlockHit() != null) { + Vec3 hitVec = result.getBlockHit().getLocation(); + collidePosX = hitVec.x; + collidePosY = hitVec.y; + collidePosZ = hitVec.z; + blockSide = result.getBlockHit().getDirection(); + } else { + collidePosX = endPosX; + collidePosY = endPosY; + collidePosZ = endPosZ; + blockSide = null; + } + if (this.blockSide != null) { this.spawnExplosionParticles(); }