From d6f5e67741091753012baa4f7e670bbd7585094c Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Sun, 11 May 2025 17:10:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=BD=BD=E5=85=B7=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E5=99=A8=E8=B4=B4=E5=9B=BE=EF=BC=8C=E9=9B=86=E8=A3=85?= =?UTF-8?q?=E7=AE=B1=E8=BD=BD=E5=85=B7=E6=9C=9D=E5=90=91=E4=B8=8E=E6=96=B9?= =?UTF-8?q?=E5=9D=97=E6=9C=9D=E5=90=91=E6=9C=89=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../f93f628a3b0902e77de76541bcff68d1e5e3578f | 4 +-- .../blockstates/vehicle_deployer.json | 29 +++++++++++++++++- .../block/VehicleDeployerBlock.java | 20 +++++++----- .../block/entity/ContainerBlockEntity.java | 5 ++- .../entity/VehicleDeployerBlockEntity.java | 7 +++-- .../datagen/ModBlockStateProvider.java | 3 +- .../textures/block/vehicle_deployer_top.png | Bin 301 -> 4406 bytes 7 files changed, 53 insertions(+), 15 deletions(-) diff --git a/src/generated/resources/.cache/f93f628a3b0902e77de76541bcff68d1e5e3578f b/src/generated/resources/.cache/f93f628a3b0902e77de76541bcff68d1e5e3578f index f60401c43..61941f60a 100644 --- a/src/generated/resources/.cache/f93f628a3b0902e77de76541bcff68d1e5e3578f +++ b/src/generated/resources/.cache/f93f628a3b0902e77de76541bcff68d1e5e3578f @@ -1,4 +1,4 @@ -// 1.21.1 2025-05-11T14:59:51.1283619 Block States: superbwarfare +// 1.21.1 2025-05-11T18:58:17.1566789 Block States: superbwarfare f3b778ca36ca78c3d80f1b778078897f59bdb0c5 assets/superbwarfare/blockstates/barbed_wire.json 0cfad4f53a8047c402edf978d0c8cf6269f063cb assets/superbwarfare/blockstates/cemented_carbide_block.json 472c06e6b43ad09925edaa88e9376bfd27ab267f assets/superbwarfare/blockstates/charging_station.json @@ -18,7 +18,7 @@ cf801445ce7cec678d5e811b5985506472e6ba4c assets/superbwarfare/blockstates/silver 2a91b72f2d7974e100ae502006a2384bd66b29e5 assets/superbwarfare/blockstates/small_container.json a175c908c9aabee3a073844cd58ec9dfe6498bf0 assets/superbwarfare/blockstates/steel_block.json d4bbef5040ef43c362b28ea12ea73fb4a3db9adc assets/superbwarfare/blockstates/tungsten_block.json -bb452d7f81cfccf77b91a50eaf7c17acc15c258a assets/superbwarfare/blockstates/vehicle_deployer.json +df138042591221cb2091c7e2f86a0ce5c77949be assets/superbwarfare/blockstates/vehicle_deployer.json 5f1c22b64ff3ca4db9987f91a7179c9e705c7601 assets/superbwarfare/models/block/cemented_carbide_block.json 0fe4613a4446ac485eee58bed6d0d8f5b38f6253 assets/superbwarfare/models/block/deepslate_galena_ore.json 84f584f684519f686e976b994f0a2639a98a7851 assets/superbwarfare/models/block/deepslate_scheelite_ore.json diff --git a/src/generated/resources/assets/superbwarfare/blockstates/vehicle_deployer.json b/src/generated/resources/assets/superbwarfare/blockstates/vehicle_deployer.json index 137d9aece..1b81ebde2 100644 --- a/src/generated/resources/assets/superbwarfare/blockstates/vehicle_deployer.json +++ b/src/generated/resources/assets/superbwarfare/blockstates/vehicle_deployer.json @@ -1,7 +1,34 @@ { "variants": { - "": { + "facing=east,triggered=false": { + "model": "superbwarfare:block/vehicle_deployer", + "y": 90 + }, + "facing=east,triggered=true": { + "model": "superbwarfare:block/vehicle_deployer", + "y": 90 + }, + "facing=north,triggered=false": { "model": "superbwarfare:block/vehicle_deployer" + }, + "facing=north,triggered=true": { + "model": "superbwarfare:block/vehicle_deployer" + }, + "facing=south,triggered=false": { + "model": "superbwarfare:block/vehicle_deployer", + "y": 180 + }, + "facing=south,triggered=true": { + "model": "superbwarfare:block/vehicle_deployer", + "y": 180 + }, + "facing=west,triggered=false": { + "model": "superbwarfare:block/vehicle_deployer", + "y": 270 + }, + "facing=west,triggered=true": { + "model": "superbwarfare:block/vehicle_deployer", + "y": 270 } } } \ No newline at end of file diff --git a/src/main/java/com/atsuishio/superbwarfare/block/VehicleDeployerBlock.java b/src/main/java/com/atsuishio/superbwarfare/block/VehicleDeployerBlock.java index f64db9ade..b747950d5 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/VehicleDeployerBlock.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/VehicleDeployerBlock.java @@ -5,22 +5,22 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.mojang.serialization.MapCodec; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.BaseEntityBlock; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.RenderShape; -import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.*; 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 net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.phys.BlockHitResult; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,11 +30,12 @@ import javax.annotation.ParametersAreNonnullByDefault; @SuppressWarnings("deprecation") public class VehicleDeployerBlock extends BaseEntityBlock { + public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; public static final BooleanProperty TRIGGERED = BlockStateProperties.TRIGGERED; public VehicleDeployerBlock() { super(Properties.of().sound(SoundType.METAL).strength(3.0f).requiresCorrectToolForDrops()); - this.registerDefaultState(this.stateDefinition.any().setValue(TRIGGERED, false)); + this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(TRIGGERED, false)); } private VehicleDeployerBlock(BlockBehaviour.Properties properties) { @@ -43,7 +44,7 @@ public class VehicleDeployerBlock extends BaseEntityBlock { @Override protected void createBlockStateDefinition(StateDefinition.@NotNull Builder builder) { - builder.add(TRIGGERED); + builder.add(FACING).add(TRIGGERED); } @Override @@ -73,7 +74,7 @@ public class VehicleDeployerBlock extends BaseEntityBlock { if (charged && !triggered) { level.setBlock(pos, state.setValue(TRIGGERED, Boolean.TRUE), 4); if (level.getBlockEntity(pos) instanceof VehicleDeployerBlockEntity blockEntity) { - blockEntity.deploy(); + blockEntity.deploy(state); } } else if (!charged && triggered) { level.setBlock(pos, state.setValue(TRIGGERED, Boolean.FALSE), 4); @@ -95,4 +96,9 @@ public class VehicleDeployerBlock extends BaseEntityBlock { public @NotNull RenderShape getRenderShape(@NotNull BlockState state) { return RenderShape.MODEL; } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext context) { + return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()); + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/block/entity/ContainerBlockEntity.java b/src/main/java/com/atsuishio/superbwarfare/block/entity/ContainerBlockEntity.java index 85acec268..4a5e0c07c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/entity/ContainerBlockEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/entity/ContainerBlockEntity.java @@ -54,17 +54,20 @@ public class ContainerBlockEntity extends BlockEntity implements GeoBlockEntity pLevel.playSound(null, pPos, SoundEvents.GENERIC_EXPLODE.value(), SoundSource.BLOCKS, 4.0F, (1.0F + (pLevel.random.nextFloat() - pLevel.random.nextFloat()) * 0.2F) * 0.7F); } } else { + var direction = pState.getValue(ContainerBlock.FACING); + if (blockEntity.entityTag != null) { var entity = blockEntity.entityType.create(pLevel); if (entity != null) { - entity.load(blockEntity.entityTag); entity.setPos(pPos.getX() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getY() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getZ() + 0.5 + (2 * Math.random() - 1) * 0.1f); + entity.setYRot(direction.toYRot()); pLevel.addFreshEntity(entity); } } else if (blockEntity.entityType != null) { var entity = blockEntity.entityType.create(pLevel); if (entity != null) { entity.setPos(pPos.getX() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getY() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getZ() + 0.5 + (2 * Math.random() - 1) * 0.1f); + entity.setYRot(direction.toYRot()); pLevel.addFreshEntity(entity); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/block/entity/VehicleDeployerBlockEntity.java b/src/main/java/com/atsuishio/superbwarfare/block/entity/VehicleDeployerBlockEntity.java index bb47d88b8..099358758 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/entity/VehicleDeployerBlockEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/entity/VehicleDeployerBlockEntity.java @@ -1,5 +1,6 @@ package com.atsuishio.superbwarfare.block.entity; +import com.atsuishio.superbwarfare.block.VehicleDeployerBlock; import com.atsuishio.superbwarfare.init.ModBlockEntities; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderLookup; @@ -43,7 +44,7 @@ public class VehicleDeployerBlockEntity extends BlockEntity { this.entityData = tag.copy(); } - public void deploy() { + public void deploy(BlockState state) { if (this.level == null) return; if (this.entityData.contains("EntityType")) { @@ -59,8 +60,11 @@ public class VehicleDeployerBlockEntity extends BlockEntity { entity.load(entityTag); } + var direction = state.getValue(VehicleDeployerBlock.FACING); + entity.setUUID(UUID.randomUUID()); entity.setPos(this.getBlockPos().getX() + 0.5 + (2 * Math.random() - 1) * 0.1f, this.getBlockPos().getY() + 1.5 + (2 * Math.random() - 1) * 0.1f, this.getBlockPos().getZ() + 0.5 + (2 * Math.random() - 1) * 0.1f); + entity.setYRot(direction.toYRot()); this.level.addFreshEntity(entity); } } @@ -71,5 +75,4 @@ public class VehicleDeployerBlockEntity extends BlockEntity { this.entityData = tag.copyTag(); } - } diff --git a/src/main/java/com/atsuishio/superbwarfare/datagen/ModBlockStateProvider.java b/src/main/java/com/atsuishio/superbwarfare/datagen/ModBlockStateProvider.java index 28b878afc..ca73fea7e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/datagen/ModBlockStateProvider.java +++ b/src/main/java/com/atsuishio/superbwarfare/datagen/ModBlockStateProvider.java @@ -27,8 +27,7 @@ public class ModBlockStateProvider extends BlockStateProvider { horizontalBlock(ModBlocks.SMALL_CONTAINER.get(), new ModelFile.UncheckedModelFile(modLoc("block/small_container"))); horizontalBlock(ModBlocks.CHARGING_STATION.get(), new ModelFile.UncheckedModelFile(modLoc("block/charging_station"))); horizontalBlock(ModBlocks.CREATIVE_CHARGING_STATION.get(), new ModelFile.UncheckedModelFile(modLoc("block/creative_charging_station"))); - - simpleBlock(ModBlocks.VEHICLE_DEPLOYER.get(), models().cubeBottomTop("vehicle_deployer", Mod.loc("block/vehicle_deployer_side"), + horizontalBlock(ModBlocks.VEHICLE_DEPLOYER.get(), models().cubeBottomTop("vehicle_deployer", Mod.loc("block/vehicle_deployer_side"), Mod.loc("block/vehicle_deployer_bottom"), Mod.loc("block/vehicle_deployer_top")) .texture("particle", Mod.loc("block/vehicle_deployer_bottom"))); diff --git a/src/main/resources/assets/superbwarfare/textures/block/vehicle_deployer_top.png b/src/main/resources/assets/superbwarfare/textures/block/vehicle_deployer_top.png index 4a891290c956035c89618f067d7b496ddf510d3c..c499696c01916584c09aec62bfee320cb245e423 100644 GIT binary patch literal 4406 zcmeHKdr%bj9bY7%JVa4M2cj%1Oc7@9_U`sxD|ZAq9v5>6NI}9wez&^^E8OjQw{Qn2 zTEz$2L};`|Lz|A6M-v;XQe$f^&l*x2ZK?*xU`%WVG%zXyCU4AuE%LpV0&r9c&H1^B~}<*H3(~;M|5-byREb z-C*0&`UO!IQ*<=fb0)9ZtDE7WamS_Ul@juZ~mg< zhUBABf9W3Reu*k-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