From 90c234018dd60379a2eb2152673dbd20dc789cb4 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Mon, 3 Feb 2025 23:42:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/projectile/FlareDecoyEntity.java | 9 +++-- .../entity/projectile/GunGrenadeEntity.java | 3 +- .../entity/vehicle/Ah6Entity.java | 7 ++-- .../entity/vehicle/ContainerMobileEntity.java | 34 ++++++++++++------- .../entity/vehicle/IArmedVehicleEntity.java | 3 ++ .../entity/vehicle/ILandArmorEntity.java | 5 +++ .../vehicle/MultiWeaponVehicleEntity.java | 2 ++ .../superbwarfare/menu/VehicleMenu.java | 3 +- .../message/SwitchVehicleWeaponMessage.java | 1 - 9 files changed, 42 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FlareDecoyEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FlareDecoyEntity.java index fbff340a9..1096dc744 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FlareDecoyEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FlareDecoyEntity.java @@ -18,6 +18,7 @@ import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PlayMessages; public class FlareDecoyEntity extends Entity { + public FlareDecoyEntity(EntityType type, Level world) { super(type, world); } @@ -37,12 +38,10 @@ public class FlareDecoyEntity extends Entity { @Override protected void readAdditionalSaveData(CompoundTag compoundTag) { - } @Override protected void addAdditionalSaveData(CompoundTag compoundTag) { - } @Override @@ -66,11 +65,11 @@ public class FlareDecoyEntity extends Entity { } public void decoyShoot(Entity entity, Vec3 shootVec, float pVelocity, float pInaccuracy) { - Vec3 vec3 = shootVec.normalize().add(this.random.triangle(0.0, 0.0172275 * (double)pInaccuracy), this.random.triangle(0.0, 0.0172275 * (double)pInaccuracy), this.random.triangle(0.0, 0.0172275 * (double)pInaccuracy)).scale((double)pVelocity); + Vec3 vec3 = shootVec.normalize().add(this.random.triangle(0.0, 0.0172275 * (double) pInaccuracy), this.random.triangle(0.0, 0.0172275 * (double) pInaccuracy), this.random.triangle(0.0, 0.0172275 * (double) pInaccuracy)).scale((double) pVelocity); this.setDeltaMovement(entity.getDeltaMovement().scale(0.75).add(vec3)); double d0 = vec3.horizontalDistance(); - this.setYRot((float)(Mth.atan2(vec3.x, vec3.z) * 57.2957763671875)); - this.setXRot((float)(Mth.atan2(vec3.y, d0) * 57.2957763671875)); + this.setYRot((float) (Mth.atan2(vec3.x, vec3.z) * 57.2957763671875)); + this.setXRot((float) (Mth.atan2(vec3.y, d0) * 57.2957763671875)); this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/GunGrenadeEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/GunGrenadeEntity.java index f1bf76bad..9419c6a1f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/GunGrenadeEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/GunGrenadeEntity.java @@ -35,6 +35,7 @@ import software.bernie.geckolib.core.animation.AnimatableManager; import software.bernie.geckolib.util.GeckoLibUtil; public class GunGrenadeEntity extends ThrowableItemProjectile implements GeoEntity { + private float monsterMultiplier = 0.0f; private float damage = 40.0f; private float explosionDamage = 80f; @@ -61,6 +62,7 @@ public class GunGrenadeEntity extends ThrowableItemProjectile implements GeoEnti public void setMonsterMultiplier(float monsterMultiplier) { this.monsterMultiplier = monsterMultiplier; } + public void charged(boolean charged) { this.charged = charged; } @@ -165,5 +167,4 @@ public class GunGrenadeEntity extends ThrowableItemProjectile implements GeoEnti public AnimatableInstanceCache getAnimatableInstanceCache() { return this.cache; } - } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java index 92a352593..3ef047c8a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -308,10 +308,10 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli diffX = Math.clamp(-60f, 60f, Mth.wrapDegrees(passenger.getXRot() - this.getXRot())); if (rightInputDown) { - holdTick ++; + holdTick++; this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) - 2f * Math.min(holdTick, 7) * this.entityData.get(PROPELLER_ROT)); } else if (this.leftInputDown) { - holdTick ++; + holdTick++; this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 2f * Math.min(holdTick, 7) * this.entityData.get(PROPELLER_ROT)); } else { holdTick = 0; @@ -617,7 +617,6 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(6, 5, 7, this.getX(), this.getEyeY(), this.getZ())); } } - } else if (entityData.get(WEAPON_TYPE) == 1 && this.getEntityData().get(LOADED_ROCKET) > 0) { x = 1.7f; y = 0.62f; @@ -777,7 +776,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli case 1 -> ModSounds.INTO_CANNON.get(); default -> throw new IllegalStateException("Unexpected type: " + type); }; - + this.level().playSound(null, this, sound, this.getSoundSource(), 1, 1); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ContainerMobileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ContainerMobileEntity.java index faf21f65d..0db87b96d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ContainerMobileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ContainerMobileEntity.java @@ -12,12 +12,14 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.HasCustomInventoryScreen; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.vehicle.ContainerEntity; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.HopperBlockEntity; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ForgeCapabilities; @@ -26,6 +28,8 @@ import net.minecraftforge.items.wrapper.InvWrapper; import org.jetbrains.annotations.Nullable; import org.joml.Math; +import java.util.List; + public class ContainerMobileEntity extends MobileVehicleEntity implements HasCustomInventoryScreen, ContainerEntity { public static final int CONTAINER_SIZE = 102; @@ -75,11 +79,13 @@ public class ContainerMobileEntity extends MobileVehicleEntity implements HasCus super.remove(pReason); } - @Override public void baseTick() { super.baseTick(); -// pickUpItem(); + + if (this.canPickUpItems()) { + this.pickUpItems(); + } for (var stack : this.getItemStacks()) { int neededEnergy = this.getMaxEnergy() - this.getEnergy(); @@ -99,16 +105,20 @@ public class ContainerMobileEntity extends MobileVehicleEntity implements HasCus this.refreshDimensions(); } -// public void pickUpItem() { -// List list = this.level().getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(0.2F, 0.1, 0.2F)); -// if (!list.isEmpty()) { -// for (ItemEntity entity : list) { -// if (!this.level().isClientSide) { -// HopperBlockEntity.addItem(this, entity); -// } -// } -// } -// } + public boolean canPickUpItems() { + return false; + } + + public void pickUpItems() { + List list = this.level().getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(0.2F, 0.1, 0.2F)); + if (!list.isEmpty()) { + for (ItemEntity entity : list) { + if (!this.level().isClientSide) { + HopperBlockEntity.addItem(this, entity); + } + } + } + } @Override public void openCustomInventoryScreen(Player pPlayer) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/IArmedVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/IArmedVehicleEntity.java index 8260f95fb..aed5a6a86 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/IArmedVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/IArmedVehicleEntity.java @@ -13,7 +13,10 @@ public interface IArmedVehicleEntity { boolean canShoot(Player player); int getAmmoCount(Player player); + boolean banHand(); + boolean hidePassenger(); + int zoomFov(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ILandArmorEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ILandArmorEntity.java index a6cce9812..817f15284 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ILandArmorEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ILandArmorEntity.java @@ -3,9 +3,14 @@ package com.atsuishio.superbwarfare.entity.vehicle; import net.minecraft.world.phys.Vec3; public interface ILandArmorEntity extends IArmedVehicleEntity { + float turretYRotO(); + float turretYRot(); + float turretXRotO(); + float turretXRot(); + Vec3 getBarrelVec(float ticks); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MultiWeaponVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MultiWeaponVehicleEntity.java index bf76ba495..de957cb62 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MultiWeaponVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MultiWeaponVehicleEntity.java @@ -1,6 +1,8 @@ package com.atsuishio.superbwarfare.entity.vehicle; public interface MultiWeaponVehicleEntity extends IArmedVehicleEntity { + void changeWeapon(int scroll); + int getWeaponType(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/menu/VehicleMenu.java b/src/main/java/com/atsuishio/superbwarfare/menu/VehicleMenu.java index 08443a36e..b53be1834 100644 --- a/src/main/java/com/atsuishio/superbwarfare/menu/VehicleMenu.java +++ b/src/main/java/com/atsuishio/superbwarfare/menu/VehicleMenu.java @@ -10,6 +10,7 @@ import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; public class VehicleMenu extends AbstractContainerMenu { + private final Container container; private final int containerRows; @@ -77,6 +78,4 @@ public class VehicleMenu extends AbstractContainerMenu { public boolean stillValid(Player pPlayer) { return this.container.stillValid(pPlayer); } - - } diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/SwitchVehicleWeaponMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/SwitchVehicleWeaponMessage.java index 91a9ae150..1638cdf04 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/SwitchVehicleWeaponMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/SwitchVehicleWeaponMessage.java @@ -34,7 +34,6 @@ public class SwitchVehicleWeaponMessage { if (player.getVehicle() instanceof MultiWeaponVehicleEntity multiWeaponVehicle && multiWeaponVehicle.isDriver(player)) { multiWeaponVehicle.changeWeapon(Mth.clamp(message.scroll > 0 ? Mth.ceil(message.scroll) : Mth.floor(message.scroll), -1, 1)); } - }); context.get().setPacketHandled(true); }