diff --git a/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/ClaymoreRenderer.java b/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/ClaymoreRenderer.java index bc38bcfb9..6082ff177 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/ClaymoreRenderer.java +++ b/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/ClaymoreRenderer.java @@ -2,12 +2,14 @@ package net.mcreator.superbwarfare.client.renderer.entity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Axis; import net.mcreator.superbwarfare.entity.ClaymoreEntity; import net.mcreator.superbwarfare.entity.model.ClaymoreModel; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; import software.bernie.geckolib.cache.object.BakedGeoModel; import software.bernie.geckolib.renderer.GeoEntityRenderer; @@ -31,6 +33,14 @@ public class ClaymoreRenderer extends GeoEntityRenderer { super.preRender(poseStack, entity, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha); } + @Override + public void render(ClaymoreEntity 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 protected float getDeathMaxRotation(ClaymoreEntity entityLivingBaseIn) { return 0.0F; diff --git a/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/Mk42Renderer.java b/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/Mk42Renderer.java index c27502882..42c2242ba 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/Mk42Renderer.java +++ b/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/Mk42Renderer.java @@ -2,13 +2,16 @@ package net.mcreator.superbwarfare.client.renderer.entity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Axis; import net.mcreator.superbwarfare.entity.Mk42Entity; +import net.mcreator.superbwarfare.entity.layer.Mk42DamageLayer; import net.mcreator.superbwarfare.entity.layer.Mk42Layer; import net.mcreator.superbwarfare.entity.model.Mk42Model; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; import software.bernie.geckolib.cache.object.BakedGeoModel; import software.bernie.geckolib.renderer.GeoEntityRenderer; @@ -17,6 +20,7 @@ public class Mk42Renderer extends GeoEntityRenderer { super(renderManager, new Mk42Model()); this.shadowRadius = 3f; this.addRenderLayer(new Mk42Layer(this)); + this.addRenderLayer(new Mk42DamageLayer(this)); } @Override @@ -33,6 +37,14 @@ public class Mk42Renderer extends GeoEntityRenderer { super.preRender(poseStack, entity, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha); } + @Override + public void render(Mk42Entity 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 protected float getDeathMaxRotation(Mk42Entity entityLivingBaseIn) { return 0.0F; diff --git a/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/Mle1934Renderer.java b/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/Mle1934Renderer.java index be5aca652..ee9f9cf0c 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/Mle1934Renderer.java +++ b/src/main/java/net/mcreator/superbwarfare/client/renderer/entity/Mle1934Renderer.java @@ -2,13 +2,16 @@ package net.mcreator.superbwarfare.client.renderer.entity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Axis; import net.mcreator.superbwarfare.entity.Mle1934Entity; +import net.mcreator.superbwarfare.entity.layer.Mle1934DamageLayer; import net.mcreator.superbwarfare.entity.layer.Mle1934Layer; import net.mcreator.superbwarfare.entity.model.Mle1934Model; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; import software.bernie.geckolib.cache.object.BakedGeoModel; import software.bernie.geckolib.renderer.GeoEntityRenderer; @@ -17,6 +20,7 @@ public class Mle1934Renderer extends GeoEntityRenderer { super(renderManager, new Mle1934Model()); this.shadowRadius = 3f; this.addRenderLayer(new Mle1934Layer(this)); + this.addRenderLayer(new Mle1934DamageLayer(this)); } @Override @@ -33,6 +37,14 @@ public class Mle1934Renderer extends GeoEntityRenderer { super.preRender(poseStack, entity, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha); } + @Override + public void render(Mle1934Entity 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 protected float getDeathMaxRotation(Mle1934Entity entityLivingBaseIn) { return 0.0F; diff --git a/src/main/java/net/mcreator/superbwarfare/entity/ClaymoreEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/ClaymoreEntity.java index 113fdce0e..f849326be 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/ClaymoreEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/ClaymoreEntity.java @@ -1,25 +1,22 @@ package net.mcreator.superbwarfare.entity; import net.mcreator.superbwarfare.ModUtils; -import net.mcreator.superbwarfare.init.ModDamageTypes; -import net.mcreator.superbwarfare.init.ModEntities; -import net.mcreator.superbwarfare.init.ModItems; +import net.mcreator.superbwarfare.init.*; import net.mcreator.superbwarfare.tools.CustomExplosion; import net.mcreator.superbwarfare.tools.ParticleTool; -import net.minecraft.core.NonNullList; +import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.players.OldUsersConverter; +import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageTypes; 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.player.Player; import net.minecraft.world.entity.projectile.ThrownPotion; import net.minecraft.world.item.ItemStack; @@ -31,10 +28,6 @@ import net.minecraftforge.items.ItemHandlerHelper; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; import software.bernie.geckolib.core.animation.AnimatableManager; -import software.bernie.geckolib.core.animation.AnimationController; -import software.bernie.geckolib.core.animation.AnimationState; -import software.bernie.geckolib.core.animation.RawAnimation; -import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; import javax.annotation.Nullable; @@ -42,12 +35,12 @@ import java.util.Comparator; import java.util.Optional; import java.util.UUID; -public class ClaymoreEntity extends LivingEntity implements GeoEntity, AnimatedEntity, OwnableEntity { - public static final EntityDataAccessor ANIMATION = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.STRING); - protected static final EntityDataAccessor> OWNER_UUID = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.OPTIONAL_UUID); - private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); +import static net.mcreator.superbwarfare.tools.ParticleTool.sendParticle; - public String animationProcedure = "empty"; +public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity, OwnableEntity { + protected static final EntityDataAccessor> OWNER_UUID = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.OPTIONAL_UUID); + public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.FLOAT); + private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); public ClaymoreEntity(EntityType type, Level world) { super(type, world); @@ -60,35 +53,17 @@ public class ClaymoreEntity extends LivingEntity implements GeoEntity, AnimatedE @Override protected void defineSynchedData() { - super.defineSynchedData(); - this.entityData.define(ANIMATION, "undefined"); this.entityData.define(OWNER_UUID, Optional.empty()); + this.entityData.define(HEALTH, 10f); } @Override - public MobType getMobType() { - return super.getMobType(); - } - - @Override - public Iterable getArmorSlots() { - return NonNullList.withSize(1, ItemStack.EMPTY); - } - - @Override - public ItemStack getItemBySlot(EquipmentSlot pSlot) { - return ItemStack.EMPTY; - } - - @Override - public void setItemSlot(EquipmentSlot pSlot, ItemStack pStack) { - + public boolean isPickable() { + return !this.isRemoved(); } @Override public boolean hurt(DamageSource source, float amount) { - if (source.is(DamageTypes.IN_FIRE)) - return false; if (source.getDirectEntity() instanceof ThrownPotion || source.getDirectEntity() instanceof AreaEffectCloud) return false; if (source.is(DamageTypes.FALL)) @@ -97,33 +72,20 @@ public class ClaymoreEntity extends LivingEntity implements GeoEntity, AnimatedE return false; if (source.is(DamageTypes.DROWN)) return false; - if (source.is(DamageTypes.LIGHTNING_BOLT)) - return false; - if (source.is(DamageTypes.EXPLOSION)) - return false; if (source.is(DamageTypes.DRAGON_BREATH)) return false; if (source.is(DamageTypes.WITHER)) return false; if (source.is(DamageTypes.WITHER_SKULL)) return false; - return super.hurt(source, amount); - } - @Override - public void die(DamageSource source) { - super.die(source); - - if (level() instanceof ServerLevel) { - CustomExplosion explosion = new CustomExplosion(this.level(), this, - ModDamageTypes.causeMineDamage(this.level().registryAccess(), this.getOwner()), 15.0f, - this.getX(), this.getY(), this.getZ(), 7.5f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); - explosion.explode(); - net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); - explosion.finalizeExplosion(false); - ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); - this.discard(); + if (this.level() instanceof ServerLevel serverLevel) { + sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.2, this.getZ(), 2, 0.02, 0.02, 0.02, 0.1, false); } + this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); + this.entityData.set(HEALTH, this.entityData.get(HEALTH) - amount); + + return super.hurt(source, amount); } public void setOwnerUUID(@Nullable UUID pUuid) { @@ -141,7 +103,7 @@ public class ClaymoreEntity extends LivingEntity implements GeoEntity, AnimatedE @Override public void addAdditionalSaveData(CompoundTag compound) { - super.addAdditionalSaveData(compound); + compound.putFloat("Health", this.entityData.get(HEALTH)); if (this.getOwnerUUID() != null) { compound.putUUID("Owner", this.getOwnerUUID()); @@ -150,7 +112,9 @@ public class ClaymoreEntity extends LivingEntity implements GeoEntity, AnimatedE @Override public void readAdditionalSaveData(CompoundTag compound) { - super.readAdditionalSaveData(compound); + if (compound.contains("Health")) { + this.entityData.set(HEALTH, compound.getFloat("Health")); + } UUID uuid; if (compound.hasUUID("Owner")) { @@ -197,15 +161,11 @@ public class ClaymoreEntity extends LivingEntity implements GeoEntity, AnimatedE if (!this.level().isClientSide()) this.discard(); } - this.removeAllEffects(); - this.clearFire(); - if (this.tickCount >= 40) { final Vec3 center = new Vec3(x + 1.5 * this.getLookAngle().x, y + 1.5 * this.getLookAngle().y, z + 1.5 * this.getLookAngle().z); for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(2.5 / 2d), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) { var condition = this.getOwner() != target && target instanceof LivingEntity - && !(target instanceof ClaymoreEntity) && !(target instanceof TargetEntity) && !(target instanceof Player player && (player.isCreative() || player.isSpectator())) && (!this.isAlliedTo(target) || target.getTeam() == null || target.getTeam().getName().equals("TDM")) @@ -226,8 +186,42 @@ public class ClaymoreEntity extends LivingEntity implements GeoEntity, AnimatedE } } + this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.03, 0.0)); + + if (!this.level().noCollision(this.getBoundingBox())) { + this.moveTowardsClosestSpace(this.getX(), (this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0, this.getZ()); + } + + this.move(MoverType.SELF, this.getDeltaMovement()); + float f = 0.98F; + if (this.onGround()) { + BlockPos pos = this.getBlockPosBelowThatAffectsMyMovement(); + f = this.level().getBlockState(pos).getFriction(this.level(), pos, this) * 0.98F; + } + + this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.98, f)); + if (this.onGround()) { + this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, -0.9, 1.0)); + } + + if (this.entityData.get(HEALTH) <= 0) { + destroy(); + } + this.refreshDimensions(); } + public void destroy() { + if (level() instanceof ServerLevel) { + CustomExplosion explosion = new CustomExplosion(this.level(), this, + ModDamageTypes.causeMineDamage(this.level().registryAccess(), this), 15.0f, + this.getX(), this.getY(), this.getZ(), 7.5f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); + explosion.explode(); + net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); + explosion.finalizeExplosion(false); + ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); + this.discard(); + } + } private void triggerExplode(Entity target) { CustomExplosion explosion = new CustomExplosion(this.level(), this, @@ -245,77 +239,26 @@ public class ClaymoreEntity extends LivingEntity implements GeoEntity, AnimatedE @Override public boolean isPushable() { - return false; - } - - @Override - public HumanoidArm getMainArm() { - return HumanoidArm.RIGHT; - } - - @Override - public void aiStep() { - super.aiStep(); - this.updateSwingTime(); - } - - private PlayState movementPredicate(software.bernie.geckolib.core.animation.AnimationState event) { - if (this.animationProcedure.equals("empty")) { - return event.setAndContinue(RawAnimation.begin().thenLoop("animation.claymore.idle")); - } - return PlayState.STOP; - } - - private PlayState procedurePredicate(AnimationState event) { - if (!animationProcedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) { - event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationProcedure)); - if (event.getController().getAnimationState() == AnimationController.State.STOPPED) { - this.animationProcedure = "empty"; - event.getController().forceAnimationReset(); - } - } else if (animationProcedure.equals("empty")) { - return PlayState.STOP; - } - return PlayState.CONTINUE; - } - - @Override - protected void tickDeath() { - ++this.deathTime; - if (this.deathTime == 1) { - this.remove(ClaymoreEntity.RemovalReason.KILLED); - } + return true; } public String getSyncedAnimation() { - return this.entityData.get(ANIMATION); + return null; } public void setAnimation(String animation) { - this.entityData.set(ANIMATION, animation); } @Override public void setAnimationProcedure(String procedure) { - this.animationProcedure = procedure; } @Override public void registerControllers(AnimatableManager.ControllerRegistrar data) { - data.add(new AnimationController<>(this, "movement", 4, this::movementPredicate)); - data.add(new AnimationController<>(this, "procedure", 4, this::procedurePredicate)); } @Override public AnimatableInstanceCache getAnimatableInstanceCache() { return this.cache; } - - public static AttributeSupplier.Builder createAttributes() { - return Mob.createMobAttributes().add(Attributes.MOVEMENT_SPEED, 0) - .add(Attributes.MAX_HEALTH, 5) - .add(Attributes.FOLLOW_RANGE, 64) - .add(Attributes.ATTACK_DAMAGE, 0) - .add(Attributes.KNOCKBACK_RESISTANCE, 10); - } } \ No newline at end of file diff --git a/src/main/java/net/mcreator/superbwarfare/entity/Mk42Entity.java b/src/main/java/net/mcreator/superbwarfare/entity/Mk42Entity.java index 7900e08ec..0dbf43e75 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/Mk42Entity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/Mk42Entity.java @@ -6,6 +6,7 @@ import net.mcreator.superbwarfare.item.common.ammo.CannonShellItem; import net.mcreator.superbwarfare.tools.CustomExplosion; import net.mcreator.superbwarfare.tools.ParticleTool; import net.mcreator.superbwarfare.tools.SoundTool; +import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; @@ -15,26 +16,20 @@ import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageTypes; 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.player.Player; +import net.minecraft.world.entity.projectile.ThrownPotion; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import net.minecraftforge.event.entity.living.LivingHurtEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PlayMessages; -import org.jetbrains.annotations.NotNull; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; import software.bernie.geckolib.core.animation.AnimatableManager; @@ -44,13 +39,14 @@ import software.bernie.geckolib.core.animation.RawAnimation; import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; -public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntity { +import static net.mcreator.superbwarfare.tools.ParticleTool.sendParticle; + +public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { public static final EntityDataAccessor COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor TYPE = 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 String animationprocedure = "empty"; - protected int interpolationSteps; protected double serverYRot; @@ -62,120 +58,97 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit public Mk42Entity(EntityType type, Level world) { super(type, world); - xpReward = 0; - setNoAi(true); - setPersistenceRequired(); } @Override protected void defineSynchedData() { - super.defineSynchedData(); this.entityData.define(COOL_DOWN, 0); this.entityData.define(TYPE, 0); + this.entityData.define(HEALTH, 500f); } @Override public void addAdditionalSaveData(CompoundTag compound) { - super.addAdditionalSaveData(compound); compound.putInt("cool_down", this.entityData.get(COOL_DOWN)); compound.putInt("type", this.entityData.get(TYPE)); + compound.putFloat("Health", this.entityData.get(HEALTH)); } @Override public void readAdditionalSaveData(CompoundTag compound) { - super.readAdditionalSaveData(compound); this.entityData.set(COOL_DOWN, compound.getInt("cool_down")); this.entityData.set(TYPE, compound.getInt("type")); + this.entityData.set(HEALTH, compound.getFloat("Health")); } @Override - protected float getStandingEyeHeight(Pose poseIn, EntityDimensions sizeIn) { + protected float getEyeHeight(Pose pPose, EntityDimensions pSize) { return 2.16F; } - @Override - public boolean canCollideWith(Entity entity) { - return true; - } - - @Override - public boolean canBeCollidedWith() { - return true; - } - @Override public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } - @Override - public MobType getMobType() { - return super.getMobType(); - } - - @Override - public boolean removeWhenFarAway(double distanceToClosestPlayer) { - return false; - } - @Override public double getPassengersRidingOffset() { return super.getPassengersRidingOffset() - 0.25; } - @Override - public SoundEvent getHurtSound(DamageSource ds) { - return ModSounds.HIT.get(); - } - - @Override - public SoundEvent getDeathSound() { - return ModSounds.HIT.get(); - } - @Override public boolean hurt(DamageSource source, float amount) { + + if (this.level() instanceof ServerLevel serverLevel) { + sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); + } + + if (source.getDirectEntity() instanceof ThrownPotion || source.getDirectEntity() instanceof AreaEffectCloud) + return false; + if (source.is(DamageTypes.FALL)) + return false; + if (source.is(DamageTypes.CACTUS)) + return false; + if (source.is(DamageTypes.DROWN)) + return false; + if (source.is(DamageTypes.LIGHTNING_BOLT)) + return false; + if (source.is(DamageTypes.FALLING_ANVIL)) + return false; + if (source.is(DamageTypes.DRAGON_BREATH)) + return false; + if (source.is(DamageTypes.WITHER)) + return false; + if (source.is(DamageTypes.WITHER_SKULL)) + return false; if (amount < 32) { return false; } - return super.hurt(source, 0.3f * amount); + + this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); + this.entityData.set(HEALTH, this.entityData.get(HEALTH) - 0.5f * amount); + + return true; } @Override - public @NotNull InteractionResult mobInteract(Player player, InteractionHand hand) { + public boolean isPickable() { + return !this.isRemoved(); + } + + @Override + public InteractionResult interact(Player player, InteractionHand hand) { if (player.isShiftKeyDown() && player.getMainHandItem().getItem() == ModItems.CROWBAR.get() && this.getFirstPassenger() == null) { this.discard(); - ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.MK_42_SPAWN_EGG.get())); +// ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.MK_42_SPAWN_EGG.get())); } else { player.setXRot(this.getXRot()); player.setYRot(this.getYRot()); player.startRiding(this); } - InteractionResult result = InteractionResult.sidedSuccess(this.level().isClientSide()); - super.mobInteract(player, hand); - return result; - } - @Override - public void die(DamageSource source) { - super.die(source); - - if (level() instanceof ServerLevel) { - destroyExplode(); - this.discard(); - } - } - - private void destroyExplode() { - CustomExplosion explosion = new CustomExplosion(this.level(), this, - ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this), 30f, - this.getX(), this.getY(), this.getZ(), 7.5f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); - explosion.explode(); - net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); - explosion.finalizeExplosion(false); - - ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); + return InteractionResult.sidedSuccess(this.level().isClientSide()); } @Override @@ -191,9 +164,77 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit this.entityData.set(TYPE, 1); } } + + this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0)); + + if (!this.level().noCollision(this.getBoundingBox())) { + this.moveTowardsClosestSpace(this.getX(), (this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0, this.getZ()); + } + + this.move(MoverType.SELF, this.getDeltaMovement()); + float f = 0.98F; + if (this.onGround()) { + BlockPos pos = this.getBlockPosBelowThatAffectsMyMovement(); + f = this.level().getBlockState(pos).getFriction(this.level(), pos, this) * 0.98F; + } + + this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.98, f)); + if (this.onGround()) { + this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, -0.9, 1.0)); + } + + if (this.entityData.get(HEALTH) <= 300) { + if (this.level() instanceof ServerLevel serverLevel) { + sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false); + } + } + + if (this.entityData.get(HEALTH) <= 200) { + if (this.level() instanceof ServerLevel serverLevel) { + sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); + sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); + } + } + + if (this.entityData.get(HEALTH) <= 150) { + if (this.level() instanceof ServerLevel serverLevel) { + sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); + sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); + } + } + + if (this.entityData.get(HEALTH) <= 100) { + if (this.level() instanceof ServerLevel serverLevel) { + sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false); + sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false); + sendParticle(serverLevel, ParticleTypes.FLAME, this.getX(), this.getY() + 3.2, this.getZ(), 4, 0.6, 0.1, 0.6, 0.05, false); + sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 3, this.getZ(), 4, 0.1, 0.1, 0.1, 0.4, false); + } + this.entityData.set(HEALTH, this.entityData.get(HEALTH) - 0.1f); + } else { + this.entityData.set(HEALTH, this.entityData.get(HEALTH) + 0.05f); + } + + if (this.entityData.get(HEALTH) <= 0) { + destroy(); + } + + travel(); this.refreshDimensions(); } + private void destroy() { + CustomExplosion explosion = new CustomExplosion(this.level(), this, + ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this), 130f, + this.getX(), this.getY(), this.getZ(), 9.5f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); + explosion.explode(); + net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); + explosion.finalizeExplosion(false); + ParticleTool.spawnHugeExplosionParticles(this.level(), this.position()); + + this.discard(); + } + @Override public void cannonShoot(Player player) { if (this.entityData.get(COOL_DOWN) > 0) { @@ -216,17 +257,17 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit int durability = 0; if (stack.is(ModItems.HE_5_INCHES.get())) { - hitDamage = 600; + hitDamage = 180; explosionRadius = 10; - explosionDamage = 200; + explosionDamage = 220; fireProbability = 0.18F; fireTime = 5; } if (stack.is(ModItems.AP_5_INCHES.get())) { - hitDamage = 850; + hitDamage = 360; explosionRadius = 3; - explosionDamage = 250; + explosionDamage = 100; fireProbability = 0; fireTime = 0; durability = 25; @@ -286,8 +327,7 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit this.interpolationSteps = 10; } - @Override - public void travel(@NotNull Vec3 dir) { + public void travel() { Player entity = this.getPassengers().isEmpty() ? null : (Player) this.getPassengers().get(0); ItemStack stack = null; if (entity != null) { @@ -307,17 +347,7 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit this.setYRot(this.getYRot() + Mth.clamp(diffY, -1.75f, 1.75f)); this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -3f, 3f), -85, 15)); this.setRot(this.getYRot(), this.getXRot()); - this.yBodyRot = this.getYRot(); - this.yHeadRot = this.getYRot(); - return; } - super.travel(dir); - } - - @Override - public void aiStep() { - super.aiStep(); - this.updateSwingTime(); } public static void init() { @@ -342,16 +372,6 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit this.clampRotation(entity); } - public static AttributeSupplier.Builder createAttributes() { - return Mob.createMobAttributes() - .add(Attributes.MOVEMENT_SPEED, 0) - .add(Attributes.MAX_HEALTH, 500) - .add(Attributes.ARMOR, 30) - .add(Attributes.ATTACK_DAMAGE, 0) - .add(Attributes.FOLLOW_RANGE, 32) - .add(Attributes.KNOCKBACK_RESISTANCE, 1); - } - private PlayState movementPredicate(AnimationState event) { if (this.entityData.get(COOL_DOWN) > 0) { if (this.entityData.get(TYPE) == 1) { @@ -364,15 +384,6 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mk42.idle")); } - @Override - protected void tickDeath() { - ++this.deathTime; - if (this.deathTime == 1) { - this.remove(Mk42Entity.RemovalReason.KILLED); - this.dropExperience(); - } - } - public String getSyncedAnimation() { return null; } @@ -390,21 +401,4 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit return this.cache; } - @SubscribeEvent - public static void onEntityAttacked(LivingHurtEvent event) { - var damagesource = event.getSource(); - var entity = event.getEntity(); - if (damagesource == null || entity == null) return; - - var sourceentity = damagesource.getEntity(); - if (sourceentity == null) return; - - if (entity instanceof Mk42Entity mk42) { - if (mk42.getFirstPassenger() == null) return; - Entity gunner = mk42.getFirstPassenger(); - if (event.getSource().getDirectEntity() == gunner) { - event.setCanceled(true); - } - } - } } diff --git a/src/main/java/net/mcreator/superbwarfare/entity/Mle1934Entity.java b/src/main/java/net/mcreator/superbwarfare/entity/Mle1934Entity.java index 39220f496..d2874c6ef 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/Mle1934Entity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/Mle1934Entity.java @@ -7,6 +7,7 @@ import net.mcreator.superbwarfare.item.common.ammo.CannonShellItem; import net.mcreator.superbwarfare.tools.CustomExplosion; import net.mcreator.superbwarfare.tools.ParticleTool; import net.mcreator.superbwarfare.tools.SoundTool; +import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; @@ -16,26 +17,20 @@ import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageTypes; 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.player.Player; +import net.minecraft.world.entity.projectile.ThrownPotion; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -import net.minecraftforge.event.entity.living.LivingHurtEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PlayMessages; -import org.jetbrains.annotations.NotNull; import org.joml.Vector3d; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; @@ -46,14 +41,18 @@ import software.bernie.geckolib.core.animation.RawAnimation; import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; -public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEntity { - public static final EntityDataAccessor COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT); - public static final EntityDataAccessor TYPE = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT); +import static net.mcreator.superbwarfare.tools.ParticleTool.sendParticle; + +public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { + public static final EntityDataAccessor COOL_DOWN = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.INT); + public static final EntityDataAccessor TYPE = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.INT); + public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.FLOAT); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); public String animationprocedure = "empty"; protected int interpolationSteps; + protected double serverYRot; protected double serverXRot; @@ -63,120 +62,97 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn public Mle1934Entity(EntityType type, Level world) { super(type, world); - xpReward = 0; - setNoAi(true); - setPersistenceRequired(); } @Override protected void defineSynchedData() { - super.defineSynchedData(); this.entityData.define(COOL_DOWN, 0); this.entityData.define(TYPE, 0); + this.entityData.define(HEALTH, 600f); } @Override public void addAdditionalSaveData(CompoundTag compound) { - super.addAdditionalSaveData(compound); compound.putInt("cool_down", this.entityData.get(COOL_DOWN)); compound.putInt("type", this.entityData.get(TYPE)); + compound.putFloat("Health", this.entityData.get(HEALTH)); } @Override public void readAdditionalSaveData(CompoundTag compound) { - super.readAdditionalSaveData(compound); this.entityData.set(COOL_DOWN, compound.getInt("cool_down")); this.entityData.set(TYPE, compound.getInt("type")); + this.entityData.set(HEALTH, compound.getFloat("Health")); } @Override - protected float getStandingEyeHeight(Pose poseIn, EntityDimensions sizeIn) { + protected float getEyeHeight(Pose pPose, EntityDimensions pSize) { return 2.16F; } - @Override - public boolean canCollideWith(Entity entity) { - return true; - } - - @Override - public boolean canBeCollidedWith() { - return true; - } - @Override public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } - @Override - public MobType getMobType() { - return super.getMobType(); - } - - @Override - public boolean removeWhenFarAway(double distanceToClosestPlayer) { - return false; - } - @Override public double getPassengersRidingOffset() { return super.getPassengersRidingOffset() - 0.075; } - @Override - public SoundEvent getHurtSound(DamageSource ds) { - return ModSounds.HIT.get(); - } - - @Override - public SoundEvent getDeathSound() { - return ModSounds.HIT.get(); - } - @Override public boolean hurt(DamageSource source, float amount) { - if (amount < 34) { + + if (this.level() instanceof ServerLevel serverLevel) { + sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); + } + + if (source.getDirectEntity() instanceof ThrownPotion || source.getDirectEntity() instanceof AreaEffectCloud) + return false; + if (source.is(DamageTypes.FALL)) + return false; + if (source.is(DamageTypes.CACTUS)) + return false; + if (source.is(DamageTypes.DROWN)) + return false; + if (source.is(DamageTypes.LIGHTNING_BOLT)) + return false; + if (source.is(DamageTypes.FALLING_ANVIL)) + return false; + if (source.is(DamageTypes.DRAGON_BREATH)) + return false; + if (source.is(DamageTypes.WITHER)) + return false; + if (source.is(DamageTypes.WITHER_SKULL)) + return false; + if (amount < 32) { return false; } - return super.hurt(source, 0.3f * amount); + + this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); + this.entityData.set(HEALTH, this.entityData.get(HEALTH) - 0.5f * amount); + + return true; } @Override - public @NotNull InteractionResult mobInteract(Player player, InteractionHand hand) { + public boolean isPickable() { + return !this.isRemoved(); + } + + @Override + public InteractionResult interact(Player player, InteractionHand hand) { if (player.isShiftKeyDown() && player.getMainHandItem().getItem() == ModItems.CROWBAR.get() && this.getFirstPassenger() == null) { this.discard(); - ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.MLE_1934_SPAWN_EGG.get())); +// ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.MK_42_SPAWN_EGG.get())); } else { player.setXRot(this.getXRot()); player.setYRot(this.getYRot()); player.startRiding(this); } - InteractionResult result = InteractionResult.sidedSuccess(this.level().isClientSide()); - super.mobInteract(player, hand); - return result; - } - @Override - public void die(DamageSource source) { - super.die(source); - - if (level() instanceof ServerLevel) { - destroyExplode(); - this.discard(); - } - } - - private void destroyExplode() { - CustomExplosion explosion = new CustomExplosion(this.level(), this, - ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this), 30f, - this.getX(), this.getY(), this.getZ(), 7.5f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); - explosion.explode(); - net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); - explosion.finalizeExplosion(false); - - ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); + return InteractionResult.sidedSuccess(this.level().isClientSide()); } @Override @@ -187,9 +163,76 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn this.entityData.set(COOL_DOWN, this.entityData.get(COOL_DOWN) - 1); } + this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0)); + + if (!this.level().noCollision(this.getBoundingBox())) { + this.moveTowardsClosestSpace(this.getX(), (this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0, this.getZ()); + } + + this.move(MoverType.SELF, this.getDeltaMovement()); + float f = 0.98F; + if (this.onGround()) { + BlockPos pos = this.getBlockPosBelowThatAffectsMyMovement(); + f = this.level().getBlockState(pos).getFriction(this.level(), pos, this) * 0.98F; + } + + this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.98, f)); + if (this.onGround()) { + this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, -0.9, 1.0)); + } + + if (this.entityData.get(HEALTH) <= 0) { + destroy(); + } + + if (this.entityData.get(HEALTH) <= 300) { + if (this.level() instanceof ServerLevel serverLevel) { + sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false); + } + } + + if (this.entityData.get(HEALTH) <= 200) { + if (this.level() instanceof ServerLevel serverLevel) { + sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); + sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); + } + } + + if (this.entityData.get(HEALTH) <= 150) { + if (this.level() instanceof ServerLevel serverLevel) { + sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); + sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); + } + } + + if (this.entityData.get(HEALTH) <= 100) { + if (this.level() instanceof ServerLevel serverLevel) { + sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false); + sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false); + sendParticle(serverLevel, ParticleTypes.FLAME, this.getX(), this.getY() + 3.2, this.getZ(), 4, 0.6, 0.1, 0.6, 0.05, false); + sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 3, this.getZ(), 4, 0.1, 0.1, 0.1, 0.4, false); + } + this.entityData.set(HEALTH, this.entityData.get(HEALTH) - 0.1f); + } else { + this.entityData.set(HEALTH, this.entityData.get(HEALTH) + 0.05f); + } + + travel(); this.refreshDimensions(); } + private void destroy() { + CustomExplosion explosion = new CustomExplosion(this.level(), this, + ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this), 140f, + this.getX(), this.getY(), this.getZ(), 10f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); + explosion.explode(); + net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); + explosion.finalizeExplosion(false); + ParticleTool.spawnHugeExplosionParticles(this.level(), this.position()); + + this.discard(); + } + @Override public void cannonShoot(Player player) { if (this.entityData.get(COOL_DOWN) > 0) { @@ -213,18 +256,18 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn boolean salvoShoot = false; if (stack.is(ModItems.HE_5_INCHES.get())) { - hitDamage = 700; + hitDamage = 200; explosionRadius = 13; - explosionDamage = 250; + explosionDamage = 240; fireProbability = 0.24F; fireTime = 5; salvoShoot = stack.getCount() > 1 || player.isCreative(); } if (stack.is(ModItems.AP_5_INCHES.get())) { - hitDamage = 1000; + hitDamage = 400; explosionRadius = 3.8f; - explosionDamage = 300; + explosionDamage = 120; fireProbability = 0; fireTime = 0; durability = 35; @@ -363,8 +406,7 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn this.interpolationSteps = 10; } - @Override - public void travel(@NotNull Vec3 dir) { + public void travel() { Player entity = this.getPassengers().isEmpty() ? null : (Player) this.getPassengers().get(0); ItemStack stack = null; if (entity != null) { @@ -381,20 +423,9 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn diffY = diffY * 0.15f; diffX = diffX * 0.15f; this.setYRot(this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f)); - this.yRotO = this.getYRot(); this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -2f, 2f), -30, 4)); this.setRot(this.getYRot(), this.getXRot()); - this.yBodyRot = this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f); - this.yHeadRot = this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f); - return; } - super.travel(dir); - } - - @Override - public void aiStep() { - super.aiStep(); - this.updateSwingTime(); } public static void init() { @@ -418,16 +449,6 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn this.clampRotation(entity); } - public static AttributeSupplier.Builder createAttributes() { - return Mob.createMobAttributes() - .add(Attributes.MOVEMENT_SPEED, 0) - .add(Attributes.MAX_HEALTH, 600) - .add(Attributes.ARMOR, 30) - .add(Attributes.ATTACK_DAMAGE, 0) - .add(Attributes.FOLLOW_RANGE, 32) - .add(Attributes.KNOCKBACK_RESISTANCE, 1); - } - private PlayState movementPredicate(AnimationState event) { if (this.entityData.get(COOL_DOWN) > 64) { if (this.entityData.get(TYPE) == 1) { @@ -439,15 +460,6 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mle1934.idle")); } - @Override - protected void tickDeath() { - ++this.deathTime; - if (this.deathTime == 1) { - this.remove(RemovalReason.KILLED); - this.dropExperience(); - } - } - public String getSyncedAnimation() { return null; } @@ -465,21 +477,4 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn return this.cache; } - @SubscribeEvent - public static void onEntityAttacked(LivingHurtEvent event) { - var damagesource = event.getSource(); - var entity = event.getEntity(); - if (damagesource == null || entity == null) return; - - var sourceentity = damagesource.getEntity(); - if (sourceentity == null) return; - - if (entity instanceof Mle1934Entity mle1934) { - if (mle1934.getFirstPassenger() == null) return; - Entity gunner = mle1934.getFirstPassenger(); - if (event.getSource().getDirectEntity() == gunner) { - event.setCanceled(true); - } - } - } } diff --git a/src/main/java/net/mcreator/superbwarfare/entity/MortarEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/MortarEntity.java index 6c511fd11..ee21a0e23 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/MortarEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/MortarEntity.java @@ -4,10 +4,11 @@ import net.mcreator.superbwarfare.ModUtils; import net.mcreator.superbwarfare.entity.projectile.MortarShellEntity; import net.mcreator.superbwarfare.init.ModEntities; import net.mcreator.superbwarfare.init.ModItems; +import net.mcreator.superbwarfare.init.ModParticleTypes; import net.mcreator.superbwarfare.init.ModSounds; +import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.syncher.EntityDataAccessor; @@ -21,11 +22,12 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.entity.*; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.ThrownPotion; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; +import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PlayMessages; import software.bernie.geckolib.animatable.GeoEntity; @@ -37,12 +39,14 @@ import software.bernie.geckolib.core.animation.RawAnimation; import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; +import static net.mcreator.superbwarfare.tools.ParticleTool.sendParticle; + 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 HEALTH = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.FLOAT); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); - public String animationProcedure = "empty"; protected int interpolationSteps; protected double serverYRot; @@ -60,6 +64,7 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity { protected void defineSynchedData() { this.entityData.define(FIRE_TIME, 0); this.entityData.define(PITCH, 70f); + this.entityData.define(HEALTH, 100f); } @Override @@ -79,8 +84,6 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity { @Override public boolean hurt(DamageSource source, float amount) { - if (source.is(DamageTypes.IN_FIRE)) - return false; if (source.getDirectEntity() instanceof ThrownPotion || source.getDirectEntity() instanceof AreaEffectCloud) return false; if (source.is(DamageTypes.FALL)) @@ -99,13 +102,21 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity { return false; if (source.is(DamageTypes.WITHER_SKULL)) return false; - return super.hurt(source, amount); + + if (this.level() instanceof ServerLevel serverLevel) { + sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 1, this.getZ(), 2, 0.05, 0.05, 0.05, 0.1, false); + } + this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); + this.entityData.set(HEALTH, this.entityData.get(HEALTH) - amount); + + return true; } @Override public void addAdditionalSaveData(CompoundTag compound) { compound.putInt("FireTime", this.entityData.get(FIRE_TIME)); compound.putFloat("Pitch", this.entityData.get(PITCH)); + compound.putFloat("Health", this.entityData.get(HEALTH)); } @Override @@ -116,98 +127,52 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity { if (compound.contains("Pitch")) { this.entityData.set(PITCH, compound.getFloat("Pitch")); } + if (compound.contains("Health")) { + this.entityData.set(HEALTH, compound.getFloat("Health")); + } } @Override - public InteractionResult interactAt(Player player, Vec3 pVec, InteractionHand 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); - } - }); + 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.setYBodyRot(this.getYRot()); + this.setYHeadRot(this.getYRot()); + this.yRotO = this.getYRot(); } - return InteractionResult.SUCCESS; -// return InteractionResult.sidedSuccess(this.level().isClientSide()); + 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 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 public void lerpTo(double x, double y, double z, float yaw, float pitch, int interpolationSteps, boolean interpolate) { serverYRot = yaw; @@ -215,16 +180,6 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity { this.interpolationSteps = 10; } -// @Override -// protected void setRot(float pYRot, float pXRot) { -// 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 public void baseTick() { super.baseTick(); @@ -233,63 +188,48 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity { } this.setXRot(-Mth.clamp(entityData.get(PITCH), 20, 89)); this.xRotO = this.getXRot(); + + this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0)); + + if (!this.level().noCollision(this.getBoundingBox())) { + this.moveTowardsClosestSpace(this.getX(), (this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0, this.getZ()); + } + + this.move(MoverType.SELF, this.getDeltaMovement()); + float f = 0.98F; + if (this.onGround()) { + BlockPos pos = this.getBlockPosBelowThatAffectsMyMovement(); + f = this.level().getBlockState(pos).getFriction(this.level(), pos, this) * 0.98F; + } + + this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.98, f)); + if (this.onGround()) { + this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, -0.9, 1.0)); + } + + if (this.entityData.get(HEALTH) <= 0) { + destroy(); + } this.refreshDimensions(); } -// @Override -// public HumanoidArm getMainArm() { -// return HumanoidArm.RIGHT; -// } -// -// @Override -// protected void doPush(Entity entityIn) { -// } -// -// @Override -// protected void pushEntities() { -// } - -// 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 event) { - if (this.animationProcedure.equals("empty")) { - if (this.entityData.get(FIRE_TIME) > 0) { - return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mortar.fire")); - } - return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mortar.idle")); + if (this.entityData.get(FIRE_TIME) > 0) { + return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mortar.fire")); } - return PlayState.STOP; + return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mortar.idle")); } - -// @Override -// protected void tickDeath() { -// ++this.deathTime; -// if (this.deathTime == 5) { -// this.remove(MortarEntity.RemovalReason.KILLED); -// this.dropExperience(); -// if (this.level() instanceof ServerLevel level) { -// var x = this.getX(); -// var y = this.getY(); -// var z = this.getZ(); -// 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())); -// mortar.setPickUpDelay(10); -// level.addFreshEntity(mortar); -// } -// } -// } - - @Override - public Vec3 getDeltaMovement() { - return new Vec3(0, 0, 0); + protected void destroy() { + if (this.level() instanceof ServerLevel level) { + var x = this.getX(); + var y = this.getY(); + var z = this.getZ(); + 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())); + mortar.setPickUpDelay(10); + level.addFreshEntity(mortar); + this.discard(); + } } public String getSyncedAnimation() { @@ -301,7 +241,6 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity { @Override public void setAnimationProcedure(String procedure) { - this.animationProcedure = procedure; } @Override diff --git a/src/main/java/net/mcreator/superbwarfare/entity/layer/Mk42DamageLayer.java b/src/main/java/net/mcreator/superbwarfare/entity/layer/Mk42DamageLayer.java new file mode 100644 index 000000000..e3766b9fb --- /dev/null +++ b/src/main/java/net/mcreator/superbwarfare/entity/layer/Mk42DamageLayer.java @@ -0,0 +1,29 @@ +package net.mcreator.superbwarfare.entity.layer; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.entity.Mk42Entity; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import software.bernie.geckolib.cache.object.BakedGeoModel; +import software.bernie.geckolib.renderer.GeoRenderer; +import software.bernie.geckolib.renderer.layer.GeoRenderLayer; + +public class Mk42DamageLayer extends GeoRenderLayer { + private static final ResourceLocation LAYER = new ResourceLocation(ModUtils.MODID, "textures/entity/sherman_damage.png"); + + public Mk42DamageLayer(GeoRenderer entityRenderer) { + super(entityRenderer); + } + + @Override + public void render(PoseStack poseStack, Mk42Entity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { + RenderType glowRenderType = RenderType.entityTranslucent(LAYER); + float heal = Mth.clamp((300 - animatable.getEntityData().get(Mk42Entity.HEALTH)) * 0.0033f,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/net/mcreator/superbwarfare/entity/layer/Mle1934DamageLayer.java b/src/main/java/net/mcreator/superbwarfare/entity/layer/Mle1934DamageLayer.java new file mode 100644 index 000000000..98df31f9d --- /dev/null +++ b/src/main/java/net/mcreator/superbwarfare/entity/layer/Mle1934DamageLayer.java @@ -0,0 +1,29 @@ +package net.mcreator.superbwarfare.entity.layer; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.entity.Mle1934Entity; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import software.bernie.geckolib.cache.object.BakedGeoModel; +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); + } + + @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((300 - animatable.getEntityData().get(Mle1934Entity.HEALTH)) * 0.0033f,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/net/mcreator/superbwarfare/entity/projectile/JavelinMissileEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/projectile/JavelinMissileEntity.java index a7eecfe1d..822d4be64 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/projectile/JavelinMissileEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/projectile/JavelinMissileEntity.java @@ -164,7 +164,7 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo @Override public void tick() { super.tick(); - Entity entity = this.level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox().inflate(512)) + Entity entity = this.level().getEntitiesOfClass(Entity.class, this.getBoundingBox().inflate(512)) .stream().filter(e -> e.getStringUUID().equals(entityData.get(TARGET_UUID))).findFirst().orElse(null); diff --git a/src/main/java/net/mcreator/superbwarfare/entity/projectile/ProjectileEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/projectile/ProjectileEntity.java index 869ccaef3..90d6d0dcd 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/projectile/ProjectileEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/projectile/ProjectileEntity.java @@ -73,10 +73,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa public static final EntityDataAccessor COLOR_R = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor COLOR_G = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor COLOR_B = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor ANIMATION = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.STRING); - private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); - public String animationProcedure = "empty"; private static final Predicate PROJECTILE_TARGETS = input -> input != null && input.isPickable() && !input.isSpectator() && input.isAlive(); private static final Predicate IGNORE_LEAVES = input -> input != null && (input.getBlock() instanceof LeavesBlock @@ -736,16 +733,14 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa } public String getSyncedAnimation() { - return this.entityData.get(ANIMATION); + return null; } public void setAnimation(String animation) { - this.entityData.set(ANIMATION, animation); } @Override public void setAnimationProcedure(String procedure) { - this.animationProcedure = procedure; } @Override diff --git a/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java b/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java index 5c0667b52..74d9edb7e 100644 --- a/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java @@ -150,7 +150,7 @@ public class ClientEventHandler { public static void handleWeaponFire(TickEvent.RenderTickEvent event) { ClientLevel level = Minecraft.getInstance().level; Player player = Minecraft.getInstance().player; - if (notInGame()) return; +// if (notInGame()) return; if (player == null) return; if (level == null) return; @@ -242,6 +242,11 @@ public class ClientEventHandler { ModUtils.PACKET_HANDLER.sendToServer(new ShootMessage(spread)); clientTimer.setProgress((long) (clientTimer.getProgress() - cooldown)); } + + if (notInGame()) { + clientTimer.stop(); + } + } else { clientTimer.stop(); fireSpread = 0; diff --git a/src/main/java/net/mcreator/superbwarfare/init/ModEntities.java b/src/main/java/net/mcreator/superbwarfare/init/ModEntities.java index b2ea9781d..f16a2b1eb 100644 --- a/src/main/java/net/mcreator/superbwarfare/init/ModEntities.java +++ b/src/main/java/net/mcreator/superbwarfare/init/ModEntities.java @@ -70,11 +70,7 @@ public class ModEntities { @SubscribeEvent public static void registerAttributes(EntityAttributeCreationEvent event) { event.put(TARGET.get(), TargetEntity.createAttributes().build()); -// event.put(MORTAR.get(), MortarEntity.createAttributes().build()); event.put(SENPAI.get(), SenpaiEntity.createAttributes().build()); - event.put(MK_42.get(), Mk42Entity.createAttributes().build()); event.put(DRONE.get(), DroneEntity.createAttributes().build()); - event.put(MLE_1934.get(), Mle1934Entity.createAttributes().build()); - event.put(CLAYMORE.get(), ClaymoreEntity.createAttributes().build()); } } diff --git a/src/main/java/net/mcreator/superbwarfare/init/ModItems.java b/src/main/java/net/mcreator/superbwarfare/init/ModItems.java index 0c4289e0d..066df3fc8 100644 --- a/src/main/java/net/mcreator/superbwarfare/init/ModItems.java +++ b/src/main/java/net/mcreator/superbwarfare/init/ModItems.java @@ -111,8 +111,6 @@ public class ModItems { public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ModUtils.MODID); public static final RegistryObject SENPAI_SPAWN_EGG = ITEMS.register("senpai_spawn_egg", () -> new ForgeSpawnEggItem(ModEntities.SENPAI, -11584987, -14014413, new Item.Properties())); - public static final RegistryObject MK_42_SPAWN_EGG = ITEMS.register("mk42_spawn_egg", () -> new ForgeSpawnEggItem(ModEntities.MK_42, -8348258, -2630437, new Item.Properties())); - public static final RegistryObject MLE_1934_SPAWN_EGG = ITEMS.register("mle1934_spawn_egg", () -> new ForgeSpawnEggItem(ModEntities.MLE_1934, -3355444, -14146005, new Item.Properties())); public static final RegistryObject ANCIENT_CPU = ITEMS.register("ancient_cpu", () -> new Item(new Item.Properties().rarity(Rarity.RARE))); public static final RegistryObject PROPELLER = ITEMS.register("propeller", () -> new Item(new Item.Properties())); public static final RegistryObject MOTOR = ITEMS.register("motor", () -> new Item(new Item.Properties())); diff --git a/src/main/java/net/mcreator/superbwarfare/item/gun/launcher/JavelinItem.java b/src/main/java/net/mcreator/superbwarfare/item/gun/launcher/JavelinItem.java index a9926361d..5032f1651 100644 --- a/src/main/java/net/mcreator/superbwarfare/item/gun/launcher/JavelinItem.java +++ b/src/main/java/net/mcreator/superbwarfare/item/gun/launcher/JavelinItem.java @@ -146,9 +146,9 @@ public class JavelinItem extends GunItem implements GeoItem, AnimatedItem { tag.putInt("max_ammo", getAmmoCount(player)); if (tag.getBoolean("Seeking")) { - Entity targetEntity = player.level().getEntitiesOfClass(LivingEntity.class, player.getBoundingBox().inflate(384)) + Entity targetEntity = player.level().getEntitiesOfClass(Entity.class, player.getBoundingBox().inflate(512)) .stream().filter(e -> e.getStringUUID().equals(tag.getString("TargetEntity"))).findFirst().orElse(null); - Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 384, 8); + Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 512, 8); if (seekingEntity != null && seekingEntity == targetEntity) { tag.putInt("SeekTime", tag.getInt("SeekTime") + 1); } else { @@ -159,8 +159,11 @@ public class JavelinItem extends GunItem implements GeoItem, AnimatedItem { SoundTool.playLocalSound(serverPlayer, ModSounds.JAVELIN_LOCK.get(), 2, 1); } - if (tag.getInt("SeekTime") > 20 && seekingEntity instanceof LivingEntity living && !living.level().isClientSide()) { - living.addEffect(new MobEffectInstance(MobEffects.GLOWING, 40, 0)); + if (seekingEntity != null && tag.getInt("SeekTime") > 20) { + if (seekingEntity instanceof LivingEntity living) { + living.addEffect(new MobEffectInstance(MobEffects.GLOWING, 40, 0)); + } + if (player instanceof ServerPlayer serverPlayer) { SoundTool.playLocalSound(serverPlayer, ModSounds.JAVELIN_LOCKON.get(), 2, 1); } diff --git a/src/main/java/net/mcreator/superbwarfare/network/message/FireMessage.java b/src/main/java/net/mcreator/superbwarfare/network/message/FireMessage.java index 55114a604..a3f64b7c1 100644 --- a/src/main/java/net/mcreator/superbwarfare/network/message/FireMessage.java +++ b/src/main/java/net/mcreator/superbwarfare/network/message/FireMessage.java @@ -129,7 +129,7 @@ public class FireMessage { } if (handItem.getItem() == ModItems.JAVELIN.get() && player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom && tag.getInt("ammo") > 0) { - Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 384, 8); + Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 512, 8); if (seekingEntity != null) { tag.putString("TargetEntity", seekingEntity.getStringUUID()); tag.putBoolean("Seeking", true); diff --git a/src/main/java/net/mcreator/superbwarfare/tools/SeekTool.java b/src/main/java/net/mcreator/superbwarfare/tools/SeekTool.java index 72312de73..52e16d2f5 100644 --- a/src/main/java/net/mcreator/superbwarfare/tools/SeekTool.java +++ b/src/main/java/net/mcreator/superbwarfare/tools/SeekTool.java @@ -1,7 +1,6 @@ package net.mcreator.superbwarfare.tools; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; @@ -16,7 +15,7 @@ public class SeekTool { Vec3 pos = new Vec3(entity.getX(), entity.getY(), entity.getZ()); return level.getEntitiesOfClass(Entity.class, new AABB(pos, pos).inflate(seekRange), e -> true).stream() .filter(e -> { - if (calculateAngle(e, entity) < seekAngle && e instanceof LivingEntity && e != entity) { + if (calculateAngle(e, entity) < seekAngle && e != entity) { return level.clip(new ClipContext(entity.getEyePosition(), e.getEyePosition(), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() != HitResult.Type.BLOCK; } diff --git a/src/main/resources/assets/superbwarfare/sounds/ak_47/ak_47_fire_1p.ogg b/src/main/resources/assets/superbwarfare/sounds/ak_47/ak_47_fire_1p.ogg index 6eb3c9cae..058d31d2c 100644 Binary files a/src/main/resources/assets/superbwarfare/sounds/ak_47/ak_47_fire_1p.ogg and b/src/main/resources/assets/superbwarfare/sounds/ak_47/ak_47_fire_1p.ogg differ diff --git a/src/main/resources/assets/superbwarfare/sounds/ak_47/ak_47_fire_3p.ogg b/src/main/resources/assets/superbwarfare/sounds/ak_47/ak_47_fire_3p.ogg index 8a2038583..d0ed19976 100644 Binary files a/src/main/resources/assets/superbwarfare/sounds/ak_47/ak_47_fire_3p.ogg and b/src/main/resources/assets/superbwarfare/sounds/ak_47/ak_47_fire_3p.ogg differ diff --git a/src/main/resources/assets/superbwarfare/textures/entity/mle1934_damage.png b/src/main/resources/assets/superbwarfare/textures/entity/mle1934_damage.png new file mode 100644 index 000000000..43af4aeb5 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/textures/entity/mle1934_damage.png differ diff --git a/src/main/resources/assets/superbwarfare/textures/entity/sherman_damage.png b/src/main/resources/assets/superbwarfare/textures/entity/sherman_damage.png new file mode 100644 index 000000000..3ad41aaf9 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/textures/entity/sherman_damage.png differ