Skip to content

Commit

Permalink
Don't add bounding blocks to the creative tab
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster committed Jun 30, 2023
1 parent 2f4daf0 commit b85c75a
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import mekanism.api.text.EnumColor;
import mekanism.api.text.TextComponentUtil;
import mekanism.common.lib.math.Pos3D;
import mekanism.common.registration.impl.ItemDeferredRegister;
import mekanism.common.util.WorldUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockSource;
Expand Down Expand Up @@ -33,7 +32,7 @@ public class ItemBalloon extends Item {
private final EnumColor color;

public ItemBalloon(EnumColor color) {
super(ItemDeferredRegister.getMekBaseProperties());
super(new Item.Properties());
this.color = color;
DispenserBlock.registerBehavior(this, new DispenserBehavior(this.color));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ public List<BakedQuad> load(@NotNull SidedConnection key) {
//If the part should be rotated, then we need to use a custom IModelTransform
Vector3f vecForDirection = Vec3.atLowerCornerOf(side.getNormal()).toVector3f();
vecForDirection.mul(-1);
//TODO - 1.20: Test this
Quaternionf quaternion = new Quaternionf().setAngleAxis(iconStatus.getAngle(), vecForDirection.x, vecForDirection.y, vecForDirection.z);
Transformation matrix = new Transformation(null, quaternion, null, null);
transform = new SimpleModelState(transform.getRotation().compose(matrix), transform.isUvLocked());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mekanism/common/item/block/ItemBlockBin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import mekanism.common.inventory.BinMekanismInventory;
import mekanism.common.inventory.slot.BinInventorySlot;
import mekanism.common.item.interfaces.IItemSustainedInventory;
import mekanism.common.registration.impl.ItemDeferredRegister;
import mekanism.common.tier.BinTier;
import mekanism.common.util.text.TextUtils;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
Expand All @@ -20,7 +20,7 @@
public class ItemBlockBin extends ItemBlockTooltip<BlockBin> implements IItemSustainedInventory {

public ItemBlockBin(BlockBin block) {
super(block, ItemDeferredRegister.getMekBaseProperties().stacksTo(1));
super(block, new Item.Properties().stacksTo(1));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import mekanism.common.block.BlockCardboardBox.BlockData;
import mekanism.common.block.states.BlockStateHelper;
import mekanism.common.config.MekanismConfig;
import mekanism.common.registration.impl.ItemDeferredRegister;
import mekanism.common.tags.MekanismTags;
import mekanism.common.tile.TileEntityCardboardBox;
import mekanism.common.util.ItemDataUtils;
Expand All @@ -24,6 +23,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.context.BlockPlaceContext;
Expand All @@ -39,7 +39,7 @@
public class ItemBlockCardboardBox extends ItemBlockMekanism<BlockCardboardBox> {

public ItemBlockCardboardBox(BlockCardboardBox block) {
super(block, ItemDeferredRegister.getMekBaseProperties().stacksTo(16));
super(block, new Item.Properties().stacksTo(16));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import mekanism.api.text.EnumColor;
import mekanism.api.text.TextComponentUtil;
import mekanism.common.block.interfaces.IColoredBlock;
import mekanism.common.registration.impl.ItemDeferredRegister;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
Expand All @@ -15,7 +14,7 @@
public class ItemBlockColoredName extends BlockItem {

public <BLOCK extends Block & IColoredBlock> ItemBlockColoredName(BLOCK block) {
this(block, ItemDeferredRegister.getMekBaseProperties());
this(block, new Item.Properties());
}

public <BLOCK extends Block & IColoredBlock> ItemBlockColoredName(BLOCK block, Item.Properties properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import mekanism.common.block.attribute.Attribute;
import mekanism.common.block.prefab.BlockTile;
import mekanism.common.content.blocktype.BlockTypeTile;
import mekanism.common.registration.impl.ItemDeferredRegister;
import mekanism.common.tier.InductionCellTier;
import mekanism.common.tile.multiblock.TileEntityInductionCell;
import mekanism.common.util.StorageUtils;
import mekanism.common.util.text.EnergyDisplay;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
Expand All @@ -20,7 +20,7 @@
public class ItemBlockInductionCell extends ItemBlockTooltip<BlockTile<TileEntityInductionCell, BlockTypeTile<TileEntityInductionCell>>> {

public ItemBlockInductionCell(BlockTile<TileEntityInductionCell, BlockTypeTile<TileEntityInductionCell>> block) {
super(block, ItemDeferredRegister.getMekBaseProperties());
super(block, new Item.Properties());
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import mekanism.common.block.attribute.Attribute;
import mekanism.common.block.prefab.BlockTile;
import mekanism.common.content.blocktype.BlockTypeTile;
import mekanism.common.registration.impl.ItemDeferredRegister;
import mekanism.common.tier.InductionProviderTier;
import mekanism.common.tile.multiblock.TileEntityInductionProvider;
import mekanism.common.util.text.EnergyDisplay;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
Expand All @@ -19,7 +19,7 @@
public class ItemBlockInductionProvider extends ItemBlockTooltip<BlockTile<TileEntityInductionProvider, BlockTypeTile<TileEntityInductionProvider>>> {

public ItemBlockInductionProvider(BlockTile<TileEntityInductionProvider, BlockTypeTile<TileEntityInductionProvider>> block) {
super(block, ItemDeferredRegister.getMekBaseProperties());
super(block, new Item.Properties());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package mekanism.common.item.block;

import mekanism.common.registration.impl.ItemDeferredRegister;
import mekanism.common.util.WorldUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.item.context.UseOnContext;
Expand All @@ -22,7 +22,7 @@
public abstract class ItemBlockMultipartAble<BLOCK extends Block> extends ItemBlockMekanism<BLOCK> {

public ItemBlockMultipartAble(BLOCK block) {
super(block, ItemDeferredRegister.getMekBaseProperties());
super(block, new Item.Properties());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import mekanism.common.block.attribute.Attributes.AttributeInventory;
import mekanism.common.block.interfaces.IHasDescription;
import mekanism.common.item.interfaces.IItemSustainedInventory;
import mekanism.common.registration.impl.ItemDeferredRegister;
import mekanism.common.util.InventoryUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.StorageUtils;
Expand Down Expand Up @@ -41,7 +40,7 @@ public ItemBlockTooltip(BLOCK block, Item.Properties properties) {
}

public ItemBlockTooltip(BLOCK block) {
this(block, true, ItemDeferredRegister.getMekBaseProperties().stacksTo(1));
this(block, true, new Item.Properties().stacksTo(1));
}

protected ItemBlockTooltip(BLOCK block, boolean hasDetails, Properties properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public <BLOCK extends Block> BlockRegistryObject<BLOCK, BlockItem> register(Stri

public <BLOCK extends Block, ITEM extends BlockItem> BlockRegistryObject<BLOCK, ITEM> registerDefaultProperties(String name, Supplier<? extends BLOCK> blockSupplier,
BiFunction<BLOCK, Item.Properties, ITEM> itemCreator) {
return register(name, blockSupplier, block -> itemCreator.apply(block, ItemDeferredRegister.getMekBaseProperties()));
return register(name, blockSupplier, block -> itemCreator.apply(block, new Item.Properties()));
}

public <BLOCK extends Block, ITEM extends BlockItem> BlockRegistryObject<BLOCK, ITEM> register(String name, Supplier<? extends BLOCK> blockSupplier,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package mekanism.common.registration.impl;

import java.util.function.UnaryOperator;
import mekanism.api.providers.IBlockProvider;
import mekanism.api.providers.IItemProvider;
import mekanism.api.text.ILangEntry;
import mekanism.common.block.BlockBounding;
import mekanism.common.registration.WrappedDeferredRegister;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.CreativeModeTab;
Expand Down Expand Up @@ -60,8 +62,11 @@ public static void addToDisplay(ItemDeferredRegister register, CreativeModeTab.O
}

public static void addToDisplay(BlockDeferredRegister register, CreativeModeTab.Output output) {
for (IItemProvider itemProvider : register.getAllBlocks()) {
addToDisplay(itemProvider, output);
for (IBlockProvider itemProvider : register.getAllBlocks()) {
//Don't add bounding blocks to the creative tab
if (!(itemProvider.getBlock() instanceof BlockBounding)) {
addToDisplay(itemProvider, output);
}
}
}

Expand All @@ -74,8 +79,7 @@ public static void addToDisplay(FluidDeferredRegister register, CreativeModeTab.
//TODO - 1.20: Re-evaluate this and maybe inline the stuff into their respective creative tabs
public interface ICustomCreativeTabContents {

default void addItems(CreativeModeTab.Output tabOutput) {
}
void addItems(CreativeModeTab.Output tabOutput);

default boolean addDefault() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public <TYPE extends MekanismFluidType, BUCKET extends BucketItem> FluidRegistry
fluidRegistryObject.updateStill(fluidRegister.register(name, () -> new Source(fluidProperties)));
fluidRegistryObject.updateFlowing(fluidRegister.register(flowingName, () -> new Flowing(fluidProperties)));
fluidRegistryObject.updateBucket(itemRegister.register(bucketName, () -> bucketCreator.create(fluidRegistryObject::getStillFluid,
ItemDeferredRegister.getMekBaseProperties().stacksTo(1).craftRemainder(Items.BUCKET))));
new Item.Properties().stacksTo(1).craftRemainder(Items.BUCKET))));
//Note: The block properties used here is a copy of the ones for water
fluidRegistryObject.updateBlock(blockRegister.register(name, () -> new LiquidBlock(fluidRegistryObject::getStillFluid, BlockBehaviour.Properties.of()
.noCollission().strength(100.0F).noLootTable().replaceable().pushReaction(PushReaction.DESTROY).liquid().mapColor(MapColor.WATER))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ public ItemDeferredRegister(String modid) {
super(modid, ForgeRegistries.ITEMS);
}

public static Item.Properties getMekBaseProperties() {
//TODO - 1.20: Do we want to inline the creation as we now have no other base properties?
//TODO - 1.20: Ensure everything actually ends up in a creative tab
return new Item.Properties();
}

public ItemRegistryObject<Item> register(String name) {
return register(name, Item::new);
}
Expand All @@ -59,15 +53,15 @@ public Component getName(@NotNull ItemStack stack) {
public ItemRegistryObject<ItemModule> registerModule(ModuleRegistryObject<?> moduleDataSupplier) {
//Note: We use the internal helper just in case we end up needing to know it is an ItemModule instead of just an Item somewhere
return register("module_" + moduleDataSupplier.getInternalRegistryName(),
() -> ModuleHelper.INSTANCE.createModuleItem(moduleDataSupplier, getMekBaseProperties()));
() -> ModuleHelper.INSTANCE.createModuleItem(moduleDataSupplier, new Item.Properties()));
}

public <ITEM extends Item> ItemRegistryObject<ITEM> register(String name, Function<Item.Properties, ITEM> sup) {
return register(name, () -> sup.apply(getMekBaseProperties()));
return register(name, () -> sup.apply(new Item.Properties()));
}

public <ITEM extends Item> ItemRegistryObject<ITEM> registerUnburnable(String name, Function<Item.Properties, ITEM> sup) {
return register(name, () -> sup.apply(getMekBaseProperties().fireResistant()));
return register(name, () -> sup.apply(new Item.Properties().fireResistant()));
}

public <ITEM extends Item> ItemRegistryObject<ITEM> register(String name, Supplier<? extends ITEM> sup) {
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/mekanism/common/registries/MekanismBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
import mekanism.common.util.EnumUtils;
import net.minecraft.stats.Stats;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
Expand Down Expand Up @@ -337,7 +336,7 @@ private MekanismBlocks() {
public static final BlockRegistryObject<BlockThermodynamicConductor, ItemBlockThermodynamicConductor> ELITE_THERMODYNAMIC_CONDUCTOR = registerThermodynamicConductor(ConductorTier.ELITE);
public static final BlockRegistryObject<BlockThermodynamicConductor, ItemBlockThermodynamicConductor> ULTIMATE_THERMODYNAMIC_CONDUCTOR = registerThermodynamicConductor(ConductorTier.ULTIMATE);

public static final BlockRegistryObject<BlockBounding, BlockItem> BOUNDING_BLOCK = registerBoundingBlock("bounding_block", BlockBounding::new);
public static final BlockRegistryObject<BlockBounding, BlockItem> BOUNDING_BLOCK = BLOCKS.register("bounding_block", BlockBounding::new);

public static final BlockRegistryObject<BlockTileModel<TileEntityChemicalTank, Machine<TileEntityChemicalTank>>, ItemBlockChemicalTank> BASIC_CHEMICAL_TANK = registerChemicalTank(MekanismBlockTypes.BASIC_CHEMICAL_TANK);
public static final BlockRegistryObject<BlockTileModel<TileEntityChemicalTank, Machine<TileEntityChemicalTank>>, ItemBlockChemicalTank> ADVANCED_CHEMICAL_TANK = registerChemicalTank(MekanismBlockTypes.ADVANCED_CHEMICAL_TANK);
Expand All @@ -348,10 +347,6 @@ private MekanismBlocks() {
public static final BlockRegistryObject<BlockCardboardBox, ItemBlockCardboardBox> CARDBOARD_BOX = BLOCKS.register("cardboard_box", BlockCardboardBox::new, ItemBlockCardboardBox::new);
public static final BlockRegistryObject<Block, BlockItem> SALT_BLOCK = BLOCKS.register("block_salt", BlockBehaviour.Properties.of().strength(0.5F).sound(SoundType.SAND).instrument(NoteBlockInstrument.SNARE));

private static BlockRegistryObject<BlockBounding, BlockItem> registerBoundingBlock(String name, Supplier<BlockBounding> blockSupplier) {
return BLOCKS.register(name, blockSupplier, block -> new BlockItem(block, new Item.Properties()));
}

private static BlockRegistryObject<BlockResource, ItemBlockResource> registerResourceBlock(BlockResourceInfo resource) {
return BLOCKS.registerDefaultProperties("block_" + resource.getRegistrySuffix(), () -> new BlockResource(resource), (block, properties) -> {
if (!block.getResourceInfo().burnsInFire()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class MekanismCreativeTabs {
public static final CreativeTabRegistryObject MEKANISM = CREATIVE_TABS.registerMain(MekanismLang.MEKANISM, MekanismItems.ATOMIC_ALLOY, builder ->
builder.withSearchBar()//Allow our tabs to be searchable for convenience purposes
.displayItems((displayParameters, output) -> {
//TODO - 1.20: Add other module's items unless we decide to split up into multiple tabs which might be time to do so
CreativeTabDeferredRegister.addToDisplay(MekanismItems.ITEMS, output);
CreativeTabDeferredRegister.addToDisplay(MekanismBlocks.BLOCKS, output);
CreativeTabDeferredRegister.addToDisplay(MekanismFluids.FLUIDS, output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private MekanismItems() {
public static final Table<ResourceType, PrimaryResource, ItemRegistryObject<Item>> PROCESSED_RESOURCES = HashBasedTable.create();

public static final ItemRegistryObject<ItemRobit> ROBIT = ITEMS.register("robit", ItemRobit::new);
public static final ItemRegistryObject<ItemEnergized> ENERGY_TABLET = ITEMS.register("energy_tablet", () -> new ItemEnergized(MekanismConfig.gear.tabletChargeRate, MekanismConfig.gear.tabletMaxEnergy, BasicEnergyContainer.alwaysTrue, BasicEnergyContainer.alwaysTrue, ItemDeferredRegister.getMekBaseProperties().rarity(Rarity.UNCOMMON)));
public static final ItemRegistryObject<ItemEnergized> ENERGY_TABLET = ITEMS.register("energy_tablet", () -> new ItemEnergized(MekanismConfig.gear.tabletChargeRate, MekanismConfig.gear.tabletMaxEnergy, BasicEnergyContainer.alwaysTrue, BasicEnergyContainer.alwaysTrue, new Item.Properties().rarity(Rarity.UNCOMMON)));
public static final ItemRegistryObject<ItemConfigurator> CONFIGURATOR = ITEMS.register("configurator", ItemConfigurator::new);
public static final ItemRegistryObject<ItemNetworkReader> NETWORK_READER = ITEMS.register("network_reader", ItemNetworkReader::new);
public static final ItemRegistryObject<ItemDictionary> DICTIONARY = ITEMS.register("dictionary", ItemDictionary::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private static <ITEM extends Item> ItemRegistryObject<ITEM> register(BiFunction<
}

private static Item.Properties getBaseProperties(BaseMekanismMaterial material) {
Item.Properties properties = ItemDeferredRegister.getMekBaseProperties();
Item.Properties properties = new Item.Properties();
if (!material.burnsInFire()) {
properties = properties.fireResistant();
}
Expand Down

0 comments on commit b85c75a

Please sign in to comment.