From 80e8fb14097f3b988446d1d34bc08aeaf841fdfd Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Mon, 16 Dec 2024 04:28:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E8=88=B9=E5=90=B8=E9=99=84?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=93=81=E9=94=AD=E4=BF=AE=E8=88=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/entity/SpeedboatEntity.java | 58 +++++++++++-------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java index 3bf4fc352..2c36cc6ba 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java @@ -26,6 +26,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; import net.minecraft.world.ContainerHelper; @@ -35,7 +36,6 @@ 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.animal.WaterAnimal; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -44,6 +44,7 @@ import net.minecraft.world.entity.projectile.ThrownPotion; import net.minecraft.world.entity.vehicle.ContainerEntity; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; @@ -73,7 +74,6 @@ import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; import java.util.Comparator; -import java.util.List; public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, IVehicleEntity, HasCustomInventoryScreen, ContainerEntity { @@ -259,6 +259,18 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, return !player.level().isClientSide ? InteractionResult.CONSUME : InteractionResult.SUCCESS; } } else { + if (player.getMainHandItem().is(Items.IRON_INGOT)) { + if (this.entityData.get(HEALTH) < MAX_HEALTH) { + this.entityData.set(HEALTH, Math.min(this.entityData.get(HEALTH) + 0.1f * MAX_HEALTH, MAX_HEALTH)); + player.getMainHandItem().shrink(1); + if (!this.level().isClientSide) { + this.level().playSound(null, this, SoundEvents.IRON_GOLEM_REPAIR, this.getSoundSource(), 1, 1); + } + } else { + player.startRiding(this); + } + return InteractionResult.sidedSuccess(this.level().isClientSide()); + } player.startRiding(this); return InteractionResult.sidedSuccess(this.level().isClientSide()); } @@ -333,7 +345,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, gunnerAngle(); gunnerFire(); - attractEntity(); +// attractEntity(); this.refreshDimensions(); } @@ -584,26 +596,26 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, } } - public boolean hasEnoughSpaceFor(Entity pEntity) { - return pEntity.getBbWidth() < this.getBbWidth(); - } - - public void attractEntity() { - List list = this.level().getEntities(this, this.getBoundingBox().inflate(0.2F, -0.01F, 0.2F), EntitySelector.pushableBy(this)); - if (!list.isEmpty()) { - boolean flag = !this.level().isClientSide && !(this.getControllingPassenger() instanceof Player); - - for (Entity entity : list) { - if (!entity.hasPassenger(this)) { - if (flag && this.getPassengers().size() < this.getMaxPassengers() && !entity.isPassenger() && this.hasEnoughSpaceFor(entity) && entity instanceof LivingEntity && !(entity instanceof WaterAnimal) && !(entity instanceof Player)) { - entity.startRiding(this); - } else { - this.push(entity); - } - } - } - } - } +// public boolean hasEnoughSpaceFor(Entity pEntity) { +// return pEntity.getBbWidth() < this.getBbWidth(); +// } +// +// public void attractEntity() { +// List list = this.level().getEntities(this, this.getBoundingBox().inflate(0.2F, -0.01F, 0.2F), EntitySelector.pushableBy(this)); +// if (!list.isEmpty()) { +// boolean flag = !this.level().isClientSide && !(this.getControllingPassenger() instanceof Player); +// +// for (Entity entity : list) { +// if (!entity.hasPassenger(this)) { +// if (flag && this.getPassengers().size() < this.getMaxPassengers() && !entity.isPassenger() && this.hasEnoughSpaceFor(entity) && entity instanceof LivingEntity && !(entity instanceof WaterAnimal) && !(entity instanceof Player)) { +// entity.startRiding(this); +// } else { +// this.push(entity); +// } +// } +// } +// } +// } public static double calculateAngle(Vec3 move, Vec3 view) { move = move.multiply(1, 0, 1).normalize();