From f839d00768bb75d550581563fb53b520cc698936 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Fri, 6 Dec 2024 21:55:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E5=85=85=E7=94=B5=E7=AB=99?= =?UTF-8?q?=E6=96=B9=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../59eb3dbb5f86130e09b3c62d89b9525ee01cf52d | 3 +- .../aea51f45d35dbbd3220b84682ce1417a457a0246 | 4 +- .../tags/blocks/mineable/pickaxe.json | 3 +- .../loot_tables/blocks/charging_station.json | 21 +++++ .../block/ChargingStationBlock.java | 23 ++++++ .../datagen/ModBlockLootProvider.java | 1 + .../datagen/ModBlockTagProvider.java | 2 +- .../entity/AnnihilatorEntity.java | 81 ++++++++++--------- .../superbwarfare/init/ModBlocks.java | 1 + .../superbwarfare/init/ModItems.java | 1 + .../assets/superbwarfare/lang/en_us.json | 1 + .../assets/superbwarfare/lang/zh_cn.json | 1 + 12 files changed, 97 insertions(+), 45 deletions(-) create mode 100644 src/generated/resources/data/superbwarfare/loot_tables/blocks/charging_station.json create mode 100644 src/main/java/com/atsuishio/superbwarfare/block/ChargingStationBlock.java diff --git a/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d index e2ef320bc..0ab70513f 100644 --- a/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d +++ b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d @@ -1,6 +1,7 @@ -// 1.20.1 2024-11-28T19:45:16.1283469 Loot Tables +// 1.20.1 2024-12-06T21:51:55.0829733 Loot Tables 98386b2e65b2afb7cf5b0cabf6a7b0f062c1e640 data/superbwarfare/loot_tables/blocks/barbed_wire.json 811e69929a14e6736015849c220100bb58d914c9 data/superbwarfare/loot_tables/blocks/cemented_carbide_block.json +9e4d3e3c60529571c1902818916ffe72dd2dbc2a data/superbwarfare/loot_tables/blocks/charging_station.json 8ed3f1d518c86fe6ed14f14f3121c2e24e109269 data/superbwarfare/loot_tables/blocks/container.json dabbe17417c944567dc6dfcdcba32b8377c24f69 data/superbwarfare/loot_tables/blocks/deepslate_galena_ore.json a7c1af3e194d35a64544902468bd964f45f2f9ef data/superbwarfare/loot_tables/blocks/deepslate_scheelite_ore.json diff --git a/src/generated/resources/.cache/aea51f45d35dbbd3220b84682ce1417a457a0246 b/src/generated/resources/.cache/aea51f45d35dbbd3220b84682ce1417a457a0246 index fcb1a849b..944329cef 100644 --- a/src/generated/resources/.cache/aea51f45d35dbbd3220b84682ce1417a457a0246 +++ b/src/generated/resources/.cache/aea51f45d35dbbd3220b84682ce1417a457a0246 @@ -1,5 +1,5 @@ -// 1.20.1 2024-11-28T19:20:29.861331 Tags for minecraft:block mod id superbwarfare +// 1.20.1 2024-12-06T21:51:55.0782775 Tags for minecraft:block mod id superbwarfare 0acfd31854bf15f2c108138b3df7206bd2593e6b data/minecraft/tags/blocks/mineable/axe.json -e059c279c01c012fe89bd4bfadf8cd6d70b3b948 data/minecraft/tags/blocks/mineable/pickaxe.json +e78725c77652a79d8e1fa4a614b7b75027aa1883 data/minecraft/tags/blocks/mineable/pickaxe.json 3da7f021790388a122717f16f51c7ec5232eebcb data/minecraft/tags/blocks/mineable/shovel.json f42a8c01336e64b74da966f03d45ee0d60ac5d6b data/minecraft/tags/blocks/needs_iron_tool.json diff --git a/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json index 15795f989..570bca685 100644 --- a/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json +++ b/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -14,6 +14,7 @@ "superbwarfare:deepslate_silver_ore", "superbwarfare:silver_block", "superbwarfare:jump_pad", - "superbwarfare:container" + "superbwarfare:container", + "superbwarfare:charging_station" ] } \ No newline at end of file diff --git a/src/generated/resources/data/superbwarfare/loot_tables/blocks/charging_station.json b/src/generated/resources/data/superbwarfare/loot_tables/blocks/charging_station.json new file mode 100644 index 000000000..870d48fb7 --- /dev/null +++ b/src/generated/resources/data/superbwarfare/loot_tables/blocks/charging_station.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:air" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "superbwarfare:blocks/charging_station" +} \ No newline at end of file diff --git a/src/main/java/com/atsuishio/superbwarfare/block/ChargingStationBlock.java b/src/main/java/com/atsuishio/superbwarfare/block/ChargingStationBlock.java new file mode 100644 index 000000000..0a88b934c --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/block/ChargingStationBlock.java @@ -0,0 +1,23 @@ +package com.atsuishio.superbwarfare.block; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.BaseEntityBlock; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.Nullable; + +public class ChargingStationBlock extends BaseEntityBlock { + + public ChargingStationBlock() { + super(BlockBehaviour.Properties.of().sound(SoundType.METAL).strength(3.0f).requiresCorrectToolForDrops()); + } + + @Nullable + @Override + public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) { + return null; + } + +} diff --git a/src/main/java/com/atsuishio/superbwarfare/datagen/ModBlockLootProvider.java b/src/main/java/com/atsuishio/superbwarfare/datagen/ModBlockLootProvider.java index ce31c7856..9a4303697 100644 --- a/src/main/java/com/atsuishio/superbwarfare/datagen/ModBlockLootProvider.java +++ b/src/main/java/com/atsuishio/superbwarfare/datagen/ModBlockLootProvider.java @@ -33,6 +33,7 @@ public class ModBlockLootProvider extends BlockLootSubProvider { this.dropSelf(ModBlocks.TUNGSTEN_BLOCK.get()); this.dropSelf(ModBlocks.CEMENTED_CARBIDE_BLOCK.get()); this.dropSelf(ModBlocks.SILVER_BLOCK.get()); + this.dropSelf(ModBlocks.CHARGING_STATION.get()); this.add(ModBlocks.GALENA_ORE.get(), this.createOreDrop(ModBlocks.GALENA_ORE.get(), ModItems.GALENA.get())); this.add(ModBlocks.SCHEELITE_ORE.get(), this.createOreDrop(ModBlocks.SCHEELITE_ORE.get(), ModItems.SCHEELITE.get())); diff --git a/src/main/java/com/atsuishio/superbwarfare/datagen/ModBlockTagProvider.java b/src/main/java/com/atsuishio/superbwarfare/datagen/ModBlockTagProvider.java index 4e1cc507a..3096ec26e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/datagen/ModBlockTagProvider.java +++ b/src/main/java/com/atsuishio/superbwarfare/datagen/ModBlockTagProvider.java @@ -28,7 +28,7 @@ public class ModBlockTagProvider extends BlockTagsProvider { ModBlocks.DEEPSLATE_GALENA_ORE.get(), ModBlocks.DEEPSLATE_SCHEELITE_ORE.get(), ModBlocks.DRAGON_TEETH.get(), ModBlocks.REFORGING_TABLE.get(), ModBlocks.LEAD_BLOCK.get(), ModBlocks.STEEL_BLOCK.get(), ModBlocks.TUNGSTEN_BLOCK.get(), ModBlocks.CEMENTED_CARBIDE_BLOCK.get(), ModBlocks.SILVER_ORE.get(), ModBlocks.DEEPSLATE_SILVER_ORE.get(), - ModBlocks.SILVER_BLOCK.get(), ModBlocks.JUMP_PAD.get(), ModBlocks.CONTAINER.get()); + ModBlocks.SILVER_BLOCK.get(), ModBlocks.JUMP_PAD.get(), ModBlocks.CONTAINER.get(), ModBlocks.CHARGING_STATION.get()); this.tag(BlockTags.MINEABLE_WITH_SHOVEL).add(ModBlocks.SANDBAG.get()); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/AnnihilatorEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/AnnihilatorEntity.java index d09ae5db1..46dbb76c6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/AnnihilatorEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/AnnihilatorEntity.java @@ -66,6 +66,7 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit public static final float MAX_HEALTH = CannonConfig.ANNIHILATOR_HP.get(); public static final float SHOOT_COST = CannonConfig.ANNIHILATOR_SHOOT_COST.get().floatValue(); + protected int interpolationSteps; protected double serverYRot; protected double serverXRot; @@ -111,9 +112,9 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit @Override protected void positionRider(Entity pPassenger, MoveFunction pCallback) { if (this.hasPassenger(pPassenger)) { - float f1 = (float)((this.isRemoved() ? 0.009999999776482582 : this.getPassengersRidingOffset()) + pPassenger.getMyRidingOffset()); + float f1 = (float) ((this.isRemoved() ? 0.009999999776482582 : this.getPassengersRidingOffset()) + pPassenger.getMyRidingOffset()); Vec3 vec3 = (new Vec3(1, 0.0, 0.0)).yRot(-this.getYRot() * 0.017453292F - 1.5707964F); - pCallback.accept(pPassenger, this.getX() + vec3.x, this.getY() + (double)f1, this.getZ() + vec3.z); + pCallback.accept(pPassenger, this.getX() + vec3.x, this.getY() + (double) f1, this.getZ() + vec3.z); } } @@ -195,7 +196,7 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit return InteractionResult.sidedSuccess(this.level().isClientSide()); } if (player.getMainHandItem().is(ModItems.SHIELD_CELL.get())) { - this.entityData.set(ENERGY, (float)Mth.clamp(this.entityData.get(ENERGY) + 1000000 , 0, CannonConfig.ANNIHILATOR_MAX_ENERGY.get())); + this.entityData.set(ENERGY, (float) Mth.clamp(this.entityData.get(ENERGY) + 1000000, 0, CannonConfig.ANNIHILATOR_MAX_ENERGY.get())); player.displayClientMessage(Component.literal("Energy:" + new java.text.DecimalFormat("##").format(this.entityData.get(ENERGY))), true); return InteractionResult.sidedSuccess(this.level().isClientSide()); } @@ -301,9 +302,9 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit Vec3 BarrelRightPos = new Vec3(BarrelRootPos.x + rightPos.x, BarrelRootPos.y + rightPos.y, BarrelRootPos.z + rightPos.z); if (this.entityData.get(COOL_DOWN) > 88) { - this.entityData.set(LASER_LEFT_LENGTH, Math.min(laserLength(BarrelLeftPos ,this), laserLengthEntity(BarrelLeftPos ,this))); - this.entityData.set(LASER_MIDDLE_LENGTH, Math.min(laserLength(BarrelMiddlePos ,this), laserLengthEntity(BarrelMiddlePos ,this))); - this.entityData.set(LASER_RIGHT_LENGTH, Math.min(laserLength(BarrelRightPos ,this), laserLengthEntity(BarrelRightPos ,this))); + this.entityData.set(LASER_LEFT_LENGTH, Math.min(laserLength(BarrelLeftPos, this), laserLengthEntity(BarrelLeftPos, this))); + this.entityData.set(LASER_MIDDLE_LENGTH, Math.min(laserLength(BarrelMiddlePos, this), laserLengthEntity(BarrelMiddlePos, this))); + this.entityData.set(LASER_RIGHT_LENGTH, Math.min(laserLength(BarrelRightPos, this), laserLengthEntity(BarrelRightPos, this))); } travel(); @@ -317,7 +318,7 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit this.refreshDimensions(); } - private float laserLength (Vec3 pos, Entity cannon) { + private float laserLength(Vec3 pos, Entity cannon) { if (this.entityData.get(COOL_DOWN) > 98) { HitResult result = cannon.level().clip(new ClipContext(pos, pos.add(cannon.getViewVector(1).scale(512)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, cannon)); @@ -330,41 +331,41 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, cannon)).getBlockPos()))); } - private float laserLengthEntity (Vec3 pos, Entity cannon) { - double distance = 512 * 512; - HitResult hitResult = cannon.pick(512, 1.0f, false); - if (hitResult.getType() != HitResult.Type.MISS) { - distance = hitResult.getLocation().distanceToSqr(pos); - double blockReach = 5; - if (distance > blockReach * blockReach) { - Vec3 posB = hitResult.getLocation(); - hitResult = BlockHitResult.miss(posB, Direction.getNearest(pos.x, pos.y, pos.z), BlockPos.containing(posB)); - } + private float laserLengthEntity(Vec3 pos, Entity cannon) { + double distance = 512 * 512; + HitResult hitResult = cannon.pick(512, 1.0f, false); + if (hitResult.getType() != HitResult.Type.MISS) { + distance = hitResult.getLocation().distanceToSqr(pos); + double blockReach = 5; + if (distance > blockReach * blockReach) { + Vec3 posB = hitResult.getLocation(); + hitResult = BlockHitResult.miss(posB, Direction.getNearest(pos.x, pos.y, pos.z), BlockPos.containing(posB)); } - Vec3 viewVec = cannon.getViewVector(1.0F); - Vec3 toVec = pos.add(viewVec.x * 512, viewVec.y * 512, viewVec.z * 512); - AABB aabb = cannon.getBoundingBox().expandTowards(viewVec.scale(512)).inflate(1.0D, 1.0D, 1.0D); - EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(cannon, pos, toVec, aabb, p -> !p.isSpectator(), distance); - if (entityhitresult != null) { - Vec3 targetPos = entityhitresult.getLocation(); - double distanceToTarget = pos.distanceToSqr(targetPos); - if (distanceToTarget > distance || distanceToTarget > 512 * 512) { - hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos)); - } else if (distanceToTarget < distance) { - hitResult = entityhitresult; - } - if (hitResult.getType() == HitResult.Type.ENTITY) { - Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0); - Entity target = ((EntityHitResult) hitResult).getEntity(); - target.hurt(ModDamageTypes.causeLaserDamage(this.level().registryAccess(), passenger, passenger), (float) 200); - target.invulnerableTime = 0; - if (this.entityData.get(COOL_DOWN) > 98) { - laserExplosion(targetPos); - } - return (float) pos.distanceTo(target.position()); - } + } + Vec3 viewVec = cannon.getViewVector(1.0F); + Vec3 toVec = pos.add(viewVec.x * 512, viewVec.y * 512, viewVec.z * 512); + AABB aabb = cannon.getBoundingBox().expandTowards(viewVec.scale(512)).inflate(1.0D, 1.0D, 1.0D); + EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(cannon, pos, toVec, aabb, p -> !p.isSpectator(), distance); + if (entityhitresult != null) { + Vec3 targetPos = entityhitresult.getLocation(); + double distanceToTarget = pos.distanceToSqr(targetPos); + if (distanceToTarget > distance || distanceToTarget > 512 * 512) { + hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos)); + } else if (distanceToTarget < distance) { + hitResult = entityhitresult; } - return 512; + if (hitResult.getType() == HitResult.Type.ENTITY) { + Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0); + Entity target = ((EntityHitResult) hitResult).getEntity(); + target.hurt(ModDamageTypes.causeLaserDamage(this.level().registryAccess(), passenger, passenger), (float) 200); + target.invulnerableTime = 0; + if (this.entityData.get(COOL_DOWN) > 98) { + laserExplosion(targetPos); + } + return (float) pos.distanceTo(target.position()); + } + } + return 512; } private void laserExplosion(Vec3 pos) { diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModBlocks.java b/src/main/java/com/atsuishio/superbwarfare/init/ModBlocks.java index 35bb8ef97..7c587668c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModBlocks.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModBlocks.java @@ -28,4 +28,5 @@ public class ModBlocks { public static final RegistryObject SILVER_BLOCK = REGISTRY.register("silver_block", SilverBlock::new); public static final RegistryObject CEMENTED_CARBIDE_BLOCK = REGISTRY.register("cemented_carbide_block", CementedCarbideBlock::new); public static final RegistryObject CONTAINER = REGISTRY.register("container", ContainerBlock::new); + public static final RegistryObject CHARGING_STATION = REGISTRY.register("charging_station", ChargingStationBlock::new); } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java index ce5b71082..3fb76c53c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java @@ -235,6 +235,7 @@ public class ModItems { public static final RegistryObject BARBED_WIRE = block(ModBlocks.BARBED_WIRE); public static final RegistryObject DRAGON_TEETH = block(ModBlocks.DRAGON_TEETH); public static final RegistryObject REFORGING_TABLE = block(ModBlocks.REFORGING_TABLE); + public static final RegistryObject CHARGING_STATION = block(ModBlocks.CHARGING_STATION); public static final RegistryObject LEAD_BLOCK = block(ModBlocks.LEAD_BLOCK); public static final RegistryObject STEEL_BLOCK = block(ModBlocks.STEEL_BLOCK); public static final RegistryObject TUNGSTEN_BLOCK = block(ModBlocks.TUNGSTEN_BLOCK); diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index b3e865357..e4d72d5ca 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -209,6 +209,7 @@ "block.superbwarfare.steel_block": "Steel Block", "block.superbwarfare.silver_block": "Silver Block", "block.superbwarfare.cemented_carbide_block": "Cemented Carbide Block", + "block.superbwarfare.charging_station": "Charging Station", "item.superbwarfare.high_energy_explosives": "High Energy Explosives", "item.superbwarfare.grain": "Grain", diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index c173c7dcf..7cd705df5 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -209,6 +209,7 @@ "block.superbwarfare.silver_block": "银块", "block.superbwarfare.cemented_carbide_block": "硬质合金块", "block.superbwarfare.steel_block": "钢块", + "block.superbwarfare.charging_station": "充电站", "item.superbwarfare.high_energy_explosives": "高能炸药", "item.superbwarfare.grain": "推进药柱",