调整载具部署器贴图,集装箱载具朝向与方块朝向有关

This commit is contained in:
17146 2025-05-11 17:10:55 +08:00 committed by Light_Quanta
parent 3a36293ae6
commit d6f5e67741
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
7 changed files with 53 additions and 15 deletions

View file

@ -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

View file

@ -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
}
}
}

View file

@ -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<Block, BlockState> 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());
}
}

View file

@ -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);
}
}

View file

@ -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();
}
}

View file

@ -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")));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 301 B

After

Width:  |  Height:  |  Size: 4.3 KiB