Skip to content

Commit

Permalink
Add useBlockDescriptionPrefix() calls for block items in DR and tests (
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n authored Oct 16, 2024
1 parent b8a868a commit 47d4034
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public <I extends Item> DeferredItem<I> register(String name, Supplier<? extends
* @see #registerSimpleBlockItem(Holder)
*/
public DeferredItem<BlockItem> registerSimpleBlockItem(String name, Supplier<? extends Block> block, Item.Properties properties) {
return this.register(name, key -> new BlockItem(block.get(), properties.setId(ResourceKey.create(Registries.ITEM, key))));
return this.register(name, key -> new BlockItem(block.get(), properties.setId(ResourceKey.create(Registries.ITEM, key)).useBlockDescriptionPrefix()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public static void registerBlocks(RegisterEvent event) {
@SubscribeEvent
public static void registerItems(RegisterEvent event) {
event.register(Registries.ITEM, helper -> {
helper.register(CUSTOM_SOIL.getId(), new BlockItem(CUSTOM_SOIL.get(), new Item.Properties().setId(ResourceKey.create(Registries.ITEM, CUSTOM_SOIL.getId()))));
helper.register(CUSTOM_PLANT.getId(), new BlockItem(CUSTOM_PLANT.get(), new Item.Properties().setId(ResourceKey.create(Registries.ITEM, CUSTOM_PLANT.getId()))));
helper.register(CUSTOM_SOIL.getId(), new BlockItem(CUSTOM_SOIL.get(), new Item.Properties().setId(ResourceKey.create(Registries.ITEM, CUSTOM_SOIL.getId())).useBlockDescriptionPrefix()));
helper.register(CUSTOM_PLANT.getId(), new BlockItem(CUSTOM_PLANT.get(), new Item.Properties().setId(ResourceKey.create(Registries.ITEM, CUSTOM_PLANT.getId())).useBlockDescriptionPrefix()));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class FlowerPotTest {
public static final DeferredBlock<FlowerPotBlock> OAK_FLOWER_POT = BLOCKS.registerBlock(BLOCK_ID + "_oak", props -> new FlowerPotBlock(EMPTY_FLOWER_POT, () -> Blocks.OAK_SAPLING, props), Block.Properties.ofFullCopy(Blocks.FLOWER_POT));

static {
ITEMS.register(BLOCK_ID, () -> new BlockItem(EMPTY_FLOWER_POT.get(), new Item.Properties().setId(ResourceKey.create(Registries.ITEM, EMPTY_FLOWER_POT.getId()))));
ITEMS.register(BLOCK_ID, () -> new BlockItem(EMPTY_FLOWER_POT.get(), new Item.Properties().setId(ResourceKey.create(Registries.ITEM, EMPTY_FLOWER_POT.getId())).useBlockDescriptionPrefix()));
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public float getFriction(BlockState state, LevelReader level, BlockPos pos, Enti

@SubscribeEvent
public static void registerItems(RegisterEvent e) {
e.register(Registries.ITEM, helper -> helper.register(BB_BLOCK.getId(), new BlockItem(BB_BLOCK.get(), new Item.Properties().setId(ResourceKey.create(Registries.ITEM, BB_BLOCK.getId())))));
e.register(Registries.ITEM, helper -> helper.register(BB_BLOCK.getId(), new BlockItem(BB_BLOCK.get(), new Item.Properties().setId(ResourceKey.create(Registries.ITEM, BB_BLOCK.getId())).useBlockDescriptionPrefix())));
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos,
}
}, Block.Properties.of().mapColor(MapColor.WOOD).strength(10));

public static DeferredItem<Item> composite_item = ITEMS.registerItem("composite_block", props -> new BlockItem(composite_block.get(), props) {
public static DeferredItem<Item> composite_item = ITEMS.registerItem("composite_block", props -> new BlockItem(composite_block.get(), props.useBlockDescriptionPrefix()) {
@Override
public boolean canEquip(ItemStack stack, EquipmentSlot armorType, LivingEntity entity) {
return armorType == EquipmentSlot.HEAD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos,
}
}, Block.Properties.of().mapColor(MapColor.WOOD).strength(10));

public static DeferredItem<Item> obj_item = ITEMS.registerItem("obj_block", props -> new BlockItem(obj_block.get(), props) {
public static DeferredItem<Item> obj_item = ITEMS.registerItem("obj_block", props -> new BlockItem(obj_block.get(), props.useBlockDescriptionPrefix()) {
@Override
public boolean canEquip(ItemStack stack, EquipmentSlot armorType, LivingEntity entity) {
return armorType == EquipmentSlot.HEAD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MapColor;
Expand Down Expand Up @@ -45,7 +44,7 @@ public class TRSRTransformerTest {

private static final DeferredBlock<Block> TEST_BLOCK = BLOCKS.registerBlock("test", Block::new, Block.Properties.of().mapColor(MapColor.STONE));
@SuppressWarnings("unused")
private static final DeferredItem<Item> TEST_ITEM = ITEMS.registerItem("test", props -> new BlockItem(TEST_BLOCK.get(), props));
private static final DeferredItem<BlockItem> TEST_ITEM = ITEMS.registerSimpleBlockItem(TEST_BLOCK);

public TRSRTransformerTest(IEventBus modEventBus) {
if (FMLEnvironment.dist.isClient()) {
Expand Down

0 comments on commit 47d4034

Please sign in to comment.