Skip to content

Commit

Permalink
Merge colored name handling fully into ItemBlockMekanism rather than …
Browse files Browse the repository at this point in the history
…having a second variant just for IColoredBlock
  • Loading branch information
pupnewfster committed Mar 1, 2024
1 parent a6edd88 commit 37b85b0
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 81 deletions.
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,14 @@ runs {
programArguments('--accessToken', (String) project.property('mc_accessToken'))
}
}
clientAlt {
configure("client")
if (!project.hasProperty('mc_username')) {
//If the property is missing (so the normal runClient task would use Dev as the name),
// change the name of the alt client type so that it doesn't conflict with the main dev one
programArguments('--username', 'AltDev')
}
}
server {
programArgument('--nogui')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import mekanism.api.text.EnumColor;
import mekanism.common.block.interfaces.IColoredBlock;
import mekanism.common.block.states.BlockStateHelper;
import mekanism.common.item.block.ItemBlockColoredName;
import mekanism.common.item.block.ItemBlockMekanism;
import mekanism.common.registration.impl.BlockDeferredRegister;
import mekanism.common.registration.impl.BlockRegistryObject;
import mekanism.common.util.EnumUtils;
Expand All @@ -37,35 +37,35 @@ private AdditionsBlocks() {

public static final BlockRegistryObject<BlockObsidianTNT, BlockItem> OBSIDIAN_TNT = BLOCKS.register("obsidian_tnt", BlockObsidianTNT::new);

public static final Map<EnumColor, BlockRegistryObject<BlockGlowPanel, ItemBlockColoredName>> GLOW_PANELS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlastic, ItemBlockColoredName>> PLASTIC_BLOCKS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlastic, ItemBlockColoredName>> SLICK_PLASTIC_BLOCKS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlastic, ItemBlockColoredName>> PLASTIC_GLOW_BLOCKS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlastic, ItemBlockColoredName>> REINFORCED_PLASTIC_BLOCKS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticRoad, ItemBlockColoredName>> PLASTIC_ROADS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticTransparent, ItemBlockColoredName>> TRANSPARENT_PLASTIC_BLOCKS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticStairs, ItemBlockColoredName>> PLASTIC_STAIRS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticSlab, ItemBlockColoredName>> PLASTIC_SLABS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticFence, ItemBlockColoredName>> PLASTIC_FENCES = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticFenceGate, ItemBlockColoredName>> PLASTIC_FENCE_GATES = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticStairs, ItemBlockColoredName>> PLASTIC_GLOW_STAIRS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticSlab, ItemBlockColoredName>> PLASTIC_GLOW_SLABS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticTransparentStairs, ItemBlockColoredName>> TRANSPARENT_PLASTIC_STAIRS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticTransparentSlab, ItemBlockColoredName>> TRANSPARENT_PLASTIC_SLABS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockGlowPanel, ItemBlockMekanism<BlockGlowPanel>>> GLOW_PANELS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlastic, ItemBlockMekanism<BlockPlastic>>> PLASTIC_BLOCKS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlastic, ItemBlockMekanism<BlockPlastic>>> SLICK_PLASTIC_BLOCKS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlastic, ItemBlockMekanism<BlockPlastic>>> PLASTIC_GLOW_BLOCKS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlastic, ItemBlockMekanism<BlockPlastic>>> REINFORCED_PLASTIC_BLOCKS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticRoad, ItemBlockMekanism<BlockPlasticRoad>>> PLASTIC_ROADS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticTransparent, ItemBlockMekanism<BlockPlasticTransparent>>> TRANSPARENT_PLASTIC_BLOCKS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticStairs, ItemBlockMekanism<BlockPlasticStairs>>> PLASTIC_STAIRS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticSlab, ItemBlockMekanism<BlockPlasticSlab>>> PLASTIC_SLABS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticFence, ItemBlockMekanism<BlockPlasticFence>>> PLASTIC_FENCES = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticFenceGate, ItemBlockMekanism<BlockPlasticFenceGate>>> PLASTIC_FENCE_GATES = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticStairs, ItemBlockMekanism<BlockPlasticStairs>>> PLASTIC_GLOW_STAIRS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticSlab, ItemBlockMekanism<BlockPlasticSlab>>> PLASTIC_GLOW_SLABS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticTransparentStairs, ItemBlockMekanism<BlockPlasticTransparentStairs>>> TRANSPARENT_PLASTIC_STAIRS = new EnumMap<>(EnumColor.class);
public static final Map<EnumColor, BlockRegistryObject<BlockPlasticTransparentSlab, ItemBlockMekanism<BlockPlasticTransparentSlab>>> TRANSPARENT_PLASTIC_SLABS = new EnumMap<>(EnumColor.class);

static {
for (EnumColor color : EnumUtils.COLORS) {
GLOW_PANELS.put(color, registerColoredBlock(BlockGlowPanel::new, "_glow_panel", color));
BlockRegistryObject<BlockPlastic, ItemBlockColoredName> plasticBlockRO = registerPlastic(color, "_plastic",
BlockRegistryObject<BlockPlastic, ItemBlockMekanism<BlockPlastic>> plasticBlockRO = registerPlastic(color, "_plastic",
properties -> properties.strength(5, 6));
PLASTIC_BLOCKS.put(color, plasticBlockRO);
SLICK_PLASTIC_BLOCKS.put(color, registerPlastic(color, "_slick_plastic", properties -> properties.strength(5, 6).friction(0.98F)));
BlockRegistryObject<BlockPlastic, ItemBlockColoredName> plasticGlowBlockRO = registerPlastic(color, "_plastic_glow",
BlockRegistryObject<BlockPlastic, ItemBlockMekanism<BlockPlastic>> plasticGlowBlockRO = registerPlastic(color, "_plastic_glow",
properties -> properties.strength(5, 6).lightLevel(state -> 10).emissiveRendering(BlockStateHelper.ALWAYS_PREDICATE));
PLASTIC_GLOW_BLOCKS.put(color, plasticGlowBlockRO);
REINFORCED_PLASTIC_BLOCKS.put(color, registerPlastic(color, "_reinforced_plastic", properties -> properties.strength(50, 1_200)));
PLASTIC_ROADS.put(color, registerColoredBlock(BlockPlasticRoad::new, "_plastic_road", color));
BlockRegistryObject<BlockPlasticTransparent, ItemBlockColoredName> transparentPlasticRO = registerColoredBlock(BlockPlasticTransparent::new,
BlockRegistryObject<BlockPlasticTransparent, ItemBlockMekanism<BlockPlasticTransparent>> transparentPlasticRO = registerColoredBlock(BlockPlasticTransparent::new,
"_plastic_transparent", color);
TRANSPARENT_PLASTIC_BLOCKS.put(color, transparentPlasticRO);
PLASTIC_STAIRS.put(color, registerPlasticStairs(plasticBlockRO, color, "_plastic_stairs", UnaryOperator.identity()));
Expand All @@ -80,23 +80,23 @@ private AdditionsBlocks() {
}
}

private static BlockRegistryObject<BlockPlastic, ItemBlockColoredName> registerPlastic(EnumColor color, String blockTypeSuffix,
private static BlockRegistryObject<BlockPlastic, ItemBlockMekanism<BlockPlastic>> registerPlastic(EnumColor color, String blockTypeSuffix,
UnaryOperator<BlockBehaviour.Properties> propertyModifier) {
return registerColoredBlock(c -> new BlockPlastic(c, propertyModifier), blockTypeSuffix, color);
}

private static BlockRegistryObject<BlockPlasticSlab, ItemBlockColoredName> registerPlasticSlab(EnumColor color, String blockTypeSuffix,
private static BlockRegistryObject<BlockPlasticSlab, ItemBlockMekanism<BlockPlasticSlab>> registerPlasticSlab(EnumColor color, String blockTypeSuffix,
UnaryOperator<BlockBehaviour.Properties> propertyModifier) {
return registerColoredBlock(c -> new BlockPlasticSlab(c, propertyModifier), blockTypeSuffix, color);
}

private static BlockRegistryObject<BlockPlasticStairs, ItemBlockColoredName> registerPlasticStairs(IBlockProvider baseBlock, EnumColor color, String blockTypeSuffix,
private static BlockRegistryObject<BlockPlasticStairs, ItemBlockMekanism<BlockPlasticStairs>> registerPlasticStairs(IBlockProvider baseBlock, EnumColor color, String blockTypeSuffix,
UnaryOperator<BlockBehaviour.Properties> propertyModifier) {
return registerColoredBlock(c -> new BlockPlasticStairs(baseBlock, c, propertyModifier), blockTypeSuffix, color);
}

private static <BLOCK extends Block & IColoredBlock> BlockRegistryObject<BLOCK, ItemBlockColoredName> registerColoredBlock(Function<EnumColor, BLOCK> blockCreator,
private static <BLOCK extends Block & IColoredBlock> BlockRegistryObject<BLOCK, ItemBlockMekanism<BLOCK>> registerColoredBlock(Function<EnumColor, BLOCK> blockCreator,
String blockTypeSuffix, EnumColor color) {
return BLOCKS.register(color.getRegistryPrefix() + blockTypeSuffix, () -> blockCreator.apply(color), ItemBlockColoredName::new);
return BLOCKS.registerDefaultProperties(color.getRegistryPrefix() + blockTypeSuffix, () -> blockCreator.apply(color), ItemBlockMekanism::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import mekanism.additions.common.registries.AdditionsBlocks;
import mekanism.api.providers.IBlockProvider;
import mekanism.client.state.BaseBlockStateProvider;
import mekanism.common.item.block.ItemBlockColoredName;
import mekanism.common.registration.impl.BlockRegistryObject;
import net.minecraft.core.Direction;
import net.minecraft.data.PackOutput;
Expand Down Expand Up @@ -49,7 +48,7 @@ protected void registerStatesAndModels() {

private void glowPanels() {
ModelFile model = models().getExistingFile(modLoc("block/glow_panel"));
for (BlockRegistryObject<BlockGlowPanel, ItemBlockColoredName> blockRO : AdditionsBlocks.GLOW_PANELS.values()) {
for (BlockRegistryObject<BlockGlowPanel, ?> blockRO : AdditionsBlocks.GLOW_PANELS.values()) {
BlockGlowPanel glowPanel = blockRO.getBlock();
directionalBlock(glowPanel, state -> model, 180, glowPanel.getFluidLoggedProperty());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess;
import mekanism.api.text.EnumColor;
import mekanism.common.block.interfaces.IColoredBlock;
import mekanism.common.item.block.ItemBlockColoredName;
import mekanism.common.recipe.BaseRecipeProvider;
import mekanism.common.recipe.ISubRecipeProvider;
import mekanism.common.recipe.builder.ExtendedShapedRecipeBuilder;
Expand Down Expand Up @@ -125,7 +124,7 @@ private void registerBalloon(RecipeOutput consumer, ItemRegistryObject<ItemBallo
}

private void registerGlowPanels(RecipeOutput consumer) {
for (BlockRegistryObject<BlockGlowPanel, ItemBlockColoredName> glowPanel : AdditionsBlocks.GLOW_PANELS.values()) {
for (BlockRegistryObject<BlockGlowPanel, ?> glowPanel : AdditionsBlocks.GLOW_PANELS.values()) {
registerGlowPanel(consumer, glowPanel, "glow_panel/");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import mekanism.api.recipes.ingredients.creator.IngredientCreatorAccess;
import mekanism.api.text.EnumColor;
import mekanism.common.block.interfaces.IColoredBlock;
import mekanism.common.item.block.ItemBlockColoredName;
import mekanism.common.recipe.BaseRecipeProvider;
import mekanism.common.recipe.ISubRecipeProvider;
import mekanism.common.recipe.builder.ExtendedShapedRecipeBuilder;
Expand Down Expand Up @@ -73,7 +72,7 @@ public void addRecipes(RecipeOutput consumer) {

private void registerPlasticBlocks(RecipeOutput consumer, String basePath) {
basePath += "block/";
for (BlockRegistryObject<BlockPlastic, ItemBlockColoredName> blockRO : AdditionsBlocks.PLASTIC_BLOCKS.values()) {
for (BlockRegistryObject<BlockPlastic, ?> blockRO : AdditionsBlocks.PLASTIC_BLOCKS.values()) {
registerPlasticBlock(consumer, blockRO, basePath);
}
}
Expand All @@ -94,7 +93,7 @@ private void registerPlasticBlock(RecipeOutput consumer, BlockRegistryObject<? e

private void registerPlasticTransparent(RecipeOutput consumer, String basePath) {
basePath += "transparent/";
for (BlockRegistryObject<BlockPlasticTransparent, ItemBlockColoredName> blockRO : AdditionsBlocks.TRANSPARENT_PLASTIC_BLOCKS.values()) {
for (BlockRegistryObject<BlockPlasticTransparent, ?> blockRO : AdditionsBlocks.TRANSPARENT_PLASTIC_BLOCKS.values()) {
registerPlasticTransparent(consumer, blockRO, basePath);
}
}
Expand All @@ -115,7 +114,7 @@ private void registerPlasticTransparent(RecipeOutput consumer, BlockRegistryObje

private void registerPlasticGlow(RecipeOutput consumer, String basePath) {
basePath += "glow/";
for (Map.Entry<EnumColor, BlockRegistryObject<BlockPlastic, ItemBlockColoredName>> entry : AdditionsBlocks.PLASTIC_GLOW_BLOCKS.entrySet()) {
for (Map.Entry<EnumColor, ? extends BlockRegistryObject<BlockPlastic, ?>> entry : AdditionsBlocks.PLASTIC_GLOW_BLOCKS.entrySet()) {
registerPlasticGlow(consumer, entry.getValue(), AdditionsBlocks.PLASTIC_BLOCKS.get(entry.getKey()), basePath);
}
}
Expand All @@ -132,7 +131,7 @@ private void registerPlasticGlow(RecipeOutput consumer, BlockRegistryObject<? ex

private void registerReinforcedPlastic(RecipeOutput consumer, String basePath) {
basePath += "reinforced/";
for (Map.Entry<EnumColor, BlockRegistryObject<BlockPlastic, ItemBlockColoredName>> entry : AdditionsBlocks.REINFORCED_PLASTIC_BLOCKS.entrySet()) {
for (Map.Entry<EnumColor, ? extends BlockRegistryObject<BlockPlastic, ?>> entry : AdditionsBlocks.REINFORCED_PLASTIC_BLOCKS.entrySet()) {
registerReinforcedPlastic(consumer, entry.getValue(), AdditionsBlocks.PLASTIC_BLOCKS.get(entry.getKey()), basePath);
}
}
Expand All @@ -150,7 +149,7 @@ private void registerReinforcedPlastic(RecipeOutput consumer, BlockRegistryObjec

private void registerPlasticRoads(RecipeOutput consumer, String basePath) {
basePath += "road/";
for (Map.Entry<EnumColor, BlockRegistryObject<BlockPlasticRoad, ItemBlockColoredName>> entry : AdditionsBlocks.PLASTIC_ROADS.entrySet()) {
for (Map.Entry<EnumColor, ? extends BlockRegistryObject<BlockPlasticRoad, ?>> entry : AdditionsBlocks.PLASTIC_ROADS.entrySet()) {
registerPlasticRoad(consumer, entry.getValue(), AdditionsBlocks.SLICK_PLASTIC_BLOCKS.get(entry.getKey()), basePath);
}
}
Expand All @@ -168,7 +167,7 @@ private void registerPlasticRoad(RecipeOutput consumer, BlockRegistryObject<? ex

private void registerSlickPlastic(RecipeOutput consumer, String basePath) {
basePath += "slick/";
for (Map.Entry<EnumColor, BlockRegistryObject<BlockPlastic, ItemBlockColoredName>> entry : AdditionsBlocks.SLICK_PLASTIC_BLOCKS.entrySet()) {
for (Map.Entry<EnumColor, ? extends BlockRegistryObject<BlockPlastic, ?>> entry : AdditionsBlocks.SLICK_PLASTIC_BLOCKS.entrySet()) {
registerSlickPlastic(consumer, entry.getValue(), AdditionsBlocks.PLASTIC_BLOCKS.get(entry.getKey()), basePath);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import mekanism.api.providers.IItemProvider;
import mekanism.api.text.EnumColor;
import mekanism.common.block.interfaces.IColoredBlock;
import mekanism.common.item.block.ItemBlockColoredName;
import mekanism.common.recipe.ISubRecipeProvider;
import mekanism.common.recipe.builder.ExtendedShapedRecipeBuilder;
import mekanism.common.recipe.pattern.Pattern;
Expand Down Expand Up @@ -38,7 +37,7 @@ public void addRecipes(RecipeOutput consumer) {

private void registerPlasticFences(RecipeOutput consumer, String basePath) {
basePath += "fence/";
for (Map.Entry<EnumColor, BlockRegistryObject<BlockPlasticFence, ItemBlockColoredName>> entry : AdditionsBlocks.PLASTIC_FENCES.entrySet()) {
for (Map.Entry<EnumColor, ? extends BlockRegistryObject<BlockPlasticFence, ?>> entry : AdditionsBlocks.PLASTIC_FENCES.entrySet()) {
registerPlasticFence(consumer, entry.getValue(), AdditionsBlocks.PLASTIC_BLOCKS.get(entry.getKey()), basePath);
}
}
Expand All @@ -56,7 +55,7 @@ private void registerPlasticFence(RecipeOutput consumer, BlockRegistryObject<? e

private void registerPlasticFenceGates(RecipeOutput consumer, String basePath) {
basePath += "fence_gate/";
for (Map.Entry<EnumColor, BlockRegistryObject<BlockPlasticFenceGate, ItemBlockColoredName>> entry : AdditionsBlocks.PLASTIC_FENCE_GATES.entrySet()) {
for (Map.Entry<EnumColor, ? extends BlockRegistryObject<BlockPlasticFenceGate, ?>> entry : AdditionsBlocks.PLASTIC_FENCE_GATES.entrySet()) {
registerPlasticFenceGate(consumer, entry.getValue(), AdditionsBlocks.PLASTIC_BLOCKS.get(entry.getKey()), basePath);
}
}
Expand Down
41 changes: 0 additions & 41 deletions src/main/java/mekanism/common/item/block/ItemBlockColoredName.java

This file was deleted.

Loading

0 comments on commit 37b85b0

Please sign in to comment.