添加tag

This commit is contained in:
17146 2024-11-28 19:22:55 +08:00
parent 684ff941ed
commit 13b7cbc010
5 changed files with 28 additions and 5 deletions

View file

@ -1,5 +1,5 @@
// 1.20.1 2024-09-17T14:58:52.1339272 Tags for minecraft:block mod id superbwarfare
// 1.20.1 2024-11-28T19:20:29.861331 Tags for minecraft:block mod id superbwarfare
0acfd31854bf15f2c108138b3df7206bd2593e6b data/minecraft/tags/blocks/mineable/axe.json
57fcadb5e8617e16a9092282796bc311857317d3 data/minecraft/tags/blocks/mineable/pickaxe.json
e059c279c01c012fe89bd4bfadf8cd6d70b3b948 data/minecraft/tags/blocks/mineable/pickaxe.json
3da7f021790388a122717f16f51c7ec5232eebcb data/minecraft/tags/blocks/mineable/shovel.json
f42a8c01336e64b74da966f03d45ee0d60ac5d6b data/minecraft/tags/blocks/needs_iron_tool.json

View file

@ -13,6 +13,7 @@
"superbwarfare:silver_ore",
"superbwarfare:deepslate_silver_ore",
"superbwarfare:silver_block",
"superbwarfare:jump_pad"
"superbwarfare:jump_pad",
"superbwarfare:container"
]
}

View file

@ -3,6 +3,11 @@ package com.atsuishio.superbwarfare.block;
import com.atsuishio.superbwarfare.block.entity.ContainerBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.*;
@ -16,6 +21,7 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import javax.annotation.Nullable;
import java.util.List;
@SuppressWarnings("deprecation")
public class ContainerBlock extends BaseEntityBlock implements SimpleWaterloggedBlock, EntityBlock {
@ -24,10 +30,21 @@ public class ContainerBlock extends BaseEntityBlock implements SimpleWaterlogged
public static final BooleanProperty OPENED = BooleanProperty.create("opened");
public ContainerBlock() {
super(BlockBehaviour.Properties.of().sound(SoundType.METAL).strength(3.0f).noCollission());
super(BlockBehaviour.Properties.of().sound(SoundType.METAL).strength(3.0f).noOcclusion().requiresCorrectToolForDrops());
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(OPENED, false));
}
@Override
public void appendHoverText(ItemStack pStack, @org.jetbrains.annotations.Nullable BlockGetter pLevel, List<Component> pTooltip, TooltipFlag pFlag) {
super.appendHoverText(pStack, pLevel, pTooltip, pFlag);
CompoundTag compoundtag = BlockItem.getBlockEntityData(pStack);
if (compoundtag != null) {
if (compoundtag.contains("Test")) {
pTooltip.add(Component.literal("Test: " + compoundtag.getInt("Test")));
}
}
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
return state.getValue(OPENED) ? box(0, 0, 0, 16, 1, 16) : box(0, 0, 0, 16, 16, 16);

View file

@ -17,6 +17,8 @@ import software.bernie.geckolib.util.GeckoLibUtil;
public class ContainerBlockEntity extends BlockEntity implements GeoBlockEntity {
public int test = 0;
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
public ContainerBlockEntity(BlockPos pos, BlockState state) {
@ -40,11 +42,13 @@ public class ContainerBlockEntity extends BlockEntity implements GeoBlockEntity
@Override
public void load(CompoundTag compound) {
super.load(compound);
this.test = compound.getInt("Test");
}
@Override
public void saveAdditional(CompoundTag compound) {
super.saveAdditional(compound);
compound.putInt("Test", this.test);
}
@Override

View file

@ -26,7 +26,8 @@ public class ModBlockTagProvider extends BlockTagsProvider {
this.tag(BlockTags.MINEABLE_WITH_PICKAXE).add(ModBlocks.GALENA_ORE.get(), ModBlocks.SCHEELITE_ORE.get(),
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.CEMENTED_CARBIDE_BLOCK.get(), ModBlocks.SILVER_ORE.get(), ModBlocks.DEEPSLATE_SILVER_ORE.get(),
ModBlocks.SILVER_BLOCK.get(), ModBlocks.JUMP_PAD.get(), ModBlocks.CONTAINER.get());
this.tag(BlockTags.MINEABLE_WITH_SHOVEL).add(ModBlocks.SANDBAG.get());
}