将火炮上的玩家隐藏到火炮内部并免疫伤害,修复阔剑bug

This commit is contained in:
Atsuihsio 2024-11-29 02:51:08 +08:00
parent dbd4a7661d
commit a4057cbfd5
10 changed files with 49 additions and 25 deletions

View file

@ -13,5 +13,5 @@ mod_description=A Warfare Mod
minecraft_version=1.20.1 minecraft_version=1.20.1
jei_version=15.2.0.27 jei_version=15.2.0.27
cloth_config_version=11.1.106 cloth_config_version=11.1.106
mod_version=0.2.9 mod_version=0.3.0
mod_authors=Atsuishio, Roki27, Light_Quanta mod_authors=Atsuishio, Roki27, Light_Quanta

View file

@ -1,12 +1,12 @@
package com.atsuishio.superbwarfare.client.renderer.entity; package com.atsuishio.superbwarfare.client.renderer.entity;
import com.atsuishio.superbwarfare.entity.Mk42Entity; import com.atsuishio.superbwarfare.entity.Mk42Entity;
import com.atsuishio.superbwarfare.entity.layer.Mk42DamageLayer;
import com.atsuishio.superbwarfare.entity.layer.Mk42Layer; import com.atsuishio.superbwarfare.entity.layer.Mk42Layer;
import com.atsuishio.superbwarfare.entity.model.Mk42Model; import com.atsuishio.superbwarfare.entity.model.Mk42Model;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis; import com.mojang.math.Axis;
import com.atsuishio.superbwarfare.entity.layer.Mk42DamageLayer;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRendererProvider;
@ -19,7 +19,7 @@ public class Mk42Renderer extends GeoEntityRenderer<Mk42Entity> {
public Mk42Renderer(EntityRendererProvider.Context renderManager) { public Mk42Renderer(EntityRendererProvider.Context renderManager) {
super(renderManager, new Mk42Model()); super(renderManager, new Mk42Model());
this.shadowRadius = 3f; this.shadowRadius = 2f;
this.addRenderLayer(new Mk42Layer(this)); this.addRenderLayer(new Mk42Layer(this));
this.addRenderLayer(new Mk42DamageLayer(this)); this.addRenderLayer(new Mk42DamageLayer(this));
} }

View file

@ -1,12 +1,12 @@
package com.atsuishio.superbwarfare.client.renderer.entity; package com.atsuishio.superbwarfare.client.renderer.entity;
import com.atsuishio.superbwarfare.entity.Mle1934Entity; import com.atsuishio.superbwarfare.entity.Mle1934Entity;
import com.atsuishio.superbwarfare.entity.layer.Mle1934DamageLayer;
import com.atsuishio.superbwarfare.entity.layer.Mle1934Layer; import com.atsuishio.superbwarfare.entity.layer.Mle1934Layer;
import com.atsuishio.superbwarfare.entity.model.Mle1934Model; import com.atsuishio.superbwarfare.entity.model.Mle1934Model;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis; import com.mojang.math.Axis;
import com.atsuishio.superbwarfare.entity.layer.Mle1934DamageLayer;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRendererProvider;
@ -18,7 +18,7 @@ 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 = 3f; this.shadowRadius = 2f;
this.addRenderLayer(new Mle1934Layer(this)); this.addRenderLayer(new Mle1934Layer(this));
this.addRenderLayer(new Mle1934DamageLayer(this)); this.addRenderLayer(new Mle1934DamageLayer(this));
} }

View file

@ -33,6 +33,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Comparator; import java.util.Comparator;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@ -78,6 +79,9 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity,
return false; return false;
if (source.is(DamageTypes.WITHER_SKULL)) if (source.is(DamageTypes.WITHER_SKULL))
return false; return false;
if (source.is(ModDamageTypes.CUSTOM_EXPLOSION) || source.is(ModDamageTypes.MINE) || source.is(ModDamageTypes.PROJECTILE_BOOM)) {
amount *= 0.2f;
}
if (this.level() instanceof ServerLevel serverLevel) { if (this.level() instanceof ServerLevel serverLevel) {
ParticleTool.sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.2, this.getZ(), 2, 0.02, 0.02, 0.02, 0.1, false); ParticleTool.sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.2, this.getZ(), 2, 0.02, 0.02, 0.02, 0.1, false);
@ -168,7 +172,7 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity,
&& target instanceof LivingEntity && target instanceof LivingEntity
&& !(target instanceof TargetEntity) && !(target instanceof TargetEntity)
&& !(target instanceof Player player && (player.isCreative() || player.isSpectator())) && !(target instanceof Player player && (player.isCreative() || player.isSpectator()))
&& (!this.isAlliedTo(target) || target.getTeam() == null || target.getTeam().getName().equals("TDM")) && (!Objects.requireNonNull(this.getOwner()).isAlliedTo(target) || target.getTeam() == null || target.getTeam().getName().equals("TDM"))
&& !target.isShiftKeyDown(); && !target.isShiftKeyDown();
if (!condition) continue; if (!condition) continue;
@ -214,8 +218,8 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity,
public void destroy() { public void destroy() {
if (level() instanceof ServerLevel) { if (level() instanceof ServerLevel) {
CustomExplosion explosion = new CustomExplosion(this.level(), null, CustomExplosion explosion = new CustomExplosion(this.level(), null,
ModDamageTypes.causeMineDamage(this.level().registryAccess(), this), 15.0f, ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), null, null), 25.0f,
this.getX(), this.getY(), this.getZ(), 7.5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
explosion.explode(); explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false); explosion.finalizeExplosion(false);
@ -227,7 +231,7 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity,
private void triggerExplode(Entity target) { private void triggerExplode(Entity target) {
CustomExplosion explosion = new CustomExplosion(this.level(), this, CustomExplosion explosion = new CustomExplosion(this.level(), this,
ModDamageTypes.causeMineDamage(this.level().registryAccess(), this.getOwner()), 140f, ModDamageTypes.causeMineDamage(this.level().registryAccess(), this.getOwner()), 140f,
target.getX(), target.getY(), target.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); target.getX(), target.getY(), target.getZ(), 4f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
explosion.explode(); explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false); explosion.finalizeExplosion(false);

View file

@ -108,7 +108,7 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
@Override @Override
public double getPassengersRidingOffset() { public double getPassengersRidingOffset() {
return super.getPassengersRidingOffset() - 0.25; return super.getPassengersRidingOffset() - 1.25;
} }
@Override @Override

View file

@ -112,7 +112,7 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity {
@Override @Override
public double getPassengersRidingOffset() { public double getPassengersRidingOffset() {
return super.getPassengersRidingOffset() - 0.075; return super.getPassengersRidingOffset() - 1.075;
} }
@Override @Override

View file

@ -1,12 +1,12 @@
package com.atsuishio.superbwarfare.entity.projectile; package com.atsuishio.superbwarfare.entity.projectile;
import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
import com.atsuishio.superbwarfare.tools.ParticleTool;
import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig; import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
import com.atsuishio.superbwarfare.entity.AnimatedEntity; import com.atsuishio.superbwarfare.entity.AnimatedEntity;
import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
import com.atsuishio.superbwarfare.tools.CustomExplosion; import com.atsuishio.superbwarfare.tools.CustomExplosion;
import com.atsuishio.superbwarfare.tools.ParticleTool;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
@ -147,7 +147,7 @@ public class CannonShellEntity extends ThrowableItemProjectile implements GeoEnt
float hardness = this.level().getBlockState(BlockPos.containing(x, y, z)).getBlock().defaultDestroyTime(); float hardness = this.level().getBlockState(BlockPos.containing(x, y, z)).getBlock().defaultDestroyTime();
this.durability -= (int) hardness; this.durability -= (int) hardness;
if (ExplosionDestroyConfig.EXPLOSION_DESTROY.get()) { if (ExplosionDestroyConfig.EXPLOSION_DESTROY.get() && hardness != -1 && hardness <= 50) {
BlockPos _pos = BlockPos.containing(x, y, z); BlockPos _pos = BlockPos.containing(x, y, z);
Block.dropResources(this.level().getBlockState(_pos), this.level(), BlockPos.containing(x, y, z), null); Block.dropResources(this.level().getBlockState(_pos), this.level(), BlockPos.containing(x, y, z), null);
this.level().destroyBlock(_pos, false); this.level().destroyBlock(_pos, false);

View file

@ -616,6 +616,10 @@ public class ClientEventHandler {
event.setCanceled(true); event.setCanceled(true);
} }
} }
if (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity) {
event.setCanceled(true);
}
} }
private static void handleWeaponSway(LivingEntity entity) { private static void handleWeaponSway(LivingEntity entity) {

View file

@ -1,21 +1,22 @@
package com.atsuishio.superbwarfare.event; package com.atsuishio.superbwarfare.event;
import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.common.GameplayConfig;
import com.atsuishio.superbwarfare.entity.ICannonEntity;
import com.atsuishio.superbwarfare.entity.TargetEntity; import com.atsuishio.superbwarfare.entity.TargetEntity;
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.network.ModVariables; import com.atsuishio.superbwarfare.network.ModVariables;
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage; import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
import com.atsuishio.superbwarfare.network.message.PlayerGunKillMessage;
import com.atsuishio.superbwarfare.tools.DamageTypeTool;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.SoundTool;
import com.atsuishio.superbwarfare.config.common.GameplayConfig;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.network.message.DrawClientMessage; import com.atsuishio.superbwarfare.network.message.DrawClientMessage;
import com.atsuishio.superbwarfare.network.message.PlayerGunKillMessage;
import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.DamageTypeTool;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.SoundTool;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ClientboundStopSoundPacket; import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
@ -45,11 +46,21 @@ import java.text.DecimalFormat;
@Mod.EventBusSubscriber @Mod.EventBusSubscriber
public class LivingEventHandler { public class LivingEventHandler {
@SubscribeEvent
public static void onEntityAttacked(LivingAttackEvent event) {
if (event.getEntity().getVehicle() != null && event.getEntity().getVehicle() instanceof ICannonEntity) {
event.setCanceled(true);
}
}
@SubscribeEvent @SubscribeEvent
public static void onEntityHurt(LivingHurtEvent event) { public static void onEntityHurt(LivingHurtEvent event) {
if (event == null || event.getEntity() == null) { if (event == null || event.getEntity() == null) {
return; return;
} }
if (event.getEntity().getVehicle() != null && event.getEntity().getVehicle() instanceof ICannonEntity) {
event.setCanceled(true);
}
handleGunPerksWhenHurt(event); handleGunPerksWhenHurt(event);
renderDamageIndicator(event); renderDamageIndicator(event);

View file

@ -1,8 +1,9 @@
package com.atsuishio.superbwarfare.mixins; package com.atsuishio.superbwarfare.mixins;
import com.atsuishio.superbwarfare.entity.DroneEntity;
import com.atsuishio.superbwarfare.entity.ICannonEntity;
import com.atsuishio.superbwarfare.entity.Mk42Entity; import com.atsuishio.superbwarfare.entity.Mk42Entity;
import com.atsuishio.superbwarfare.entity.Mle1934Entity; import com.atsuishio.superbwarfare.entity.Mle1934Entity;
import com.atsuishio.superbwarfare.entity.DroneEntity;
import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.init.ModTags;
@ -41,7 +42,11 @@ public abstract class CameraMixin {
if (player != null) { if (player != null) {
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) { if (player.getVehicle() != null && mc.player.getVehicle() instanceof ICannonEntity && Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
setRotation(player.getViewYRot(partialTicks), player.getViewXRot(partialTicks));
setPosition(player.getX(), player.getEyeY() + 1, player.getZ());
info.cancel();
} else if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
DroneEntity drone = EntityFindUtil.findDrone(player.level(), stack.getOrCreateTag().getString("LinkedDrone")); DroneEntity drone = EntityFindUtil.findDrone(player.level(), stack.getOrCreateTag().getString("LinkedDrone"));
if (drone != null) { if (drone != null) {
@ -64,11 +69,11 @@ public abstract class CameraMixin {
@Inject(method = "setup", at = @At("TAIL")) @Inject(method = "setup", at = @At("TAIL"))
public void ia$setup(BlockGetter area, Entity entity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) { public void ia$setup(BlockGetter area, Entity entity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
if (thirdPerson && entity.getVehicle() instanceof Mk42Entity) { if (thirdPerson && entity.getVehicle() instanceof Mk42Entity) {
move(-getMaxZoom(8), 1.0, 0.0); move(-getMaxZoom(8), 2, 0.0);
return; return;
} }
if (thirdPerson && entity.getVehicle() instanceof Mle1934Entity) { if (thirdPerson && entity.getVehicle() instanceof Mle1934Entity) {
move(-getMaxZoom(10), 1.3, 0.0); move(-getMaxZoom(10), 2.3, 0.0);
return; return;
} }
if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && entity instanceof Player player && player.getMainHandItem().is(ModTags.Items.GUN)) { if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && entity instanceof Player player && player.getMainHandItem().is(ModTags.Items.GUN)) {