添加激光炮模型

This commit is contained in:
Atsuihsio 2024-12-05 03:01:25 +08:00
parent 678438307e
commit 562f24c3dd
13 changed files with 4170 additions and 3 deletions

View file

@ -0,0 +1,28 @@
package com.atsuishio.superbwarfare.client.layer;
import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.entity.AnnihilatorEntity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
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 software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.renderer.GeoRenderer;
import software.bernie.geckolib.renderer.layer.GeoRenderLayer;
public class AnnihilatorLayer extends GeoRenderLayer<AnnihilatorEntity> {
private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/annihilator_e.png");
public AnnihilatorLayer(GeoRenderer<AnnihilatorEntity> entityRenderer) {
super(entityRenderer);
}
@Override
public void render(PoseStack poseStack, AnnihilatorEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) {
RenderType glowRenderType = RenderType.energySwirl(LAYER,1,1);
getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1);
}
}

View file

@ -0,0 +1,61 @@
package com.atsuishio.superbwarfare.client.model.entity;
import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.entity.AnnihilatorEntity;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import software.bernie.geckolib.constant.DataTickets;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.model.GeoModel;
import software.bernie.geckolib.model.data.EntityModelData;
public class AnnihilatorModel extends GeoModel<AnnihilatorEntity> {
@Override
public ResourceLocation getAnimationResource(AnnihilatorEntity entity) {
return null;
}
@Override
public ResourceLocation getModelResource(AnnihilatorEntity entity) {
return ModUtils.loc("geo/annihilator.geo.json");
// Player player = Minecraft.getInstance().player;
//
// int distance = 0;
//
// if (player != null) {
// distance = (int) player.position().distanceTo(entity.position());
// }
//
// if (distance < 32) {
// return ModUtils.loc("geo/sherman.geo.json");
// } else if (distance < 64) {
// return ModUtils.loc("geo/sherman_lod1.geo.json");
// } else {
// return ModUtils.loc("geo/sherman_lod2.geo.json");
// }
}
@Override
public ResourceLocation getTextureResource(AnnihilatorEntity entity) {
return ModUtils.loc("textures/entity/annihilator.png");
}
@Override
public void setCustomAnimations(AnnihilatorEntity animatable, long instanceId, AnimationState<AnnihilatorEntity> animationState) {
CoreGeoBone bone = getAnimationProcessor().getBone("PaoGuan");
EntityModelData entityData = animationState.getData(DataTickets.ENTITY_MODEL_DATA);
bone.setRotX((entityData.headPitch()) * Mth.DEG_TO_RAD);
CoreGeoBone laser1 = getAnimationProcessor().getBone("laser1");
CoreGeoBone laser2 = getAnimationProcessor().getBone("laser2");
CoreGeoBone laser3 = getAnimationProcessor().getBone("laser3");
laser1.setScaleZ(512);
laser2.setScaleZ(512);
laser3.setScaleZ(512);
}
}

View file

@ -26,8 +26,8 @@ public class GunGrenadeModel extends GeoModel<GunGrenadeEntity> {
@Override
public void setCustomAnimations(GunGrenadeEntity animatable, long instanceId, AnimationState animationState) {
CoreGeoBone bone = getAnimationProcessor().getBone("bone");
bone.setScaleX(0.15f);
bone.setScaleY(0.15f);
bone.setScaleZ(0.15f);
bone.setScaleX(0.2f);
bone.setScaleY(0.2f);
bone.setScaleZ(0.2f);
}
}

View file

@ -0,0 +1,52 @@
package com.atsuishio.superbwarfare.client.renderer.entity;
import com.atsuishio.superbwarfare.client.layer.AnnihilatorLayer;
import com.atsuishio.superbwarfare.client.model.entity.AnnihilatorModel;
import com.atsuishio.superbwarfare.entity.AnnihilatorEntity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis;
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;
public class AnnihilatorRenderer extends GeoEntityRenderer<AnnihilatorEntity> {
public AnnihilatorRenderer(EntityRendererProvider.Context renderManager) {
super(renderManager, new AnnihilatorModel());
this.shadowRadius = 2f;
this.addRenderLayer(new AnnihilatorLayer(this));
// this.addRenderLayer(new Mk42DamageLayer(this));
}
@Override
public RenderType getRenderType(AnnihilatorEntity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
return RenderType.entityTranslucent(getTextureLocation(animatable));
}
@Override
public void preRender(PoseStack poseStack, AnnihilatorEntity entity, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green,
float blue, float alpha) {
float scale = 1f;
this.scaleHeight = scale;
this.scaleWidth = scale;
super.preRender(poseStack, entity, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha);
}
@Override
public void render(AnnihilatorEntity 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(AnnihilatorEntity entityLivingBaseIn) {
return 0.0F;
}
}

View file

@ -20,6 +20,8 @@ public class CannonConfig {
public static ForgeConfigSpec.IntValue MLE1934_HE_EXPLOSION_DAMAGE;
public static ForgeConfigSpec.IntValue MLE1934_HE_EXPLOSION_RADIUS;
public static ForgeConfigSpec.IntValue ANNIHILATOR_HP;
public static void init(ForgeConfigSpec.Builder builder) {
builder.push("mk_42");
@ -70,6 +72,12 @@ public class CannonConfig {
MLE1934_HE_EXPLOSION_RADIUS = builder.defineInRange("mle_1934_he_explosion_radius", 12, 1, 50);
builder.pop();
builder.push("annihilator");
builder.comment("The HealthPoint of ANNIHILATOR");
ANNIHILATOR_HP = builder.defineInRange("annihilator_hp", 4000, 1, 10000000);
builder.pop();
}
}

View file

@ -0,0 +1,507 @@
package com.atsuishio.superbwarfare.entity;
import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.server.CannonConfig;
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity;
import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
import com.atsuishio.superbwarfare.item.common.ammo.CannonShellItem;
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
import com.atsuishio.superbwarfare.tools.CustomExplosion;
import com.atsuishio.superbwarfare.tools.ParticleTool;
import com.atsuishio.superbwarfare.tools.SoundTool;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
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.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
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.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.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.network.PacketDistributor;
import net.minecraftforge.network.PlayMessages;
import org.joml.Vector3d;
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.util.GeckoLibUtil;
import java.util.Comparator;
public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntity {
public static final EntityDataAccessor<Integer> COOL_DOWN = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> TYPE = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.FLOAT);
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
public static final float MAX_HEALTH = CannonConfig.ANNIHILATOR_HP.get();
protected int interpolationSteps;
protected double serverYRot;
protected double serverXRot;
public AnnihilatorEntity(PlayMessages.SpawnEntity packet, Level world) {
this(ModEntities.ANNIHILATOR.get(), world);
}
public AnnihilatorEntity(EntityType<AnnihilatorEntity> type, Level world) {
super(type, world);
this.noCulling = true;
}
@Override
protected void defineSynchedData() {
this.entityData.define(COOL_DOWN, 0);
this.entityData.define(TYPE, 0);
this.entityData.define(HEALTH, MAX_HEALTH);
}
@Override
public void addAdditionalSaveData(CompoundTag compound) {
compound.putInt("CoolDown", 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) {
this.entityData.set(COOL_DOWN, compound.getInt("CoolDown"));
this.entityData.set(TYPE, compound.getInt("Type"));
if (compound.contains("Health")) {
this.entityData.set(HEALTH, compound.getFloat("Health"));
} else {
this.entityData.set(HEALTH, MAX_HEALTH);
}
}
@Override
public boolean canBeCollidedWith() {
return true;
}
@Override
public boolean canCollideWith(Entity pEntity) {
return (pEntity.canBeCollidedWith() || pEntity.isPushable()) && !this.isPassengerOfSameVehicle(pEntity);
}
@Override
protected float getEyeHeight(Pose pPose, EntityDimensions pSize) {
return 2.16F;
}
@Override
public Packet<ClientGamePacketListener> getAddEntityPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}
@Override
public double getPassengersRidingOffset() {
return super.getPassengersRidingOffset() - 0.075;
}
@Override
public boolean hurt(DamageSource source, float amount) {
if (this.level() instanceof ServerLevel serverLevel) {
ParticleTool.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 (source.is(ModDamageTypes.PROJECTILE_BOOM)) {
amount *= 0.5f;
}
if (source.is(ModDamageTypes.CANNON_FIRE)) {
amount *= 1.4f;
}
if (source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE)) {
amount *= 1.6f;
}
this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1);
this.entityData.set(HEALTH, this.entityData.get(HEALTH) - 0.5f * Math.max(amount - 150, 0));
return true;
}
@Override
public boolean isPickable() {
return !this.isRemoved();
}
@Override
public InteractionResult interact(Player player, InteractionHand hand) {
if (player.isShiftKeyDown()) {
if (player.getMainHandItem().is(ModItems.CROWBAR.get()) && this.getFirstPassenger() == null) {
ItemStack stack = ContainerBlockItem.createInstance(this);
if (!player.addItem(stack)) {
player.drop(stack, false);
}
this.discard();
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
return InteractionResult.PASS;
} else {
if (this.getFirstPassenger() == null) {
player.setXRot(this.getXRot());
player.setYRot(this.getYRot());
player.startRiding(this);
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
}
return InteractionResult.PASS;
}
@Override
public Vec3 getDeltaMovement() {
return new Vec3(0, Math.min(super.getDeltaMovement().y, 0), 0);
}
@Override
public void baseTick() {
super.baseTick();
if (this.entityData.get(COOL_DOWN) > 0) {
this.entityData.set(COOL_DOWN, this.entityData.get(COOL_DOWN) - 1);
}
this.move(MoverType.SELF, this.getDeltaMovement());
if (this.onGround()) {
this.setDeltaMovement(Vec3.ZERO);
} else {
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0));
}
if (this.entityData.get(HEALTH) <= 0.4 * CannonConfig.ANNIHILATOR_HP.get()) {
if (this.level() instanceof ServerLevel serverLevel) {
ParticleTool.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) <= 0.25 * CannonConfig.ANNIHILATOR_HP.get()) {
if (this.level() instanceof ServerLevel serverLevel) {
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
ParticleTool.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) <= 0.15 * CannonConfig.ANNIHILATOR_HP.get()) {
if (this.level() instanceof ServerLevel serverLevel) {
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
ParticleTool.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) <= 0.1 * CannonConfig.ANNIHILATOR_HP.get()) {
if (this.level() instanceof ServerLevel serverLevel) {
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false);
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false);
ParticleTool.sendParticle(serverLevel, ParticleTypes.FLAME, this.getX(), this.getY() + 3.2, this.getZ(), 4, 0.6, 0.1, 0.6, 0.05, false);
ParticleTool.sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 3, this.getZ(), 4, 0.1, 0.1, 0.1, 0.4, false);
}
if (this.tickCount % 15 == 0) {
this.level().playSound(null, this.getOnPos(), SoundEvents.FIRE_AMBIENT, SoundSource.PLAYERS, 1, 1);
}
this.entityData.set(HEALTH, this.entityData.get(HEALTH) - 0.1f);
} else {
this.entityData.set(HEALTH, Math.min(this.entityData.get(HEALTH) + 0.05f, MAX_HEALTH));
}
if (this.entityData.get(HEALTH) <= 0) {
this.ejectPassengers();
destroy();
}
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(), 25f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : 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) {
return;
}
Level level = player.level();
if (level instanceof ServerLevel server) {
ItemStack stack = player.getMainHandItem();
if (!(stack.getItem() instanceof CannonShellItem)) {
return;
}
float hitDamage = 0;
float explosionRadius = 0;
float explosionDamage = 0;
float fireProbability = 0;
int fireTime = 0;
int durability = 0;
boolean salvoShoot = false;
if (stack.is(ModItems.HE_5_INCHES.get())) {
hitDamage = CannonConfig.MLE1934_HE_DAMAGE.get();
explosionRadius = CannonConfig.MLE1934_HE_EXPLOSION_RADIUS.get();
explosionDamage = CannonConfig.MLE1934_HE_EXPLOSION_DAMAGE.get();
fireProbability = 0.24F;
fireTime = 5;
durability = 1;
salvoShoot = stack.getCount() > 1 || player.isCreative();
}
if (stack.is(ModItems.AP_5_INCHES.get())) {
hitDamage = CannonConfig.MLE1934_AP_DAMAGE.get();
explosionRadius = CannonConfig.MLE1934_AP_EXPLOSION_RADIUS.get();
explosionDamage = CannonConfig.MLE1934_AP_EXPLOSION_DAMAGE.get();
fireProbability = 0;
fireTime = 0;
durability = 70;
salvoShoot = stack.getCount() > 1 || player.isCreative();
}
if (!player.isCreative()) {
stack.shrink(salvoShoot ? 2 : 1);
}
float yRot = this.getYRot();
if (yRot < 0) {
yRot += 360;
}
yRot = yRot + 90 % 360;
var leftPos = new Vector3d(0, 0, -0.45);
leftPos.rotateZ(-this.getXRot() * Mth.DEG_TO_RAD);
leftPos.rotateY(-yRot * Mth.DEG_TO_RAD);
// 左炮管
CannonShellEntity entityToSpawnLeft = new CannonShellEntity(ModEntities.CANNON_SHELL.get(),
player, level, hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime).durability(durability);
entityToSpawnLeft.setPos(this.getX() + leftPos.x,
this.getEyeY() - 0.2 + leftPos.y,
this.getZ() + leftPos.z);
entityToSpawnLeft.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 15, 0.05f);
level.addFreshEntity(entityToSpawnLeft);
var leftPosP1 = new Vector3d(7, 0, -0.45);
leftPosP1.rotateZ(-this.getXRot() * Mth.DEG_TO_RAD);
leftPosP1.rotateY(-yRot * Mth.DEG_TO_RAD);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE,
this.getX() + leftPosP1.x,
this.getEyeY() - 0.2 + leftPosP1.y,
this.getZ() + leftPosP1.z,
10, 0.4, 0.4, 0.4, 0.0075);
server.sendParticles(ParticleTypes.CLOUD,
this.getX() + leftPosP1.x,
this.getEyeY() - 0.2 + leftPosP1.y,
this.getZ() + leftPosP1.z,
10, 0.4, 0.4, 0.4, 0.0075);
int count = 5;
for (float i = 9.5f; i < 14; i += .5f) {
var leftPosP = new Vector3d(i, 0, -0.45);
leftPosP.rotateZ(-this.getXRot() * Mth.DEG_TO_RAD);
leftPosP.rotateY(-yRot * Mth.DEG_TO_RAD);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE,
this.getX() + leftPosP.x,
this.getEyeY() - 0.2 + leftPosP.y,
this.getZ() + leftPosP.z,
Mth.clamp(count--, 1, 5), 0.1, 0.1, 0.1, 0.002);
}
// 右炮管
if (salvoShoot) {
var rightPos = new Vector3d(0, 0, 0.45);
rightPos.rotateZ(-this.getXRot() * Mth.DEG_TO_RAD);
rightPos.rotateY(-yRot * Mth.DEG_TO_RAD);
CannonShellEntity entityToSpawnRight = new CannonShellEntity(ModEntities.CANNON_SHELL.get(),
player, level, hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime).durability(durability);
entityToSpawnRight.setPos(this.getX() + rightPos.x,
this.getEyeY() - 0.2 + rightPos.y,
this.getZ() + rightPos.z);
entityToSpawnRight.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 15, 0.05f);
level.addFreshEntity(entityToSpawnRight);
var rightPosP1 = new Vector3d(7, 0, 0.45);
rightPosP1.rotateZ(-this.getXRot() * Mth.DEG_TO_RAD);
rightPosP1.rotateY(-yRot * Mth.DEG_TO_RAD);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE,
this.getX() + rightPosP1.x,
this.getEyeY() - 0.2 + rightPosP1.y,
this.getZ() + rightPosP1.z,
10, 0.4, 0.4, 0.4, 0.0075);
server.sendParticles(ParticleTypes.CLOUD,
this.getX() + rightPosP1.x,
this.getEyeY() - 0.2 + rightPosP1.y,
this.getZ() + rightPosP1.z,
10, 0.4, 0.4, 0.4, 0.0075);
int countR = 5;
for (float i = 9.5f; i < 14; i += .5f) {
var rightPosP = new Vector3d(i, 0, 0.45);
rightPosP.rotateZ(-this.getXRot() * Mth.DEG_TO_RAD);
rightPosP.rotateY(-yRot * Mth.DEG_TO_RAD);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE,
this.getX() + rightPosP.x,
this.getEyeY() - 0.2 + rightPosP.y,
this.getZ() + rightPosP.z,
Mth.clamp(countR--, 1, 5), 0.1, 0.1, 0.1, 0.002);
}
this.entityData.set(TYPE, 1);
} else {
this.entityData.set(TYPE, -1);
}
if (player instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, ModSounds.MK_42_FIRE_1P.get(), 2, 1);
ModUtils.queueServerWork(44, () -> SoundTool.playLocalSound(serverPlayer, ModSounds.MK_42_RELOAD.get(), 2, 1));
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_FIRE_3P.get(), SoundSource.PLAYERS, 6, 1);
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_FAR.get(), SoundSource.PLAYERS, 16, 1);
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_VERYFAR.get(), SoundSource.PLAYERS, 32, 1);
}
this.entityData.set(COOL_DOWN, 74);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE,
this.getX() + 5 * this.getLookAngle().x,
this.getY(),
this.getZ() + 5 * this.getLookAngle().z,
100, 7, 0.02, 7, 0.005);
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
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()));
}
}
}
}
@Override
public void lerpTo(double x, double y, double z, float yaw, float pitch, int interpolationSteps, boolean interpolate) {
serverYRot = yaw;
serverXRot = pitch;
this.interpolationSteps = 10;
}
public void travel() {
Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
if (!(passenger instanceof LivingEntity entity)) return;
float passengerY = entity.getYHeadRot();
if (passengerY > 180.0f) {
passengerY -= 360.0f;
} else if (passengerY < -180.0f) {
passengerY += 360.0f;
}
float diffY = passengerY - this.getYRot();
float diffX = entity.getXRot() - 1.2f - this.getXRot();
if (diffY > 180.0f) {
diffY -= 360.0f;
} else if (diffY < -180.0f) {
diffY += 360.0f;
}
diffY = Mth.clamp(diffY * 0.15f, -0.6f, 0.6f);
diffX = diffX * 0.15f;
this.setYRot(this.getYRot() + diffY);
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -2f, 2f), -45, 5));
this.setRot(this.getYRot(), this.getXRot());
}
protected void clampRotation(Entity entity) {
float f = Mth.wrapDegrees(entity.getXRot());
float f1 = Mth.clamp(f, -45.0F, 5.0F);
entity.xRotO += f1 - f;
entity.setXRot(entity.getXRot() + f1 - f);
}
@Override
public void onPassengerTurned(Entity entity) {
this.clampRotation(entity);
}
// private PlayState movementPredicate(AnimationState<AnnihilatorEntity> event) {
// if (this.entityData.get(COOL_DOWN) > 64) {
// if (this.entityData.get(TYPE) == 1) {
// return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mle1934.salvo_fire"));
// } else {
// return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mle1934.fire"));
// }
// }
// return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mle1934.idle"));
// }
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
// data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate));
}
@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return this.cache;
}
}

View file

@ -34,6 +34,8 @@ public class ModEntities {
EntityType.Builder.<Mk42Entity>of(Mk42Entity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(5124).setUpdateInterval(3).setCustomClientFactory(Mk42Entity::new).fireImmune().sized(3.4f, 3.5f));
public static final RegistryObject<EntityType<Mle1934Entity>> MLE_1934 = register("mle_1934",
EntityType.Builder.<Mle1934Entity>of(Mle1934Entity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(Mle1934Entity::new).fireImmune().sized(4.5f, 2.8f));
public static final RegistryObject<EntityType<AnnihilatorEntity>> ANNIHILATOR = register("annihilator",
EntityType.Builder.<AnnihilatorEntity>of(AnnihilatorEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(AnnihilatorEntity::new).fireImmune().sized(13f, 4.2f));
public static final RegistryObject<EntityType<DroneEntity>> DRONE = register("drone",
EntityType.Builder.<DroneEntity>of(DroneEntity::new, MobCategory.CREATURE).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(DroneEntity::new).sized(0.6f, 0.2f));

View file

@ -28,5 +28,6 @@ public class ModEntityRenderers {
event.registerEntityRenderer(ModEntities.MLE_1934.get(), Mle1934Renderer::new);
event.registerEntityRenderer(ModEntities.JAVELIN_MISSILE.get(), JavelinMissileRenderer::new);
event.registerEntityRenderer(ModEntities.LASER.get(), LaserEntityRenderer::new);
event.registerEntityRenderer(ModEntities.ANNIHILATOR.get(), AnnihilatorRenderer::new);
}
}

View file

@ -105,6 +105,7 @@ public class ModTabs {
if (registryObject.get() == ModItems.CONTAINER.get()) {
output.accept(ContainerBlockItem.createMk42Instance());
output.accept(ContainerBlockItem.createMle1934Instance());
output.accept(ContainerBlockItem.createAnnihilatorInstance());
} else {
output.accept(registryObject.get());
if (registryObject.get() == ModItems.ARMOR_PLATE.get()) {

View file

@ -97,4 +97,8 @@ public class ContainerBlockItem extends BlockItem implements GeoItem {
public static ItemStack createMle1934Instance() {
return createInstance(ModEntities.MLE_1934.get());
}
public static ItemStack createAnnihilatorInstance() {
return createInstance(ModEntities.ANNIHILATOR.get());
}
}

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B