Refactor the way pool tile variants are registered

This commit is contained in:
zontreck 2024-11-21 22:25:56 -07:00
parent ffcecb8e8e
commit 017a608f5d

View file

@ -19,6 +19,9 @@ import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import java.util.ArrayList;
import java.util.List;
public class ModBlocks {
private static BlockBehaviour.StatePredicate shulkerState = (p_152653_, p_152654_, p_152655_) -> {
@ -110,6 +113,49 @@ public class ModBlocks {
}
public static List<RegistryObject<Block>> registerPoolTile(String color) {
String baseNick = color.length()>1 ? color+"_pool_tile" : "pool_tile";
List<RegistryObject<Block>> ret = new ArrayList<>();
final RegistryObject<Block> tile1 = registerWithItem(BLOCKS.register(baseNick, ()->new Block(stone)), new Item.Properties());
final RegistryObject<Block> POOL_TILE_STAIRS = registerWithItem(BLOCKS.register(baseNick + "_stairs", ()->new StairBlock(tile1.get()::defaultBlockState, stone)), new Item.Properties());
final RegistryObject<Block> POOL_TILE_SLAB = registerWithItem(BLOCKS.register(baseNick+"_slab", ()->new SlabBlock(stone)), new Item.Properties());
final RegistryObject<Block> POOL_TILE_WALL = registerWithItem(BLOCKS.register(baseNick + "_wall", ()->new WallBlock(stone)), new Item.Properties());
final RegistryObject<Block> POOL_LIGHT = registerWithItem(BLOCKS.register(baseNick + "_light", ()->new Block(poolLightClean)), new Item.Properties());
final RegistryObject<Block> DIRTY_POOL_TILE = registerWithItem(BLOCKS.register("dirty_" + baseNick, ()->new Block(stone)), new Item.Properties());
final RegistryObject<Block> DIRTY_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dirty_" + baseNick + "_stairs", ()->new StairBlock(DIRTY_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
final RegistryObject<Block> DIRTY_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dirty_" + baseNick + "_slab", ()-> new SlabBlock(stone)), new Item.Properties());
final RegistryObject<Block> DIRTY_POOL_TILE_WALL = registerWithItem(BLOCKS.register("dirty_" + baseNick + "_wall", ()->new WallBlock(stone)), new Item.Properties());
final RegistryObject<Block> DIRTY_POOL_LIGHT = registerWithItem(BLOCKS.register("dirty_" + baseNick + "_light", ()->new Block(poolLightDirty)), new Item.Properties());
final RegistryObject<Block> FILTHY_POOL_LIGHT = registerWithItem(BLOCKS.register("filthy_" + baseNick + "_light", ()->new Block(poolLightFilthy)), new Item.Properties());
ret.add(tile1);
ret.add(POOL_TILE_STAIRS);
ret.add(POOL_TILE_SLAB);
ret.add(POOL_TILE_WALL);
ret.add(POOL_LIGHT);
ret.add(DIRTY_POOL_TILE);
ret.add(DIRTY_POOL_TILE_STAIRS);
ret.add(DIRTY_POOL_TILE_SLAB);
ret.add(DIRTY_POOL_TILE_WALL);
ret.add(DIRTY_POOL_LIGHT);
ret.add(FILTHY_POOL_LIGHT);
return ret;
}
public static final RegistryObject<Block> DARK_RED_WOOL = registerWithItem(BLOCKS.register("dark_red_wool", ()->new Block(BlockBehaviour.Properties.copy(Blocks.RED_WOOL))), new Item.Properties());
@ -162,147 +208,26 @@ public class ModBlocks {
public static final List<RegistryObject<Block>> NORMAL_POOL_TILE = registerPoolTile("");
public static final RegistryObject<Block> POOL_TILE = registerWithItem(BLOCKS.register("pool_tile", ()->new Block(stone)), new Item.Properties());
public static final RegistryObject<Block> POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("pool_tile_stairs", ()->new StairBlock(POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
public static final List<RegistryObject<Block>> DARK_POOL_TILES = registerPoolTile("dark");
public static final RegistryObject<Block> POOL_TILE_SLAB = registerWithItem(BLOCKS.register("pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
public static final List<RegistryObject<Block>> BLUE_POOL_TILES = registerPoolTile("blue");
public static final RegistryObject<Block> POOL_TILE_WALL = registerWithItem(BLOCKS.register("pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
public static final List<RegistryObject<Block>> RED_POOL_TILES = registerPoolTile("red");
public static final RegistryObject<Block> POOL_LIGHT = registerWithItem(BLOCKS.register("pool_light", ()->new Block(poolLightClean)), new Item.Properties());
public static final List<RegistryObject<Block>> GREEN_POOL_TILES = registerPoolTile("green");
public static final List<RegistryObject<Block>> YELLOW_POOL_TILES = registerPoolTile("yellow");
public static final List<RegistryObject<Block>> CYAN_POOL_TILES = registerPoolTile("cyan");
public static final RegistryObject<Block> DIRTY_POOL_TILE = registerWithItem(BLOCKS.register("dirty_pool_tile", ()->new Block(stone)), new Item.Properties());
public static final List<RegistryObject<Block>> PURPLE_POOL_TILES = registerPoolTile("purple");
public static final RegistryObject<Block> DIRTY_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dirty_pool_tile_stairs", ()->new StairBlock(DIRTY_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dirty_pool_tile_slab", ()-> new SlabBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_POOL_TILE_WALL = registerWithItem(BLOCKS.register("dirty_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_POOL_LIGHT = registerWithItem(BLOCKS.register("dirty_pool_light", ()->new Block(poolLightDirty)), new Item.Properties());
public static final RegistryObject<Block> FILTHY_POOL_LIGHT = registerWithItem(BLOCKS.register("filthy_pool_light", ()->new Block(poolLightFilthy)), new Item.Properties());
public static final RegistryObject<Block> DARK_POOL_TILE = registerWithItem(BLOCKS.register("dark_pool_tile", ()->new Block(stone)), new Item.Properties());
public static final RegistryObject<Block> DARK_POOL_LIGHT = registerWithItem(BLOCKS.register("dark_pool_light", ()->new Block(poolLightClean)), new Item.Properties());
public static final RegistryObject<Block> DARK_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dark_pool_tile_stairs", ()->new StairBlock(DARK_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
public static final RegistryObject<Block> DARK_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dark_pool_tile_slab",()-> new SlabBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> BLUE_POOL_TILE = registerWithItem(BLOCKS.register("blue_pool_tile",()-> new Block(stone)), new Item.Properties());
public static final RegistryObject<Block> BLUE_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("blue_pool_tile_stairs", ()->new StairBlock(BLUE_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
public static final RegistryObject<Block> BLUE_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("blue_pool_tile_slab",()-> new SlabBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> BLUE_POOL_TILE_WALL = registerWithItem(BLOCKS.register("blue_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> BLUE_POOL_LIGHT = registerWithItem(BLOCKS.register("blue_pool_light", ()->new Block(poolLightClean)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_BLUE_POOL_TILE = registerWithItem(BLOCKS.register("dirty_blue_pool_tile", ()->new Block(stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_BLUE_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dirty_blue_pool_tile_stairs", ()->new StairBlock(DIRTY_BLUE_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_BLUE_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dirty_blue_pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_BLUE_POOL_TILE_WALL = registerWithItem(BLOCKS.register("dirty_blue_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_BLUE_POOL_LIGHT = registerWithItem(BLOCKS.register("dirty_blue_pool_light", ()->new Block(poolLightDirty)), new Item.Properties());
public static final RegistryObject<Block> FILTHY_BLUE_POOL_LIGHT = registerWithItem(BLOCKS.register("filthy_blue_pool_light", ()->new Block(poolLightFilthy)), new Item.Properties());
public static final RegistryObject<Block> RED_POOL_TILE = registerWithItem(BLOCKS.register("red_pool_tile", ()->new Block(stone)), new Item.Properties());
public static final RegistryObject<Block> RED_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("red_pool_tile_stairs", ()->new StairBlock(RED_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
public static final RegistryObject<Block> RED_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("red_pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> RED_POOL_TILE_WALL = registerWithItem(BLOCKS.register("red_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> RED_POOL_LIGHT = registerWithItem(BLOCKS.register("red_pool_light", ()->new Block(poolLightClean)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_RED_POOL_TILE = registerWithItem(BLOCKS.register("dirty_red_pool_tile", ()->new Block(stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_RED_POOL_LIGHT = registerWithItem(BLOCKS.register("dirty_red_pool_light", ()->new Block(poolLightDirty)), new Item.Properties());
public static final RegistryObject<Block> FILTHY_RED_POOL_LIGHT = registerWithItem(BLOCKS.register("filthy_red_pool_light", ()->new Block(poolLightFilthy)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_RED_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dirty_red_pool_tile_stairs", ()->new StairBlock(DIRTY_RED_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_RED_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dirty_red_pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_RED_POOL_TILE_WALL = registerWithItem(BLOCKS.register("dirty_red_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> GREEN_POOL_TILE = registerWithItem(BLOCKS.register("green_pool_tile", ()->new Block(stone)), new Item.Properties());
public static final RegistryObject<Block> GREEN_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("green_pool_tile_stairs", ()->new StairBlock(GREEN_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
public static final RegistryObject<Block> GREEN_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("green_pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> GREEN_POOL_TILE_WALL = registerWithItem(BLOCKS.register("green_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> GREEN_POOL_LIGHT = registerWithItem(BLOCKS.register("green_pool_light", ()->new Block(poolLightClean)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_GREEN_POOL_TILE = registerWithItem(BLOCKS.register("dirty_green_pool_tile", ()->new Block(stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_GREEN_POOL_LIGHT = registerWithItem(BLOCKS.register("dirty_green_pool_light", ()->new Block(poolLightDirty)), new Item.Properties());
public static final RegistryObject<Block> FILTHY_GREEN_POOL_LIGHT = registerWithItem(BLOCKS.register("filthy_green_pool_light", ()->new Block(poolLightFilthy)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_GREEN_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dirty_green_pool_tile_stairs", ()->new StairBlock(DIRTY_GREEN_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_GREEN_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dirty_green_pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> DIRTY_GREEN_POOL_TILE_WALL = registerWithItem(BLOCKS.register("dirty_green_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
public static final RegistryObject<Block> MINI_SUN = registerWithItem(BLOCKS.register("mini_sun", ()->new MiniSunBlock(explosionResistance.lightLevel((x)->128))), new Item.Properties());