From a4057cbfd51ecb1e8b02e1afcbefc8415bb860ee Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Fri, 29 Nov 2024 02:51:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E7=81=AB=E7=82=AE=E4=B8=8A=E7=9A=84?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6=E9=9A=90=E8=97=8F=E5=88=B0=E7=81=AB=E7=82=AE?= =?UTF-8?q?=E5=86=85=E9=83=A8=E5=B9=B6=E5=85=8D=E7=96=AB=E4=BC=A4=E5=AE=B3?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=98=94=E5=89=91bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../client/renderer/entity/Mk42Renderer.java | 4 ++-- .../renderer/entity/Mle1934Renderer.java | 4 ++-- .../superbwarfare/entity/ClaymoreEntity.java | 12 ++++++---- .../superbwarfare/entity/Mk42Entity.java | 2 +- .../superbwarfare/entity/Mle1934Entity.java | 2 +- .../entity/projectile/CannonShellEntity.java | 8 +++---- .../event/ClientEventHandler.java | 4 ++++ .../event/LivingEventHandler.java | 23 ++++++++++++++----- .../superbwarfare/mixins/CameraMixin.java | 13 +++++++---- 10 files changed, 49 insertions(+), 25 deletions(-) diff --git a/gradle.properties b/gradle.properties index c9cb0cca5..46968edab 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,5 +13,5 @@ mod_description=A Warfare Mod minecraft_version=1.20.1 jei_version=15.2.0.27 cloth_config_version=11.1.106 -mod_version=0.2.9 +mod_version=0.3.0 mod_authors=Atsuishio, Roki27, Light_Quanta \ No newline at end of file diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mk42Renderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mk42Renderer.java index 058353583..0726906f0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mk42Renderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mk42Renderer.java @@ -1,12 +1,12 @@ package com.atsuishio.superbwarfare.client.renderer.entity; 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.model.Mk42Model; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; -import com.atsuishio.superbwarfare.entity.layer.Mk42DamageLayer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRendererProvider; @@ -19,7 +19,7 @@ public class Mk42Renderer extends GeoEntityRenderer { public Mk42Renderer(EntityRendererProvider.Context renderManager) { super(renderManager, new Mk42Model()); - this.shadowRadius = 3f; + this.shadowRadius = 2f; this.addRenderLayer(new Mk42Layer(this)); this.addRenderLayer(new Mk42DamageLayer(this)); } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java index 50ec481ea..6008b20ea 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/Mle1934Renderer.java @@ -1,12 +1,12 @@ package com.atsuishio.superbwarfare.client.renderer.entity; 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.model.Mle1934Model; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; -import com.atsuishio.superbwarfare.entity.layer.Mle1934DamageLayer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRendererProvider; @@ -18,7 +18,7 @@ import software.bernie.geckolib.renderer.GeoEntityRenderer; public class Mle1934Renderer extends GeoEntityRenderer { public Mle1934Renderer(EntityRendererProvider.Context renderManager) { super(renderManager, new Mle1934Model()); - this.shadowRadius = 3f; + this.shadowRadius = 2f; this.addRenderLayer(new Mle1934Layer(this)); this.addRenderLayer(new Mle1934DamageLayer(this)); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/ClaymoreEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/ClaymoreEntity.java index e88604161..2756e105b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/ClaymoreEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/ClaymoreEntity.java @@ -33,6 +33,7 @@ import software.bernie.geckolib.util.GeckoLibUtil; import javax.annotation.Nullable; import java.util.Comparator; +import java.util.Objects; import java.util.Optional; import java.util.UUID; @@ -78,6 +79,9 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity, return false; if (source.is(DamageTypes.WITHER_SKULL)) 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) { 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 TargetEntity) && !(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(); if (!condition) continue; @@ -214,8 +218,8 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity, public void destroy() { if (level() instanceof ServerLevel) { CustomExplosion explosion = new CustomExplosion(this.level(), null, - ModDamageTypes.causeMineDamage(this.level().registryAccess(), this), 15.0f, - this.getX(), this.getY(), this.getZ(), 7.5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1); + ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), null, null), 25.0f, + this.getX(), this.getY(), this.getZ(), 5f, 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); @@ -227,7 +231,7 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity, private void triggerExplode(Entity target) { CustomExplosion explosion = new CustomExplosion(this.level(), this, 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(); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java index ee7f6b86e..66ac713ba 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java @@ -108,7 +108,7 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { @Override public double getPassengersRidingOffset() { - return super.getPassengersRidingOffset() - 0.25; + return super.getPassengersRidingOffset() - 1.25; } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java index f984aa41f..47fed072b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java @@ -112,7 +112,7 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { @Override public double getPassengersRidingOffset() { - return super.getPassengersRidingOffset() - 0.075; + return super.getPassengersRidingOffset() - 1.075; } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java index 1287c91db..b342ce611 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java @@ -1,12 +1,12 @@ 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.config.server.ExplosionDestroyConfig; 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.ParticleTool; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; 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(); 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); Block.dropResources(this.level().getBlockState(_pos), this.level(), BlockPos.containing(x, y, z), null); this.level().destroyBlock(_pos, false); diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java index c800abbcc..090e00188 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java @@ -616,6 +616,10 @@ public class ClientEventHandler { event.setCanceled(true); } } + + if (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity) { + event.setCanceled(true); + } } private static void handleWeaponSway(LivingEntity entity) { diff --git a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java index aacf44b76..a48523488 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java @@ -1,21 +1,22 @@ package com.atsuishio.superbwarfare.event; 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.projectile.ProjectileEntity; import com.atsuishio.superbwarfare.init.*; +import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.network.ModVariables; 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.PlayerGunKillMessage; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; 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.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundStopSoundPacket; @@ -45,11 +46,21 @@ import java.text.DecimalFormat; @Mod.EventBusSubscriber public class LivingEventHandler { + @SubscribeEvent + public static void onEntityAttacked(LivingAttackEvent event) { + if (event.getEntity().getVehicle() != null && event.getEntity().getVehicle() instanceof ICannonEntity) { + event.setCanceled(true); + } + } + @SubscribeEvent public static void onEntityHurt(LivingHurtEvent event) { if (event == null || event.getEntity() == null) { return; } + if (event.getEntity().getVehicle() != null && event.getEntity().getVehicle() instanceof ICannonEntity) { + event.setCanceled(true); + } handleGunPerksWhenHurt(event); renderDamageIndicator(event); diff --git a/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java b/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java index 08660176b..c9e936cbf 100644 --- a/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java +++ b/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java @@ -1,8 +1,9 @@ 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.Mle1934Entity; -import com.atsuishio.superbwarfare.entity.DroneEntity; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModTags; @@ -41,7 +42,11 @@ public abstract class CameraMixin { if (player != null) { 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")); if (drone != null) { @@ -64,11 +69,11 @@ public abstract class CameraMixin { @Inject(method = "setup", at = @At("TAIL")) public void ia$setup(BlockGetter area, Entity entity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) { if (thirdPerson && entity.getVehicle() instanceof Mk42Entity) { - move(-getMaxZoom(8), 1.0, 0.0); + move(-getMaxZoom(8), 2, 0.0); return; } if (thirdPerson && entity.getVehicle() instanceof Mle1934Entity) { - move(-getMaxZoom(10), 1.3, 0.0); + move(-getMaxZoom(10), 2.3, 0.0); return; } if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && entity instanceof Player player && player.getMainHandItem().is(ModTags.Items.GUN)) {