修复渲染问题
This commit is contained in:
parent
e79fcf88ee
commit
7f2fc4c9aa
10 changed files with 41 additions and 19 deletions
|
@ -16,6 +16,7 @@ import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||||
|
|
||||||
public class Mle1934Renderer extends GeoEntityRenderer<Mle1934Entity> {
|
public class Mle1934Renderer extends GeoEntityRenderer<Mle1934Entity> {
|
||||||
|
|
||||||
public Mle1934Renderer(EntityRendererProvider.Context renderManager) {
|
public Mle1934Renderer(EntityRendererProvider.Context renderManager) {
|
||||||
super(renderManager, new Mle1934Model());
|
super(renderManager, new Mle1934Model());
|
||||||
this.shadowRadius = 2f;
|
this.shadowRadius = 2f;
|
||||||
|
|
|
@ -31,8 +31,10 @@ import java.text.DecimalFormat;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||||
public class CannonHudOverlay {
|
public class CannonHudOverlay {
|
||||||
|
|
||||||
public static float health = 0;
|
public static float health = 0;
|
||||||
public static float maxHealth = 0;
|
public static float maxHealth = 0;
|
||||||
|
|
||||||
private static final ResourceLocation ARMOR = ModUtils.loc("textures/screens/armor.png");
|
private static final ResourceLocation ARMOR = ModUtils.loc("textures/screens/armor.png");
|
||||||
private static final ResourceLocation HEALTH = ModUtils.loc("textures/screens/armor_value.png");
|
private static final ResourceLocation HEALTH = ModUtils.loc("textures/screens/armor_value.png");
|
||||||
private static final ResourceLocation HEALTH_FRAME = ModUtils.loc("textures/screens/armor_value_frame.png");
|
private static final ResourceLocation HEALTH_FRAME = ModUtils.loc("textures/screens/armor_value_frame.png");
|
||||||
|
|
|
@ -59,6 +59,7 @@ import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DroneEntity extends LivingEntity implements GeoEntity {
|
public class DroneEntity extends LivingEntity implements GeoEntity {
|
||||||
|
|
||||||
public static final EntityDataAccessor<Boolean> LINKED = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.BOOLEAN);
|
public static final EntityDataAccessor<Boolean> LINKED = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.BOOLEAN);
|
||||||
public static final EntityDataAccessor<String> CONTROLLER = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.STRING);
|
public static final EntityDataAccessor<String> CONTROLLER = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.STRING);
|
||||||
public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.INT);
|
||||||
|
@ -74,7 +75,6 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
|
||||||
private boolean move = false;
|
private boolean move = false;
|
||||||
public static double lastTickSpeed = 0;
|
public static double lastTickSpeed = 0;
|
||||||
|
|
||||||
|
|
||||||
public DroneEntity(PlayMessages.SpawnEntity packet, Level world) {
|
public DroneEntity(PlayMessages.SpawnEntity packet, Level world) {
|
||||||
this(ModEntities.DRONE.get(), world);
|
this(ModEntities.DRONE.get(), world);
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,6 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
|
||||||
this.entityData.set(ROT_Z, compound.getFloat("rotZ"));
|
this.entityData.set(ROT_Z, compound.getFloat("rotZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Vector3f getForwardDirection() {
|
public Vector3f getForwardDirection() {
|
||||||
return new Vector3f(
|
return new Vector3f(
|
||||||
Mth.sin(-getYRot() * ((float) Math.PI / 180)),
|
Mth.sin(-getYRot() * ((float) Math.PI / 180)),
|
||||||
|
@ -183,7 +182,6 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
|
||||||
).normalize();
|
).normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Vector3f getRightDirection() {
|
public Vector3f getRightDirection() {
|
||||||
return new Vector3f(
|
return new Vector3f(
|
||||||
Mth.cos(-getYRot() * ((float) Math.PI / 180)),
|
Mth.cos(-getYRot() * ((float) Math.PI / 180)),
|
||||||
|
|
|
@ -3,5 +3,6 @@ package com.atsuishio.superbwarfare.entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
public interface ICannonEntity {
|
public interface ICannonEntity {
|
||||||
|
|
||||||
void cannonShoot(Player player);
|
void cannonShoot(Player player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,9 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
public static final EntityDataAccessor<Integer> COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT);
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
|
||||||
public static final float MAX_HEALTH = CannonConfig.MK42_HP.get();
|
public static final float MAX_HEALTH = CannonConfig.MK42_HP.get();
|
||||||
|
|
||||||
protected int interpolationSteps;
|
protected int interpolationSteps;
|
||||||
protected double serverYRot;
|
protected double serverYRot;
|
||||||
protected double serverXRot;
|
protected double serverXRot;
|
||||||
|
|
|
@ -486,8 +486,6 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
this.clampRotation(entity);
|
this.clampRotation(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private PlayState movementPredicate(AnimationState<Mle1934Entity> event) {
|
private PlayState movementPredicate(AnimationState<Mle1934Entity> event) {
|
||||||
if (this.entityData.get(COOL_DOWN) > 64) {
|
if (this.entityData.get(COOL_DOWN) > 64) {
|
||||||
if (this.entityData.get(TYPE) == 1) {
|
if (this.entityData.get(TYPE) == 1) {
|
||||||
|
|
|
@ -46,6 +46,7 @@ import software.bernie.geckolib.core.object.PlayState;
|
||||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity {
|
public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity {
|
||||||
|
|
||||||
public static final EntityDataAccessor<Integer> FIRE_TIME = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> FIRE_TIME = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Float> PITCH = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> PITCH = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.FLOAT);
|
||||||
public static final EntityDataAccessor<Float> Y_ROT = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> Y_ROT = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.FLOAT);
|
||||||
|
|
|
@ -35,6 +35,7 @@ import software.bernie.geckolib.core.object.PlayState;
|
||||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
public class SenpaiEntity extends Monster implements GeoEntity, AnimatedEntity {
|
public class SenpaiEntity extends Monster implements GeoEntity, AnimatedEntity {
|
||||||
|
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
|
||||||
public SenpaiEntity(PlayMessages.SpawnEntity packet, Level world) {
|
public SenpaiEntity(PlayMessages.SpawnEntity packet, Level world) {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.entity.layer;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.config.server.CannonConfig;
|
import com.atsuishio.superbwarfare.config.server.CannonConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.Mk42Entity;
|
|
||||||
import com.atsuishio.superbwarfare.entity.Mle1934Entity;
|
import com.atsuishio.superbwarfare.entity.Mle1934Entity;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
@ -16,7 +15,8 @@ import software.bernie.geckolib.renderer.GeoRenderer;
|
||||||
import software.bernie.geckolib.renderer.layer.GeoRenderLayer;
|
import software.bernie.geckolib.renderer.layer.GeoRenderLayer;
|
||||||
|
|
||||||
public class Mle1934DamageLayer extends GeoRenderLayer<Mle1934Entity> {
|
public class Mle1934DamageLayer extends GeoRenderLayer<Mle1934Entity> {
|
||||||
private static final ResourceLocation LAYER = new ResourceLocation(ModUtils.MODID, "textures/entity/mle1934_damage.png");
|
|
||||||
|
private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/mle1934_damage.png");
|
||||||
|
|
||||||
public Mle1934DamageLayer(GeoRenderer<Mle1934Entity> entityRenderer) {
|
public Mle1934DamageLayer(GeoRenderer<Mle1934Entity> entityRenderer) {
|
||||||
super(entityRenderer);
|
super(entityRenderer);
|
||||||
|
@ -25,7 +25,7 @@ public class Mle1934DamageLayer extends GeoRenderLayer<Mle1934Entity> {
|
||||||
@Override
|
@Override
|
||||||
public void render(PoseStack poseStack, Mle1934Entity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) {
|
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);
|
RenderType glowRenderType = RenderType.entityTranslucent(LAYER);
|
||||||
float heal = Mth.clamp((0.3f * CannonConfig.MLE1934_HP.get() - animatable.getEntityData().get(Mk42Entity.HEALTH)) * 0.000007f * CannonConfig.MLE1934_HP.get(), 0.1f, 1);
|
float heal = Mth.clamp((0.3f * CannonConfig.MLE1934_HP.get() - animatable.getEntityData().get(Mle1934Entity.HEALTH)) * 0.000007f * CannonConfig.MLE1934_HP.get(), 0.1f, 1);
|
||||||
getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, heal);
|
getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, heal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.level.ClipContext;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
@ -49,6 +50,23 @@ public class LaserEntity extends AbstractLaserEntity {
|
||||||
|
|
||||||
if (this.tickCount >= this.getCountDown()) {
|
if (this.tickCount >= this.getCountDown()) {
|
||||||
this.calculateEndPos(RADIUS);
|
this.calculateEndPos(RADIUS);
|
||||||
|
|
||||||
|
CustomHitResult result = new CustomHitResult();
|
||||||
|
result.setBlockHit(this.level().clip(new ClipContext(new Vec3(getX(), getY(), getZ()), new Vec3(endPosX, endPosY, endPosZ),
|
||||||
|
ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)));
|
||||||
|
if (result.getBlockHit() != null) {
|
||||||
|
Vec3 hitVec = result.getBlockHit().getLocation();
|
||||||
|
collidePosX = hitVec.x;
|
||||||
|
collidePosY = hitVec.y;
|
||||||
|
collidePosZ = hitVec.z;
|
||||||
|
blockSide = result.getBlockHit().getDirection();
|
||||||
|
} else {
|
||||||
|
collidePosX = endPosX;
|
||||||
|
collidePosY = endPosY;
|
||||||
|
collidePosZ = endPosZ;
|
||||||
|
blockSide = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.blockSide != null) {
|
if (this.blockSide != null) {
|
||||||
this.spawnExplosionParticles();
|
this.spawnExplosionParticles();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue