From 926298a1bf6a57dbcb8e2e5c1491493ef5fef35b Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Tue, 7 Jan 2025 05:19:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=A7=E5=9E=8B=E8=9E=BA?= =?UTF-8?q?=E6=97=8B=E6=A1=A8=EF=BC=8C=E7=81=AB=E7=AE=AD=E5=BC=B9=EF=BC=8C?= =?UTF-8?q?=E7=9B=B4=E5=8D=87=E6=9C=BA=E7=9A=84=E9=85=8D=E6=96=B9=E3=80=82?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=A4=E4=BA=92bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../b69ee8a2655365569b979911c0440daa8c470ac2 | 3 +- .../models/item/large_propeller.json | 6 +++ .../datagen/ModItemModelProvider.java | 1 + .../entity/vehicle/ContainerMobileEntity.java | 47 ++++++++++++++++++ .../entity/vehicle/VehicleEntity.java | 32 ++++-------- .../event/LivingEventHandler.java | 8 +++ .../superbwarfare/init/ModItems.java | 1 + .../superbwarfare/tools/CustomExplosion.java | 9 ++-- .../assets/superbwarfare/lang/en_us.json | 1 + .../assets/superbwarfare/lang/zh_cn.json | 1 + .../textures/item/large_propeller.png | Bin 0 -> 256 bytes .../superbwarfare/recipes/ah_6_crafting.json | 43 ++++++++++++++++ .../superbwarfare/recipes/grain_crafting.json | 2 +- .../recipes/large_motor_crafting.json | 19 +++++-- .../recipes/large_propeller_crafting.json | 21 ++++++++ .../recipes/missile_engine_crafting.json | 2 +- .../recipes/rocket_70_crafting.json | 27 ++++++++++ .../recipes/seeker_crafting.json | 2 +- .../recipes/speedboat_crafting.json | 4 +- 19 files changed, 192 insertions(+), 37 deletions(-) create mode 100644 src/generated/resources/assets/superbwarfare/models/item/large_propeller.json create mode 100644 src/main/resources/assets/superbwarfare/textures/item/large_propeller.png create mode 100644 src/main/resources/data/superbwarfare/recipes/ah_6_crafting.json create mode 100644 src/main/resources/data/superbwarfare/recipes/large_propeller_crafting.json create mode 100644 src/main/resources/data/superbwarfare/recipes/rocket_70_crafting.json diff --git a/src/generated/resources/.cache/b69ee8a2655365569b979911c0440daa8c470ac2 b/src/generated/resources/.cache/b69ee8a2655365569b979911c0440daa8c470ac2 index 25776245a..49754392e 100644 --- a/src/generated/resources/.cache/b69ee8a2655365569b979911c0440daa8c470ac2 +++ b/src/generated/resources/.cache/b69ee8a2655365569b979911c0440daa8c470ac2 @@ -1,4 +1,4 @@ -// 1.20.1 2025-01-07T02:18:22.6361822 Item Models: superbwarfare +// 1.20.1 2025-01-07T03:38:49.7324927 Item Models: superbwarfare 13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/aa_12_blueprint.json 13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/ak_12_blueprint.json 13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/ak_47_blueprint.json @@ -47,6 +47,7 @@ e04bbd61e716fc5d53c9425aba508fc3287bfd57 assets/superbwarfare/models/item/iron_p 195c1b7cbcce9b0ac42ecbfc21a8cafff8c78372 assets/superbwarfare/models/item/jump_pad.json 13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/k_98_blueprint.json 4c9b6c2911ae5e6e2a026d2ae9d3c0564cdba0b3 assets/superbwarfare/models/item/large_motor.json +95c0f92c4a4b3adff9c95878540071b04a921792 assets/superbwarfare/models/item/large_propeller.json ce9e4fd8ea92cfdbdda158776c1b6e1b482a3f2a assets/superbwarfare/models/item/lead_ingot.json f66c351b4843ad4d4e086ccfb7d4d0221227d196 assets/superbwarfare/models/item/legendary_material_pack.json 13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/m2hb_blueprint.json diff --git a/src/generated/resources/assets/superbwarfare/models/item/large_propeller.json b/src/generated/resources/assets/superbwarfare/models/item/large_propeller.json new file mode 100644 index 000000000..16d9e604a --- /dev/null +++ b/src/generated/resources/assets/superbwarfare/models/item/large_propeller.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "superbwarfare:item/large_propeller" + } +} \ No newline at end of file diff --git a/src/main/java/com/atsuishio/superbwarfare/datagen/ModItemModelProvider.java b/src/main/java/com/atsuishio/superbwarfare/datagen/ModItemModelProvider.java index 5ebf5a45e..2ee738bd5 100644 --- a/src/main/java/com/atsuishio/superbwarfare/datagen/ModItemModelProvider.java +++ b/src/main/java/com/atsuishio/superbwarfare/datagen/ModItemModelProvider.java @@ -28,6 +28,7 @@ public class ModItemModelProvider extends ItemModelProvider { // misc simpleItem(ModItems.ANCIENT_CPU); simpleItem(ModItems.PROPELLER); + simpleItem(ModItems.LARGE_PROPELLER); simpleItem(ModItems.MOTOR); simpleItem(ModItems.LARGE_MOTOR); simpleItem(ModItems.DRONE); 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 615cee12d..730b18a95 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ContainerMobileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ContainerMobileEntity.java @@ -1,13 +1,17 @@ package com.atsuishio.superbwarfare.entity.vehicle; import com.atsuishio.superbwarfare.init.ModItems; +import com.atsuishio.superbwarfare.item.ContainerBlockItem; import com.atsuishio.superbwarfare.menu.VehicleMenu; import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvents; import net.minecraft.world.ContainerHelper; import net.minecraft.world.Containers; +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; @@ -16,6 +20,7 @@ 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.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.HopperBlockEntity; import net.minecraft.world.level.gameevent.GameEvent; @@ -25,6 +30,7 @@ import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.items.wrapper.InvWrapper; import org.jetbrains.annotations.Nullable; +import org.joml.Math; import java.util.List; @@ -56,6 +62,47 @@ public class ContainerMobileEntity extends MobileVehicleEntity implements HasCus ContainerHelper.loadAllItems(compound, this.getItemStacks()); } + @Override + public InteractionResult interact(Player player, InteractionHand hand) { + if (player.getVehicle() == this) return InteractionResult.PASS; + + ItemStack stack = player.getMainHandItem(); + if (player.isShiftKeyDown() && stack.is(ModItems.CROWBAR.get())) { + ItemStack container = ContainerBlockItem.createInstance(this); + if (!player.addItem(container)) { + player.drop(container, false); + } + this.remove(RemovalReason.DISCARDED); + this.discard(); + return InteractionResult.SUCCESS; + } else if (player.isShiftKeyDown()) { + player.openMenu(this); + return !player.level().isClientSide ? InteractionResult.CONSUME : InteractionResult.SUCCESS; + } else if (this.getHealth() < this.getMaxHealth() && stack.is(Items.IRON_INGOT)) { + this.heal(Math.min(50, this.getMaxHealth())); + stack.shrink(1); + if (!this.level().isClientSide) { + this.level().playSound(null, this, SoundEvents.IRON_GOLEM_REPAIR, this.getSoundSource(), 0.5f, 1); + } + return InteractionResult.SUCCESS; + } else if (!player.isShiftKeyDown()) { + if (this.getFirstPassenger() == null) { + player.setXRot(this.getXRot()); + player.setYRot(this.getYRot()); + return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS; + } else if (!(this.getFirstPassenger() instanceof Player)) { + this.getFirstPassenger().stopRiding(); + player.setXRot(this.getXRot()); + player.setYRot(this.getYRot()); + return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS; + } + if (this.getPassengers().size() < this.getMaxPassengers()) { + return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS; + } + } + return InteractionResult.PASS; + } + @Override public void remove(RemovalReason pReason) { if (!this.level().isClientSide && pReason != RemovalReason.DISCARDED) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java index f12248779..500b5f7cb 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java @@ -96,7 +96,7 @@ public class VehicleEntity extends Entity { public InteractionResult interact(Player player, InteractionHand hand) { if (player.getVehicle() == this) return InteractionResult.PASS; - ItemStack stack = player.getItemInHand(hand); + ItemStack stack = player.getMainHandItem(); if (player.isShiftKeyDown() && stack.is(ModItems.CROWBAR.get())) { ItemStack container = ContainerBlockItem.createInstance(this); if (!player.addItem(container)) { @@ -104,29 +104,15 @@ public class VehicleEntity extends Entity { } this.remove(RemovalReason.DISCARDED); this.discard(); - } else if (stack.is(Items.IRON_INGOT)) { - if (this.getHealth() < this.getMaxHealth()) { - this.heal(Math.min(50, this.getMaxHealth())); - stack.shrink(1); - if (!this.level().isClientSide) { - this.level().playSound(null, this, SoundEvents.IRON_GOLEM_REPAIR, this.getSoundSource(), 0.5f, 1); - } - } else if (!this.level().isClientSide) { - if (this.getFirstPassenger() == null) { - player.setXRot(this.getXRot()); - player.setYRot(this.getYRot()); - return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS; - } else if (!(this.getFirstPassenger() instanceof Player)) { - this.getFirstPassenger().stopRiding(); - player.setXRot(this.getXRot()); - player.setYRot(this.getYRot()); - return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS; - } - if (this.getPassengers().size() < this.getMaxPassengers()) { - return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS; - } + return InteractionResult.SUCCESS; + } else if (this.getHealth() < this.getMaxHealth() && stack.is(Items.IRON_INGOT)) { + this.heal(Math.min(50, this.getMaxHealth())); + stack.shrink(1); + if (!this.level().isClientSide) { + this.level().playSound(null, this, SoundEvents.IRON_GOLEM_REPAIR, this.getSoundSource(), 0.5f, 1); } - } else if (!this.level().isClientSide) { + return InteractionResult.SUCCESS; + } else if (!player.isShiftKeyDown()) { if (this.getFirstPassenger() == null) { player.setXRot(this.getXRot()); player.setYRot(this.getYRot()); diff --git a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java index 78de89a09..4b1726477 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java @@ -44,6 +44,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.GameRules; import net.minecraft.world.level.block.entity.HopperBlockEntity; import net.minecraftforge.event.entity.living.*; +import net.minecraftforge.event.level.ExplosionEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.network.PacketDistributor; @@ -54,6 +55,13 @@ import java.util.Objects; @Mod.EventBusSubscriber public class LivingEventHandler { + @SubscribeEvent + public static void onExplode(ExplosionEvent.Detonate event) { + event.getExplosion().clearToBlow(); + + } + + @SubscribeEvent public static void onEntityAttacked(LivingAttackEvent event) { if (event.getEntity().getVehicle() != null && event.getEntity().getVehicle() instanceof ICannonEntity) { diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java index 10fb76253..b693e9dc6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java @@ -119,6 +119,7 @@ public class ModItems { public static final RegistryObject SENPAI_SPAWN_EGG = ITEMS.register("senpai_spawn_egg", () -> new ForgeSpawnEggItem(ModEntities.SENPAI, -11584987, -14014413, new Item.Properties())); public static final RegistryObject ANCIENT_CPU = ITEMS.register("ancient_cpu", () -> new Item(new Item.Properties().rarity(Rarity.RARE))); public static final RegistryObject PROPELLER = ITEMS.register("propeller", () -> new Item(new Item.Properties())); + public static final RegistryObject LARGE_PROPELLER = ITEMS.register("large_propeller", () -> new Item(new Item.Properties())); public static final RegistryObject MOTOR = ITEMS.register("motor", () -> new Item(new Item.Properties())); public static final RegistryObject LARGE_MOTOR = ITEMS.register("large_motor", () -> new Item(new Item.Properties())); public static final RegistryObject DRONE = ITEMS.register("drone", Drone::new); diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java b/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java index f4727eccd..ca74e491c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java @@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.tools; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig; +import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; import com.google.common.collect.Sets; import net.minecraft.core.BlockPos; @@ -201,8 +202,11 @@ public class CustomExplosion extends Explosion { zDistance *= d11; Vec3 knockbackVec = new Vec3(0.2 * xDistance, 0.2 * yDistance, 0.2 * zDistance); - entity.setDeltaMovement(entity.getDeltaMovement().add(knockbackVec)); - + if (entity instanceof VehicleEntity vehicle) { + vehicle.setDeltaMovement(vehicle.getDeltaMovement().add(knockbackVec.scale(0.05f))); + } else { + entity.setDeltaMovement(entity.getDeltaMovement().add(knockbackVec)); + } if (entity instanceof Player player) { if (!player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying)) { this.getHitPlayers().put(player, knockbackVec); @@ -213,5 +217,4 @@ public class CustomExplosion extends Explosion { } } } - } diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index 0ff96d63e..934433b9f 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -184,6 +184,7 @@ "item.superbwarfare.monitor": "Monitor", "des.superbwarfare.monitor": "Drone Distance: %1$s", "item.superbwarfare.propeller": "Propeller", + "item.superbwarfare.large_propeller": "Large_Propeller", "item.superbwarfare.motor": "Motor", "item.superbwarfare.large_motor": "Large Motor", "item.superbwarfare.hand_grenade": "Hand Grenade", diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index 432ea5739..7e6246680 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -183,6 +183,7 @@ "item.superbwarfare.monitor": "遥控器", "des.superbwarfare.monitor": "无人机距离你: %1$s", "item.superbwarfare.propeller": "螺旋桨", + "item.superbwarfare.large_propeller": "大型螺旋桨", "item.superbwarfare.motor": "马达", "item.superbwarfare.large_motor": "大型电动机", "item.superbwarfare.hand_grenade": "M67手榴弹", diff --git a/src/main/resources/assets/superbwarfare/textures/item/large_propeller.png b/src/main/resources/assets/superbwarfare/textures/item/large_propeller.png new file mode 100644 index 0000000000000000000000000000000000000000..39dc3a97cc6ce8ad73dbef96b7a13775fcef5520 GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5M?jcysy3fAP;ir{ zi(`mI@7zg-d`$)tt^0+{@*X@pz_RW|Z;Z@dR&MqOI=qP`qQXMe>}p|k>O7he(f6(_ z`FrnwT=Y@CsiC@`quw_5zGS@M>%B#M-qYL-tj+1Ix)J8O@82zK(z@~CKFjA^{pI?J z%TKMErsBE8BK}F$Ztq#*lb*HSc%F3qijMuqSMzute<{w&IedD@VT(eGv~wr!^Gbhv zE0udtF=(CnH^Yd(%>osv0$j{Tj(vHtjFqE}(QbuPwe<1Iy?#K~GkCiCxvX