diff --git a/src/generated/resources/assets/create/blockstates/framed_glass.json b/src/generated/resources/assets/create/blockstates/framed_glass.json new file mode 100644 index 000000000..30accaee6 --- /dev/null +++ b/src/generated/resources/assets/create/blockstates/framed_glass.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "create:block/framed_glass" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/blockstates/horizontal_framed_glass.json b/src/generated/resources/assets/create/blockstates/horizontal_framed_glass.json new file mode 100644 index 000000000..b1041887a --- /dev/null +++ b/src/generated/resources/assets/create/blockstates/horizontal_framed_glass.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "create:block/horizontal_framed_glass" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/blockstates/vertical_framed_glass.json b/src/generated/resources/assets/create/blockstates/vertical_framed_glass.json new file mode 100644 index 000000000..d6fe30474 --- /dev/null +++ b/src/generated/resources/assets/create/blockstates/vertical_framed_glass.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "create:block/vertical_framed_glass" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/lang/en_ud.json b/src/generated/resources/assets/create/lang/en_ud.json index f33c70bac..aed9e61bb 100644 --- a/src/generated/resources/assets/create/lang/en_ud.json +++ b/src/generated/resources/assets/create/lang/en_ud.json @@ -28,6 +28,7 @@ "block.create.fancy_limestone_bricks": "s\u029E\u0254\u0131\u0279\u15FA \u01DDuo\u0287s\u01DD\u026F\u0131\uA780 \u028E\u0254u\u0250\u2132", "block.create.fancy_scoria_bricks": "s\u029E\u0254\u0131\u0279\u15FA \u0250\u0131\u0279o\u0254S \u028E\u0254u\u0250\u2132", "block.create.fancy_weathered_limestone_bricks": "s\u029E\u0254\u0131\u0279\u15FA \u01DDuo\u0287s\u01DD\u026F\u0131\uA780 p\u01DD\u0279\u01DD\u0265\u0287\u0250\u01DDM \u028E\u0254u\u0250\u2132", + "block.create.framed_glass": "ss\u0250\u05DF\u2141 p\u01DD\u026F\u0250\u0279\u2132", "block.create.gabbro": "o\u0279qq\u0250\u2141", "block.create.gabbro_bricks": "s\u029E\u0254\u0131\u0279\u15FA o\u0279qq\u0250\u2141", "block.create.gabbro_cobblestone": "\u01DDuo\u0287s\u01DD\u05DFqqo\u0186 o\u0279qq\u0250\u2141", @@ -35,6 +36,7 @@ "block.create.granite_bricks": "s\u029E\u0254\u0131\u0279\u15FA \u01DD\u0287\u0131u\u0250\u0279\u2141", "block.create.granite_cobblestone": "\u01DDuo\u0287s\u01DD\u05DFqqo\u0186 \u01DD\u0287\u0131u\u0250\u0279\u2141", "block.create.granite_pillar": "\u0279\u0250\u05DF\u05DF\u0131\u0500 \u01DD\u0287\u0131u\u0250\u0279\u2141", + "block.create.horizontal_framed_glass": "ss\u0250\u05DF\u2141 p\u01DD\u026F\u0250\u0279\u2132 \u05DF\u0250\u0287uoz\u0131\u0279oH", "block.create.layered_andesite": "\u01DD\u0287\u0131s\u01DDpu\u2C6F p\u01DD\u0279\u01DD\u028E\u0250\uA780", "block.create.layered_dark_scoria": "\u0250\u0131\u0279o\u0254S \u029E\u0279\u0250\u15E1 p\u01DD\u0279\u01DD\u028E\u0250\uA780", "block.create.layered_diorite": "\u01DD\u0287\u0131\u0279o\u0131\u15E1 p\u01DD\u0279\u01DD\u028E\u0250\uA780", @@ -87,6 +89,7 @@ "block.create.scoria_bricks": "s\u029E\u0254\u0131\u0279\u15FA \u0250\u0131\u0279o\u0254S", "block.create.scoria_cobblestone": "\u01DDuo\u0287s\u01DD\u05DFqqo\u0186 \u0250\u0131\u0279o\u0254S", "block.create.scoria_pillar": "\u0279\u0250\u05DF\u05DF\u0131\u0500 \u0250\u0131\u0279o\u0254S", + "block.create.vertical_framed_glass": "ss\u0250\u05DF\u2141 p\u01DD\u026F\u0250\u0279\u2132 \u05DF\u0250\u0254\u0131\u0287\u0279\u01DD\u039B", "block.create.weathered_limestone": "\u01DDuo\u0287s\u01DD\u026F\u0131\uA780 p\u01DD\u0279\u01DD\u0265\u0287\u0250\u01DDM", "block.create.weathered_limestone_bricks": "s\u029E\u0254\u0131\u0279\u15FA \u01DDuo\u0287s\u01DD\u026F\u0131\uA780 p\u01DD\u0279\u01DD\u0265\u0287\u0250\u01DDM", "block.create.weathered_limestone_cobblestone": "\u01DDuo\u0287s\u01DD\u05DFqqo\u0186 \u01DDuo\u0287s\u01DD\u026F\u0131\uA780 p\u01DD\u0279\u01DD\u0265\u0287\u0250\u01DDM", diff --git a/src/generated/resources/assets/create/lang/en_us.json b/src/generated/resources/assets/create/lang/en_us.json index 7db19c201..91a912cb9 100644 --- a/src/generated/resources/assets/create/lang/en_us.json +++ b/src/generated/resources/assets/create/lang/en_us.json @@ -28,6 +28,7 @@ "block.create.fancy_limestone_bricks": "Fancy Limestone Bricks", "block.create.fancy_scoria_bricks": "Fancy Scoria Bricks", "block.create.fancy_weathered_limestone_bricks": "Fancy Weathered Limestone Bricks", + "block.create.framed_glass": "Framed Glass", "block.create.gabbro": "Gabbro", "block.create.gabbro_bricks": "Gabbro Bricks", "block.create.gabbro_cobblestone": "Gabbro Cobblestone", @@ -35,6 +36,7 @@ "block.create.granite_bricks": "Granite Bricks", "block.create.granite_cobblestone": "Granite Cobblestone", "block.create.granite_pillar": "Granite Pillar", + "block.create.horizontal_framed_glass": "Horizontal Framed Glass", "block.create.layered_andesite": "Layered Andesite", "block.create.layered_dark_scoria": "Layered Dark Scoria", "block.create.layered_diorite": "Layered Diorite", @@ -87,6 +89,7 @@ "block.create.scoria_bricks": "Scoria Bricks", "block.create.scoria_cobblestone": "Scoria Cobblestone", "block.create.scoria_pillar": "Scoria Pillar", + "block.create.vertical_framed_glass": "Vertical Framed Glass", "block.create.weathered_limestone": "Weathered Limestone", "block.create.weathered_limestone_bricks": "Weathered Limestone Bricks", "block.create.weathered_limestone_cobblestone": "Weathered Limestone Cobblestone", diff --git a/src/generated/resources/assets/create/models/block/framed_glass.json b/src/generated/resources/assets/create/models/block/framed_glass.json new file mode 100644 index 000000000..ad76ac5c7 --- /dev/null +++ b/src/generated/resources/assets/create/models/block/framed_glass.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "create:block/palettes/framed_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/models/block/horizontal_framed_glass.json b/src/generated/resources/assets/create/models/block/horizontal_framed_glass.json new file mode 100644 index 000000000..ad76ac5c7 --- /dev/null +++ b/src/generated/resources/assets/create/models/block/horizontal_framed_glass.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "create:block/palettes/framed_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/models/block/vertical_framed_glass.json b/src/generated/resources/assets/create/models/block/vertical_framed_glass.json new file mode 100644 index 000000000..ad76ac5c7 --- /dev/null +++ b/src/generated/resources/assets/create/models/block/vertical_framed_glass.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "create:block/palettes/framed_glass" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/models/item/framed_glass.json b/src/generated/resources/assets/create/models/item/framed_glass.json new file mode 100644 index 000000000..23fff4e54 --- /dev/null +++ b/src/generated/resources/assets/create/models/item/framed_glass.json @@ -0,0 +1,3 @@ +{ + "parent": "create:block/framed_glass" +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/models/item/horizontal_framed_glass.json b/src/generated/resources/assets/create/models/item/horizontal_framed_glass.json new file mode 100644 index 000000000..82dea0725 --- /dev/null +++ b/src/generated/resources/assets/create/models/item/horizontal_framed_glass.json @@ -0,0 +1,3 @@ +{ + "parent": "create:block/horizontal_framed_glass" +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/models/item/vertical_framed_glass.json b/src/generated/resources/assets/create/models/item/vertical_framed_glass.json new file mode 100644 index 000000000..f9e4d4bb4 --- /dev/null +++ b/src/generated/resources/assets/create/models/item/vertical_framed_glass.json @@ -0,0 +1,3 @@ +{ + "parent": "create:block/vertical_framed_glass" +} \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 2aeb6da3d..3fecb5da2 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -73,12 +73,6 @@ import com.simibubi.create.modules.logistics.block.inventories.CreativeCrateBloc import com.simibubi.create.modules.logistics.block.inventories.FlexcrateBlock; import com.simibubi.create.modules.logistics.block.transposer.LinkedTransposerBlock; import com.simibubi.create.modules.logistics.block.transposer.TransposerBlock; -import com.simibubi.create.modules.palettes.CTGlassBlock; -import com.simibubi.create.modules.palettes.CTGlassPaneBlock; -import com.simibubi.create.modules.palettes.CTWindowBlock; -import com.simibubi.create.modules.palettes.GlassPaneBlock; -import com.simibubi.create.modules.palettes.HorizontalCTGlassBlock; -import com.simibubi.create.modules.palettes.VerticalCTGlassBlock; import com.tterrag.registrate.builders.BlockBuilder; import com.tterrag.registrate.builders.ItemBuilder; import com.tterrag.registrate.providers.ProviderType; @@ -96,7 +90,6 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.FenceBlock; import net.minecraft.block.FenceGateBlock; -import net.minecraft.block.GlassBlock; import net.minecraft.block.SlabBlock; import net.minecraft.block.WallBlock; import net.minecraft.client.Minecraft; @@ -165,9 +158,9 @@ public enum AllBlocks implements NonNullSupplier { PLOUGH(PloughBlock::new), ANALOG_LEVER(AnalogLeverBlock::new), - ANDESITE_CASING(() -> new CasingBlock("andesite_casing")), - COPPER_CASING(() -> new CasingBlock("copper_casing")), - BRASS_CASING(() -> new CasingBlock("crafter_top")), + ANDESITE_CASING(() -> new CasingBlock(Properties.from(Blocks.ANDESITE))), + COPPER_CASING(() -> new CasingBlock(Properties.from(Blocks.ANDESITE))), + BRASS_CASING(() -> new CasingBlock(Properties.from(Blocks.ANDESITE))), MECHANICAL_CRAFTER(MechanicalCrafterBlock::new), SEQUENCED_GEARSHIFT(SequencedGearshiftBlock::new), @@ -233,34 +226,34 @@ public enum AllBlocks implements NonNullSupplier { _6_(Sections.PALETTES), - TILED_GLASS(() -> new GlassBlock(Properties.from(Blocks.GLASS)), ITaggable.create() - .withVanillaTags(ITaggable.BLOCK, "impermeable") - .withForgeTags("glass")), - FRAMED_GLASS(() -> new CTGlassBlock(AllCTs.FRAMED_GLASS, false)), - HORIZONTAL_FRAMED_GLASS( - () -> new HorizontalCTGlassBlock(AllCTs.HORIZONTAL_FRAMED_GLASS, AllCTs.FRAMED_GLASS, false)), - VERTICAL_FRAMED_GLASS(() -> new VerticalCTGlassBlock(AllCTs.VERTICAL_FRAMED_GLASS, false)), - - OAK_GLASS(() -> new CTWindowBlock(AllCTs.OAK_GLASS, false)), - SPRUCE_GLASS(() -> new CTWindowBlock(AllCTs.SPRUCE_GLASS, false)), - BIRCH_GLASS(() -> new CTWindowBlock(AllCTs.BIRCH_GLASS, true)), - JUNGLE_GLASS(() -> new CTWindowBlock(AllCTs.JUNGLE_GLASS, false)), - DARK_OAK_GLASS(() -> new CTWindowBlock(AllCTs.DARK_OAK_GLASS, false)), - ACACIA_GLASS(() -> new CTWindowBlock(AllCTs.ACACIA_GLASS, false)), - IRON_GLASS(() -> new CTWindowBlock(AllCTs.IRON_GLASS, false)), - - TILED_GLASS_PANE(() -> new GlassPaneBlock(Properties.from(Blocks.GLASS)), ITaggable.create() - .withForgeTags("glass_panes")), - FRAMED_GLASS_PANE(() -> new CTGlassPaneBlock(FRAMED_GLASS.get())), - HORIZONTAL_FRAMED_GLASS_PANE(() -> new CTGlassPaneBlock(HORIZONTAL_FRAMED_GLASS.get())), - VERTICAL_FRAMED_GLASS_PANE(() -> new CTGlassPaneBlock(VERTICAL_FRAMED_GLASS.get())), - OAK_GLASS_PANE(() -> new CTGlassPaneBlock(OAK_GLASS.get())), - SPRUCE_GLASS_PANE(() -> new CTGlassPaneBlock(SPRUCE_GLASS.get())), - BIRCH_GLASS_PANE(() -> new CTGlassPaneBlock(BIRCH_GLASS.get())), - JUNGLE_GLASS_PANE(() -> new CTGlassPaneBlock(JUNGLE_GLASS.get())), - DARK_OAK_GLASS_PANE(() -> new CTGlassPaneBlock(DARK_OAK_GLASS.get())), - ACACIA_GLASS_PANE(() -> new CTGlassPaneBlock(ACACIA_GLASS.get())), - IRON_GLASS_PANE(() -> new CTGlassPaneBlock(IRON_GLASS.get())), +// TILED_GLASS(() -> new GlassBlock(Properties.from(Blocks.GLASS)), ITaggable.create() +// .withVanillaTags(ITaggable.BLOCK, "impermeable") +// .withForgeTags("glass")), +// FRAMED_GLASS(() -> new CTGlassBlock(AllCTs.FRAMED_GLASS, false)), +// HORIZONTAL_FRAMED_GLASS( +// () -> new HorizontalCTGlassBlock(AllCTs.HORIZONTAL_FRAMED_GLASS, AllCTs.FRAMED_GLASS, false)), +// VERTICAL_FRAMED_GLASS(() -> new VerticalCTGlassBlock(AllCTs.VERTICAL_FRAMED_GLASS, false)), +// +// OAK_GLASS(() -> new CTWindowBlock(AllCTs.OAK_GLASS, false)), +// SPRUCE_GLASS(() -> new CTWindowBlock(AllCTs.SPRUCE_GLASS, false)), +// BIRCH_GLASS(() -> new CTWindowBlock(AllCTs.BIRCH_GLASS, true)), +// JUNGLE_GLASS(() -> new CTWindowBlock(AllCTs.JUNGLE_GLASS, false)), +// DARK_OAK_GLASS(() -> new CTWindowBlock(AllCTs.DARK_OAK_GLASS, false)), +// ACACIA_GLASS(() -> new CTWindowBlock(AllCTs.ACACIA_GLASS, false)), +// IRON_GLASS(() -> new CTWindowBlock(AllCTs.IRON_GLASS, false)), +// +// TILED_GLASS_PANE(() -> new GlassPaneBlock(Properties.from(Blocks.GLASS)), ITaggable.create() +// .withForgeTags("glass_panes")), +// FRAMED_GLASS_PANE(() -> new CTGlassPaneBlock(FRAMED_GLASS.get())), +// HORIZONTAL_FRAMED_GLASS_PANE(() -> new CTGlassPaneBlock(HORIZONTAL_FRAMED_GLASS.get())), +// VERTICAL_FRAMED_GLASS_PANE(() -> new CTGlassPaneBlock(VERTICAL_FRAMED_GLASS.get())), +// OAK_GLASS_PANE(() -> new CTGlassPaneBlock(OAK_GLASS.get())), +// SPRUCE_GLASS_PANE(() -> new CTGlassPaneBlock(SPRUCE_GLASS.get())), +// BIRCH_GLASS_PANE(() -> new CTGlassPaneBlock(BIRCH_GLASS.get())), +// JUNGLE_GLASS_PANE(() -> new CTGlassPaneBlock(JUNGLE_GLASS.get())), +// DARK_OAK_GLASS_PANE(() -> new CTGlassPaneBlock(DARK_OAK_GLASS.get())), +// ACACIA_GLASS_PANE(() -> new CTGlassPaneBlock(ACACIA_GLASS.get())), +// IRON_GLASS_PANE(() -> new CTGlassPaneBlock(IRON_GLASS.get())), // GRANITE_BRICKS(() -> new Block(Properties.from(Blocks.GRANITE))), // GRANITE_LAYERS( diff --git a/src/main/java/com/simibubi/create/AllBlocksNew.java b/src/main/java/com/simibubi/create/AllBlocksNew.java index 12e05297a..8126fc47a 100644 --- a/src/main/java/com/simibubi/create/AllBlocksNew.java +++ b/src/main/java/com/simibubi/create/AllBlocksNew.java @@ -2,6 +2,7 @@ package com.simibubi.create; import static com.simibubi.create.modules.Sections.SCHEMATICS; +import com.simibubi.create.foundation.registrate.CreateRegistrate; import com.simibubi.create.foundation.utility.data.AssetLookup; import com.simibubi.create.foundation.utility.data.BlockStateGen; import com.simibubi.create.modules.Sections; @@ -28,33 +29,42 @@ public class AllBlocksNew { } public static final BlockEntry SCHEMATICANNON = - REGISTRATE.block("schematicannon", SchematicannonBlock::new) - .initialProperties(() -> Blocks.DISPENSER) - .blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), AssetLookup.partialBaseModel(ctx, prov))) - .item() - .model(AssetLookup::customItemModel) - .build() - .register(); + REGISTRATE.createBlock("schematicannon", SchematicannonBlock::new) + .initialProperties(() -> Blocks.DISPENSER) + .blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), AssetLookup.partialBaseModel(ctx, prov))) + .item() + .model(AssetLookup::customItemModel) + .build() + .register(); public static final BlockEntry SCHEMATIC_TABLE = - REGISTRATE.block("schematic_table", SchematicTableBlock::new) - .initialProperties(() -> Blocks.LECTERN) - .blockstate((ctx, prov) -> prov.horizontalBlock(ctx.getEntry(), prov.models() - .getExistingFile(ctx.getId()), 0)) - .simpleItem() - .register(); + REGISTRATE.createBlock("schematic_table", SchematicTableBlock::new) + .initialProperties(() -> Blocks.LECTERN) + .blockstate((ctx, prov) -> prov.horizontalBlock(ctx.getEntry(), prov.models() + .getExistingFile(ctx.getId()), 0)) + .simpleItem() + .register(); static { REGISTRATE.startSection(Sections.KINETICS); } - public static final BlockEntry SHAFT = REGISTRATE.block("shaft", ShaftBlock::new) - .initialProperties(SharedProperties::kinetic) - .blockstate(BlockStateGen.axisBlockProvider(false)) - .simpleItem() - .register(); + public static final BlockEntry SHAFT = REGISTRATE.createBlock("shaft", ShaftBlock::new) + .initialProperties(SharedProperties::kinetic) + .blockstate(BlockStateGen.axisBlockProvider(false)) + .simpleItem() + .register(); - public static final BlockEntry COGWHEEL = REGISTRATE.block("cogwheel", CogWheelBlock::small) + public static final BlockEntry COGWHEEL = REGISTRATE.createBlock("cogwheel", CogWheelBlock::small) + .initialProperties(SharedProperties::kinetic) + .properties(p -> p.sound(SoundType.WOOD)) + .blockstate(BlockStateGen.axisBlockProvider(false)) + .item(CogwheelBlockItem::new) + .build() + .register(); + + public static final BlockEntry LARGE_COGWHEEL = + REGISTRATE.createBlock("large_cogwheel", CogWheelBlock::large) .initialProperties(SharedProperties::kinetic) .properties(p -> p.sound(SoundType.WOOD)) .blockstate(BlockStateGen.axisBlockProvider(false)) @@ -62,25 +72,8 @@ public class AllBlocksNew { .build() .register(); - public static final BlockEntry LARGE_COGWHEEL = - REGISTRATE.block("large_cogwheel", CogWheelBlock::large) - .initialProperties(SharedProperties::kinetic) - .properties(p -> p.sound(SoundType.WOOD)) - .blockstate(BlockStateGen.axisBlockProvider(false)) - .item(CogwheelBlockItem::new) - .build() - .register(); - public static final BlockEntry ENCASED_SHAFT = - REGISTRATE.block("encased_shaft", EncasedShaftBlock::new) - .initialProperties(SharedProperties::kinetic) - .blockstate(BlockStateGen.axisBlockProvider(true)) - .item() - .model(AssetLookup::customItemModel) - .build() - .register(); - - public static final BlockEntry GEARBOX = REGISTRATE.block("gearbox", GearboxBlock::new) + REGISTRATE.createBlock("encased_shaft", EncasedShaftBlock::new) .initialProperties(SharedProperties::kinetic) .blockstate(BlockStateGen.axisBlockProvider(true)) .item() @@ -88,22 +81,30 @@ public class AllBlocksNew { .build() .register(); - public static final BlockEntry CLUTCH = REGISTRATE.block("clutch", ClutchBlock::new) - .initialProperties(SharedProperties::kinetic) - .blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p))) - .item() - .model(AssetLookup::customItemModel) - .build() - .register(); + public static final BlockEntry GEARBOX = REGISTRATE.createBlock("gearbox", GearboxBlock::new) + .initialProperties(SharedProperties::kinetic) + .blockstate(BlockStateGen.axisBlockProvider(true)) + .item() + .model(AssetLookup::customItemModel) + .build() + .register(); - public static final BlockEntry GEARSHIFT = REGISTRATE.block("gearshift", GearshiftBlock::new) - .initialProperties(SharedProperties::kinetic) - .blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p))) - .item() - .model(AssetLookup::customItemModel) - .build() - .register(); + public static final BlockEntry CLUTCH = REGISTRATE.createBlock("clutch", ClutchBlock::new) + .initialProperties(SharedProperties::kinetic) + .blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p))) + .item() + .model(AssetLookup::customItemModel) + .build() + .register(); + + public static final BlockEntry GEARSHIFT = REGISTRATE.createBlock("gearshift", GearshiftBlock::new) + .initialProperties(SharedProperties::kinetic) + .blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p))) + .item() + .model(AssetLookup::customItemModel) + .build() + .register(); public static void register() {} - + } diff --git a/src/main/java/com/simibubi/create/AllCTs.java b/src/main/java/com/simibubi/create/AllCTs.java index e3aae506f..d5aa4cd56 100644 --- a/src/main/java/com/simibubi/create/AllCTs.java +++ b/src/main/java/com/simibubi/create/AllCTs.java @@ -12,10 +12,10 @@ import net.minecraft.util.ResourceLocation; public enum AllCTs { - FRAMED_GLASS(omni("framed_glass")), - HORIZONTAL_FRAMED_GLASS(custom(HORIZONTAL, "framed_glass", "horizontal_framed_glass")), - VERTICAL_FRAMED_GLASS(custom(VERTICAL, "framed_glass", "vertical_framed_glass")), - + FRAMED_GLASS(custom(OMNIDIRECTIONAL, "palettes/framed_glass", "framed_glass")), + HORIZONTAL_FRAMED_GLASS(custom(HORIZONTAL, "palettes/framed_glass", "horizontal_framed_glass")), + VERTICAL_FRAMED_GLASS(custom(VERTICAL, "palettes/framed_glass", "vertical_framed_glass")), + OAK_GLASS(vertical("oak_window")), SPRUCE_GLASS(vertical("spruce_window")), BIRCH_GLASS(vertical("birch_window")), @@ -24,7 +24,7 @@ public enum AllCTs { ACACIA_GLASS(vertical("acacia_window")), ACACIA_GLASS_DENSE(vertical("acacia_window_dense")), IRON_GLASS(vertical("iron_window")), - + GRANITE_LAYERS(layers("granite")), DIORITE_LAYERS(layers("diorite")), ANDESITE_LAYERS(layers("andesite")), @@ -33,7 +33,7 @@ public enum AllCTs { LIMESTONE_LAYERS(layers("limestone")), WEATHERED_LIMESTONE_LAYERS(layers("weathered_limestone")), SCORIA_LAYERS(layers("scoria")), - + POLISHED_GRANITE(polishedVanilla("granite")), POLISHED_DIORITE(polishedVanilla("diorite")), POLISHED_ANDESITE(polishedVanilla("andesite")), @@ -42,7 +42,7 @@ public enum AllCTs { POLISHED_LIMESTONE(polished("limestone")), POLISHED_WEATHERED_LIMESTONE(polished("weathered_limestone")), POLISHED_SCORIA(polished("scoria")), - + ; private CTSpriteShiftEntry entry; @@ -58,11 +58,11 @@ public enum AllCTs { static CTSpriteShiftEntry omni(String name) { return CTSpriteShifter.get(OMNIDIRECTIONAL, name); } - + static CTSpriteShiftEntry custom(CTType type, String from, String to) { return CTSpriteShifter.get(type, from, to); } - + static CTSpriteShiftEntry vertical(String blockname) { return CTSpriteShifter.get(VERTICAL, blockname); } @@ -77,7 +77,7 @@ public enum AllCTs { static CTSpriteShiftEntry polishedVanilla(String blockname) { return CTSpriteShifter.get(OMNIDIRECTIONAL, new ResourceLocation("block/polished_" + blockname), - "polished_" + blockname); + "polished_" + blockname); } } diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index 0730aae9a..74e2e4c50 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -7,6 +7,7 @@ import com.simibubi.create.config.AllConfigs; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.command.CreateCommand; import com.simibubi.create.foundation.command.ServerLagger; +import com.simibubi.create.foundation.registrate.CreateRegistrate; import com.simibubi.create.foundation.world.AllWorldFeatures; import com.simibubi.create.modules.contraptions.TorquePropagator; import com.simibubi.create.modules.logistics.RedstoneLinkNetworkHandler; @@ -37,7 +38,7 @@ public class Create { public static final String ID = "create"; public static final String NAME = "Create"; - public static final String VERSION = "0.1.1b"; + public static final String VERSION = "0.2.3"; public static Logger logger = LogManager.getLogger(); public static ItemGroup baseCreativeTab = new CreateItemGroup(); diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 53004e33e..d77b237f1 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -5,9 +5,7 @@ import java.util.List; import java.util.Map; import java.util.function.Function; -import com.simibubi.create.foundation.block.IHaveCustomBlockModel; -import com.simibubi.create.foundation.block.connected.IHaveConnectedTextures; -import com.simibubi.create.foundation.block.render.SpriteShiftEntry; +import com.simibubi.create.foundation.block.render.CustomBlockModels; import com.simibubi.create.foundation.item.IHaveCustomItemModel; import com.simibubi.create.foundation.utility.SuperByteBufferCache; import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer; @@ -42,6 +40,7 @@ public class CreateClient { public static SchematicHandler schematicHandler; public static SchematicAndQuillHandler schematicAndQuillHandler; public static SuperByteBufferCache bufferCache; + private static CustomBlockModels customBlockModels; public static void addListeners(IEventBus modEventBus) { DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { @@ -70,7 +69,7 @@ public class CreateClient { AllEntities.registerRenderers(); IResourceManager resourceManager = Minecraft.getInstance() - .getResourceManager(); + .getResourceManager(); if (resourceManager instanceof IReloadableResourceManager) ((IReloadableResourceManager) resourceManager).addReloadListener(new ResourceReloadHandler()); } @@ -84,17 +83,16 @@ public class CreateClient { @OnlyIn(Dist.CLIENT) public static void onTextureStitch(TextureStitchEvent.Pre event) { - if (!event.getMap().getId().equals(PlayerContainer.BLOCK_ATLAS_TEXTURE)) + if (!event.getMap() + .getId() + .equals(PlayerContainer.BLOCK_ATLAS_TEXTURE)) return; event.addSprite(new ResourceLocation(Create.ID, "block/belt_animated")); - for (AllBlocks allBlocks : AllBlocks.values()) { - Block block = allBlocks.get(); - if (block instanceof IHaveConnectedTextures) - for (SpriteShiftEntry spriteShiftEntry : ((IHaveConnectedTextures) block).getBehaviour() - .getAllCTShifts()) - event.addSprite(spriteShiftEntry.getTargetResourceLocation()); - } + + for (AllCTs ct : AllCTs.values()) + event.addSprite(ct.get() + .getTargetResourceLocation()); } @OnlyIn(Dist.CLIENT) @@ -102,18 +100,15 @@ public class CreateClient { Map modelRegistry = event.getModelRegistry(); AllBlockPartials.onModelBake(event); - for (AllBlocks allBlocks : AllBlocks.values()) { - Block block = allBlocks.get(); - if (block instanceof IHaveCustomBlockModel) - swapModels(modelRegistry, getAllBlockStateModelLocations(allBlocks), - ((IHaveCustomBlockModel) block)::createModel); - } + getCustomBlockModels() + .foreach((block, modelFunc) -> swapModels(modelRegistry, getAllBlockStateModelLocations(block), modelFunc)); + // todo modelswap for item registrate for (AllItems item : AllItems.values()) { if (item.get() instanceof IHaveCustomItemModel) swapModels(modelRegistry, getItemModelLocation(item), - m -> ((IHaveCustomItemModel) item.get()).createModel(m) - .loadPartials(event)); + m -> ((IHaveCustomItemModel) item.get()).createModel(m) + .loadPartials(event)); } } @@ -125,47 +120,51 @@ public class CreateClient { for (AllItems item : AllItems.values()) { if (item.get() instanceof IHaveCustomItemModel) ((IHaveCustomItemModel) item.get()).createModel(null) - .getModelLocations() - .forEach(ModelLoader::addSpecialModel); + .getModelLocations() + .forEach(ModelLoader::addSpecialModel); } } @OnlyIn(Dist.CLIENT) protected static ModelResourceLocation getItemModelLocation(AllItems item) { return new ModelResourceLocation(item.get() - .getRegistryName(), "inventory"); + .getRegistryName(), "inventory"); } @OnlyIn(Dist.CLIENT) - protected static List getAllBlockStateModelLocations(AllBlocks block) { + protected static List getAllBlockStateModelLocations(Block block) { List models = new ArrayList<>(); - block.get() - .getStateContainer() - .getValidStates() - .forEach(state -> { - models.add(getBlockModelLocation(block, BlockModelShapes.getPropertyMapString(state.getValues()))); - }); + block.getStateContainer() + .getValidStates() + .forEach(state -> { + models.add(getBlockModelLocation(block, BlockModelShapes.getPropertyMapString(state.getValues()))); + }); return models; } @OnlyIn(Dist.CLIENT) - protected static ModelResourceLocation getBlockModelLocation(AllBlocks block, String suffix) { - return new ModelResourceLocation(block.get() - .getRegistryName(), suffix); + protected static ModelResourceLocation getBlockModelLocation(Block block, String suffix) { + return new ModelResourceLocation(block.getRegistryName(), suffix); } @OnlyIn(Dist.CLIENT) protected static void swapModels(Map modelRegistry, - ModelResourceLocation location, Function factory) { + ModelResourceLocation location, Function factory) { modelRegistry.put(location, factory.apply(modelRegistry.get(location))); } @OnlyIn(Dist.CLIENT) protected static void swapModels(Map modelRegistry, - List locations, Function factory) { + List locations, Function factory) { locations.forEach(location -> { swapModels(modelRegistry, location, factory); }); } + public static CustomBlockModels getCustomBlockModels() { + if (customBlockModels == null) + customBlockModels = new CustomBlockModels(); + return customBlockModels; + } + } diff --git a/src/main/java/com/simibubi/create/CreateRegistrate.java b/src/main/java/com/simibubi/create/CreateRegistrate.java deleted file mode 100644 index 0567cce41..000000000 --- a/src/main/java/com/simibubi/create/CreateRegistrate.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.simibubi.create; - -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.Map.Entry; - -import com.simibubi.create.modules.Sections; -import com.tterrag.registrate.AbstractRegistrate; -import com.tterrag.registrate.builders.Builder; -import com.tterrag.registrate.util.NonNullLazyValue; -import com.tterrag.registrate.util.entry.RegistryEntry; -import com.tterrag.registrate.util.nullness.NonNullSupplier; - -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.IForgeRegistryEntry; - -public class CreateRegistrate extends AbstractRegistrate { - - /** - * Create a new {@link CreateRegistrate} and register event listeners for - * registration and data generation. Used in lieu of adding side-effects to - * constructor, so that alternate initialization strategies can be done in - * subclasses. - * - * @param modid The mod ID for which objects will be registered - * @return The {@link CreateRegistrate} instance - */ - public static CreateRegistrate create(String modid) { - return new CreateRegistrate(modid).registerEventListeners(FMLJavaModLoadingContext.get() - .getModEventBus()) - .itemGroup(() -> Create.baseCreativeTab); - } - - public static NonNullLazyValue lazy(String modid) { - return new NonNullLazyValue<>(() -> create(modid)); - } - - protected CreateRegistrate(String modid) { - super(modid); - } - - private Map, Sections> sectionLookup = new IdentityHashMap<>(); - - private Sections section; - - public CreateRegistrate startSection(Sections section) { - this.section = section; - return self(); - } - - public Sections currentSection() { - return section; - } - - @Override - protected , T extends R> RegistryEntry accept(String name, - Class type, Builder builder, NonNullSupplier creator) { - RegistryEntry ret = super.accept(name, type, builder, creator); - sectionLookup.put(ret, currentSection()); - return ret; - } - - public void addToSection(RegistryEntry entry, Sections section) { - sectionLookup.put(entry, section); - } - - public Sections getSection(RegistryEntry entry) { - return sectionLookup.getOrDefault(entry, Sections.UNASSIGNED); - } - - public Sections getSection(IForgeRegistryEntry entry) { - return sectionLookup.entrySet() - .stream() - .filter(e -> e.getKey() - .get() == entry) - .map(Entry::getValue) - .findFirst() - .orElse(Sections.UNASSIGNED); - } -} diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/CTModel.java b/src/main/java/com/simibubi/create/foundation/block/connected/CTModel.java index 7a827e153..801c13962 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/CTModel.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/CTModel.java @@ -18,7 +18,6 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.ILightReader; import net.minecraftforge.client.model.BakedModelWrapper; -import net.minecraftforge.client.model.data.EmptyModelData; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.client.model.data.ModelProperty; @@ -45,17 +44,14 @@ public class CTModel extends BakedModelWrapper { } } - public CTModel(IBakedModel originalModel, IHaveConnectedTextures block) { + public CTModel(IBakedModel originalModel, ConnectedTextureBehaviour behaviour) { super(originalModel); - behaviour = block.getBehaviour(); + this.behaviour = behaviour; } @Override public IModelData getModelData(ILightReader world, BlockPos pos, BlockState state, IModelData tileData) { - if (!(state.getBlock() instanceof IHaveConnectedTextures)) - return EmptyModelData.INSTANCE; CTData data = new CTData(); - for (Direction face : Direction.values()) { if (!Block.shouldSideBeRendered(state, world, pos, face) && !(state.getBlock() instanceof PaneBlock)) continue; diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShiftEntry.java b/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShiftEntry.java index 0ac5d7a1a..e1405fcda 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShiftEntry.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/CTSpriteShiftEntry.java @@ -7,6 +7,10 @@ import com.simibubi.create.foundation.utility.SuperByteBuffer; public abstract class CTSpriteShiftEntry extends SpriteShiftEntry { int textureSheetSize; + + public enum Type { + HORIZONTAL, VERTICAL, OMNIDIRECTIONAL; + } public CTSpriteShiftEntry(int sheetSize) { this.textureSheetSize = sheetSize; @@ -25,6 +29,7 @@ public abstract class CTSpriteShiftEntry extends SpriteShiftEntry { } public abstract int getTextureIndex(CTContext context); + public abstract Type getType(); public static class Horizontal extends CTSpriteShiftEntry { @@ -37,6 +42,11 @@ public abstract class CTSpriteShiftEntry extends SpriteShiftEntry { return (context.right ? 1 : 0) + (context.left ? 2 : 0); } + @Override + public Type getType() { + return Type.HORIZONTAL; + } + } public static class Vertical extends CTSpriteShiftEntry { @@ -50,6 +60,11 @@ public abstract class CTSpriteShiftEntry extends SpriteShiftEntry { return (context.up ? 1 : 0) + (context.down ? 2 : 0); } + @Override + public Type getType() { + return Type.VERTICAL; + } + } public static class Omnidirectional extends CTSpriteShiftEntry { @@ -120,6 +135,11 @@ public abstract class CTSpriteShiftEntry extends SpriteShiftEntry { return tileX + 8 * tileY; } + @Override + public Type getType() { + return Type.OMNIDIRECTIONAL; + } + } } diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/ConnectedTextureBehaviour.java b/src/main/java/com/simibubi/create/foundation/block/connected/ConnectedTextureBehaviour.java index 1b1055dde..a864f87b1 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/ConnectedTextureBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/ConnectedTextureBehaviour.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.block.connected; -import java.util.function.BiPredicate; +import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry.Type; import net.minecraft.block.BlockState; import net.minecraft.util.Direction; @@ -32,19 +32,26 @@ public abstract class ConnectedTextureBehaviour { return reverseUVs(state, face); } - public boolean connectsTo(BlockState state, BlockState other, ILightReader reader, BlockPos pos, - BlockPos otherPos, Direction face) { + public boolean connectsTo(BlockState state, BlockState other, ILightReader reader, BlockPos pos, BlockPos otherPos, + Direction face) { BlockPos blockingPos = otherPos.offset(face); - if ((face.getAxis().getCoordinate(pos.getX(), pos.getY(), pos.getZ()) == face.getAxis() + if ((face.getAxis() + .getCoordinate(pos.getX(), pos.getY(), pos.getZ()) == face.getAxis() .getCoordinate(otherPos.getX(), otherPos.getY(), otherPos.getZ())) - && connectsTo(state, reader.getBlockState(blockingPos), reader, pos, blockingPos, face)) + && connectsTo(state, reader.getBlockState(blockingPos), reader, pos, blockingPos, face)) return false; return state.getBlock() == other.getBlock(); } CTContext buildContext(ILightReader reader, BlockPos pos, BlockState state, Direction face) { + CTContext context = new CTContext(); + CTSpriteShiftEntry textureEntry = get(state, face); + + if (textureEntry == null) + return context; + Axis axis = face.getAxis(); boolean positive = face.getAxisDirection() == AxisDirection.POSITIVE; Direction h = axis == Axis.X ? Direction.SOUTH : Direction.WEST; @@ -58,27 +65,39 @@ public abstract class ConnectedTextureBehaviour { final Direction horizontal = h; final Direction vertical = v; - BiPredicate connection = (x, y) -> { - BlockPos p = pos.offset(horizontal, x).offset(vertical, y); - return connectsTo(state, reader.getBlockState(p), reader, pos, p, face); - }; - boolean flipH = reverseUVsHorizontally(state, face); boolean flipV = reverseUVsVertically(state, face); int sh = flipH ? -1 : 1; int sv = flipV ? -1 : 1; - CTContext context = new CTContext(); - context.up = connection.test(0, sv); - context.down = connection.test(0, -sv); - context.left = connection.test(-sh, 0); - context.right = connection.test(sh, 0); - context.topLeft = connection.test(-sh, sv); - context.topRight = connection.test(sh, sv); - context.bottomLeft = connection.test(-sh, -sv); - context.bottomRight = connection.test(sh, -sv); + Type type = textureEntry.getType(); + + if (type != Type.HORIZONTAL) { + context.up = testConnection(reader, pos, state, face, horizontal, vertical, 0, sv); + context.down = testConnection(reader, pos, state, face, horizontal, vertical, 0, -sv); + } + + if (type != Type.VERTICAL) { + context.left = testConnection(reader, pos, state, face, horizontal, vertical, -sh, 0); + context.right = testConnection(reader, pos, state, face, horizontal, vertical, sh, 0); + } + + if (type == Type.OMNIDIRECTIONAL) { + context.topLeft = testConnection(reader, pos, state, face, horizontal, vertical, -sh, sv); + context.topRight = testConnection(reader, pos, state, face, horizontal, vertical, sh, sv); + context.bottomLeft = testConnection(reader, pos, state, face, horizontal, vertical, -sh, -sv); + context.bottomRight = testConnection(reader, pos, state, face, horizontal, vertical, sh, -sv); + } return context; } + private boolean testConnection(ILightReader reader, BlockPos pos, BlockState state, Direction face, + final Direction horizontal, final Direction vertical, int sh, int sv) { + BlockPos p = pos.offset(horizontal, sh) + .offset(vertical, sv); + boolean test = connectsTo(state, reader.getBlockState(p), reader, pos, p, face); + return test; + } + } diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/GlassPaneCTBehaviour.java b/src/main/java/com/simibubi/create/foundation/block/connected/GlassPaneCTBehaviour.java new file mode 100644 index 000000000..836d9483d --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/block/connected/GlassPaneCTBehaviour.java @@ -0,0 +1,39 @@ +package com.simibubi.create.foundation.block.connected; + +import com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockTileEntity; + +import net.minecraft.block.BlockState; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Direction; +import net.minecraft.util.Direction.AxisDirection; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.ILightReader; + +public class GlassPaneCTBehaviour extends StandardCTBehaviour { + + public GlassPaneCTBehaviour(CTSpriteShiftEntry shift) { + super(shift); + } + + @Override + public boolean connectsTo(BlockState state, BlockState other, ILightReader reader, BlockPos pos, BlockPos otherPos, + Direction face) { + + TileEntity te = reader.getTileEntity(pos); + if (te instanceof WindowInABlockTileEntity) + state = ((WindowInABlockTileEntity) te).getWindowBlock(); + + TileEntity otherTE = reader.getTileEntity(otherPos); + if (otherTE instanceof WindowInABlockTileEntity) + other = ((WindowInABlockTileEntity) otherTE).getWindowBlock(); + + return state.getBlock() == other.getBlock(); + } + + @Override + protected boolean reverseUVsHorizontally(BlockState state, net.minecraft.util.Direction face) { + if (face.getAxisDirection() == AxisDirection.NEGATIVE) + return true; + return super.reverseUVsHorizontally(state, face); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/HorizontalCTBehaviour.java b/src/main/java/com/simibubi/create/foundation/block/connected/HorizontalCTBehaviour.java new file mode 100644 index 000000000..e13803217 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/block/connected/HorizontalCTBehaviour.java @@ -0,0 +1,35 @@ +package com.simibubi.create.foundation.block.connected; + +import java.util.Arrays; + +import net.minecraft.block.BlockState; +import net.minecraft.util.Direction; + +public class HorizontalCTBehaviour extends ConnectedTextureBehaviour { + + CTSpriteShiftEntry topShift; + CTSpriteShiftEntry layerShift; + + public HorizontalCTBehaviour(CTSpriteShiftEntry layerShift) { + this(layerShift, null); + } + + public HorizontalCTBehaviour(CTSpriteShiftEntry layerShift, CTSpriteShiftEntry topShift) { + this.layerShift = layerShift; + this.topShift = topShift; + } + + @Override + public CTSpriteShiftEntry get(BlockState state, Direction direction) { + return direction.getAxis() + .isHorizontal() ? layerShift : topShift; + } + + @Override + public Iterable getAllCTShifts() { + if (topShift == null) + return Arrays.asList(layerShift); + return Arrays.asList(layerShift, topShift); + } + +} \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/IHaveConnectedTextures.java b/src/main/java/com/simibubi/create/foundation/block/connected/IHaveConnectedTextures.java deleted file mode 100644 index 5404d1f46..000000000 --- a/src/main/java/com/simibubi/create/foundation/block/connected/IHaveConnectedTextures.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.simibubi.create.foundation.block.connected; - -import com.simibubi.create.foundation.block.IHaveCustomBlockModel; - -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -public interface IHaveConnectedTextures extends IHaveCustomBlockModel { - - public ConnectedTextureBehaviour getBehaviour(); - - @Override - @OnlyIn(Dist.CLIENT) - default IBakedModel createModel(IBakedModel original) { - return new CTModel(original, this); - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/block/render/CustomBlockModels.java b/src/main/java/com/simibubi/create/foundation/block/render/CustomBlockModels.java new file mode 100644 index 000000000..0f3efbd4a --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/block/render/CustomBlockModels.java @@ -0,0 +1,48 @@ +package com.simibubi.create.foundation.block.render; + +import java.util.ArrayList; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Supplier; + +import org.apache.commons.lang3.tuple.Pair; + +import com.tterrag.registrate.util.nullness.NonNullBiConsumer; +import com.tterrag.registrate.util.nullness.NonNullFunction; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.model.IBakedModel; + +public class CustomBlockModels { + + private List, NonNullFunction>> registered; + private Map> customModels; + + public CustomBlockModels() { + registered = new ArrayList<>(); + customModels = new IdentityHashMap<>(); + } + + public void register(Supplier entry, + NonNullFunction behaviour) { + registered.add(Pair.of(entry, behaviour)); + } + + public void foreach(NonNullBiConsumer> consumer) { + loadEntriesIfMissing(); + customModels.forEach(consumer); + } + + private void loadEntriesIfMissing() { + if (customModels.isEmpty()) + loadEntries(); + } + + private void loadEntries() { + customModels.clear(); + registered.forEach(p -> customModels.put(p.getKey() + .get(), p.getValue())); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java index ece3d75b4..c5c96b82e 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java @@ -3,8 +3,8 @@ package com.simibubi.create.foundation.block.render; import java.util.function.Function; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.util.ResourceLocation; public class SpriteShiftEntry { @@ -19,7 +19,8 @@ public class SpriteShiftEntry { } protected void loadTextures() { - Function textureMap = Minecraft.getInstance().getSpriteAtlas(AtlasTexture.LOCATION_BLOCKS_TEXTURE); + Function textureMap = Minecraft.getInstance() + .getSpriteAtlas(PlayerContainer.BLOCK_ATLAS_TEXTURE); original = textureMap.apply(originalTextureLocation); target = textureMap.apply(targetTextureLocation); } diff --git a/src/main/java/com/simibubi/create/foundation/registrate/CreateBlockBuilder.java b/src/main/java/com/simibubi/create/foundation/registrate/CreateBlockBuilder.java new file mode 100644 index 000000000..5e228467a --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/registrate/CreateBlockBuilder.java @@ -0,0 +1,70 @@ +package com.simibubi.create.foundation.registrate; + +import java.util.LinkedList; +import java.util.List; + +import com.simibubi.create.CreateClient; +import com.simibubi.create.foundation.block.connected.CTModel; +import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; +import com.tterrag.registrate.AbstractRegistrate; +import com.tterrag.registrate.builders.BlockBuilder; +import com.tterrag.registrate.builders.BuilderCallback; +import com.tterrag.registrate.util.entry.BlockEntry; +import com.tterrag.registrate.util.nullness.NonNullConsumer; +import com.tterrag.registrate.util.nullness.NonNullFunction; +import com.tterrag.registrate.util.nullness.NonNullSupplier; + +import net.minecraft.block.Block; +import net.minecraft.block.Block.Properties; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.DistExecutor; + +public class CreateBlockBuilder extends BlockBuilder { + + private List>> registerCallbacks; + + protected CreateBlockBuilder(AbstractRegistrate owner, P parent, String name, BuilderCallback callback, + NonNullFunction factory, NonNullSupplier initialProperties) { + super(owner, parent, name, callback, factory, initialProperties); + registerCallbacks = new LinkedList<>(); + } + + public static CreateBlockBuilder create(AbstractRegistrate owner, P parent, + String name, BuilderCallback callback, NonNullFunction factory, Material material) { + return (CreateBlockBuilder) new CreateBlockBuilder<>(owner, parent, name, callback, factory, + () -> Block.Properties.create(material)).defaultBlockstate() + .defaultLoot() + .defaultLang(); + } + + public CreateBlockBuilder connectedTextures(ConnectedTextureBehaviour behaviour) { + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> registerConnectedTexture(behaviour)); + return this; + } + + public CreateBlockBuilder onRegister(NonNullConsumer> callback) { + registerCallbacks.add(callback); + return this; + } + + @Override + public BlockEntry register() { + BlockEntry register = super.register(); + registerCallbacks.forEach(func -> func.accept(register)); + return register; + } + + @OnlyIn(Dist.CLIENT) + private void registerConnectedTexture(ConnectedTextureBehaviour behaviour) { + registerModelSwap(model -> new CTModel(model, behaviour)); + } + + @OnlyIn(Dist.CLIENT) + private void registerModelSwap(NonNullFunction modelFunc) { + onRegister(entry -> CreateClient.getCustomBlockModels().register(entry, modelFunc)); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrate.java b/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrate.java new file mode 100644 index 000000000..53f3f0e39 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrate.java @@ -0,0 +1,25 @@ +package com.simibubi.create.foundation.registrate; + +import com.simibubi.create.Create; +import com.tterrag.registrate.util.NonNullLazyValue; + +public class CreateRegistrate extends CreateRegistrateBase { + + /** + * Create a new {@link CreateRegistrate} and register event listeners for + * registration and data generation. Used in lieu of adding side-effects to + * constructor, so that alternate initialization strategies can be done in + * subclasses. + * + * @param modid The mod ID for which objects will be registered + * @return The {@link CreateRegistrate} instance + */ + public CreateRegistrate(String modid) { + super(modid, () -> Create.baseCreativeTab); + } + + public static NonNullLazyValue lazy(String modid) { + return new NonNullLazyValue<>(() -> new CreateRegistrate(modid)); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrateBase.java b/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrateBase.java new file mode 100644 index 000000000..995409b6e --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/registrate/CreateRegistrateBase.java @@ -0,0 +1,95 @@ +package com.simibubi.create.foundation.registrate; + +import java.util.IdentityHashMap; +import java.util.Map; +import java.util.Map.Entry; + +import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; +import com.simibubi.create.foundation.utility.data.BlockStateGen; +import com.simibubi.create.modules.Sections; +import com.simibubi.create.modules.palettes.ConnectedGlassBlock; +import com.tterrag.registrate.AbstractRegistrate; +import com.tterrag.registrate.builders.Builder; +import com.tterrag.registrate.util.entry.BlockEntry; +import com.tterrag.registrate.util.entry.RegistryEntry; +import com.tterrag.registrate.util.nullness.NonNullFunction; +import com.tterrag.registrate.util.nullness.NonNullSupplier; + +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.item.ItemGroup; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.IForgeRegistryEntry; + +public class CreateRegistrateBase> extends AbstractRegistrate { + + protected CreateRegistrateBase(String modid, NonNullSupplier creativeTab) { + super(modid); + registerEventListeners(FMLJavaModLoadingContext.get() + .getModEventBus()); + itemGroup(creativeTab); + } + + private static Map, Sections> sectionLookup = new IdentityHashMap<>(); + private Sections section; + + public void startSection(Sections section) { + this.section = section; + } + + public Sections currentSection() { + return section; + } + + @Override + protected , T extends R> RegistryEntry accept(String name, + Class type, Builder builder, NonNullSupplier creator) { + RegistryEntry ret = super.accept(name, type, builder, creator); + sectionLookup.put(ret, currentSection()); + return ret; + } + + @SuppressWarnings("unchecked") + public CreateBlockBuilder createBlock(String name, + NonNullFunction factory) { + return (CreateBlockBuilder) super.block(name, factory); + } + + @Override + public CreateBlockBuilder block(P parent, String name, + NonNullFunction factory, Material material) { + return CreateBlockBuilder.create(this, parent, name, this::accept, factory, material); + } + + public void addToSection(RegistryEntry entry, Sections section) { + sectionLookup.put(entry, section); + } + + public Sections getSection(RegistryEntry entry) { + return sectionLookup.getOrDefault(entry, Sections.UNASSIGNED); + } + + public Sections getSection(IForgeRegistryEntry entry) { + return sectionLookup.entrySet() + .stream() + .filter(e -> e.getKey() + .get() == entry) + .map(Entry::getValue) + .findFirst() + .orElse(Sections.UNASSIGNED); + } + + // Specific patterns + + public BlockEntry framedGlass(String name, ConnectedTextureBehaviour behaviour) { + return createBlock(name, ConnectedGlassBlock::new).connectedTextures(behaviour) + .addLayer(() -> RenderType::getTranslucent) + .initialProperties(() -> Blocks.GLASS) + .blockstate((c, p) -> BlockStateGen.cubeAll(c, p, "palettes/", "framed_glass")) + .simpleItem() + .register(); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/utility/data/BlockStateGen.java b/src/main/java/com/simibubi/create/foundation/utility/data/BlockStateGen.java index bb8a550a0..feec00e2f 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/data/BlockStateGen.java +++ b/src/main/java/com/simibubi/create/foundation/utility/data/BlockStateGen.java @@ -18,36 +18,42 @@ import net.minecraftforge.client.model.generators.ModelFile; public class BlockStateGen { public static NonNullBiConsumer, RegistrateBlockstateProvider> axisBlockProvider( - boolean customItem) { + boolean customItem) { return (c, p) -> BlockStateGen.axisBlock(c, p, - $ -> customItem ? AssetLookup.partialBaseModel(c, p) : AssetLookup.standardModel(c, p)); + $ -> customItem ? AssetLookup.partialBaseModel(c, p) : AssetLookup.standardModel(c, p)); } public static void axisBlock(DataGenContext ctx, RegistrateBlockstateProvider prov, - Function modelFunc) { + Function modelFunc) { prov.getVariantBuilder(ctx.getEntry()) - .forAllStates(state -> { - Axis axis = state.get(BlockStateProperties.AXIS); - return ConfiguredModel.builder() - .modelFile(modelFunc.apply(state)) - .rotationX(axis == Axis.Y ? 0 : 90) - .rotationY(axis == Axis.X ? 90 : 0) - .build(); - }); + .forAllStates(state -> { + Axis axis = state.get(BlockStateProperties.AXIS); + return ConfiguredModel.builder() + .modelFile(modelFunc.apply(state)) + .rotationX(axis == Axis.Y ? 0 : 90) + .rotationY(axis == Axis.X ? 90 : 0) + .build(); + }); } public static void cubeAll(DataGenContext ctx, RegistrateBlockstateProvider prov, - String texturePath) { + String textureSubDir) { + cubeAll(ctx, prov, textureSubDir, ctx.getName()); + } + + public static void cubeAll(DataGenContext ctx, RegistrateBlockstateProvider prov, + String textureSubDir, String name) { + String texturePath = "block/" + textureSubDir + name; prov.simpleBlock(ctx.get(), prov.models() - .cubeAll(ctx.getName(), prov.modLoc(texturePath))); + .cubeAll(ctx.getName(), prov.modLoc(texturePath))); } public static void pavedBlock(DataGenContext ctx, RegistrateBlockstateProvider prov, - ModelFile top, ModelFile covered) { + ModelFile top, ModelFile covered) { prov.getVariantBuilder(ctx.getEntry()) - .forAllStates(state -> ConfiguredModel.builder() - .modelFile(state.get(PavedBlock.COVERED) ? covered : top) - .build()); + .forAllStates(state -> ConfiguredModel.builder() + .modelFile(state.get(PavedBlock.COVERED) ? covered : top) + .build()); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/CasingBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/CasingBlock.java index 938b56b2c..4e9e8ddab 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/CasingBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/CasingBlock.java @@ -1,14 +1,7 @@ package com.simibubi.create.modules.contraptions; -import com.simibubi.create.foundation.block.connected.CTSpriteShifter; -import com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTType; -import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; -import com.simibubi.create.foundation.block.connected.IHaveConnectedTextures; -import com.simibubi.create.foundation.block.connected.StandardCTBehaviour; - import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResultType; @@ -16,15 +9,12 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraftforge.common.ToolType; -public class CasingBlock extends Block implements IHaveConnectedTextures, IWrenchable { +public class CasingBlock extends Block implements IWrenchable { - String textureFrom; - - public CasingBlock(String textureFrom) { - super(Properties.from(Blocks.ANDESITE)); - this.textureFrom = textureFrom; + public CasingBlock(Properties p_i48440_1_) { + super(p_i48440_1_); } - + @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { return ActionResultType.FAIL; @@ -49,9 +39,4 @@ public class CasingBlock extends Block implements IHaveConnectedTextures, IWrenc return tool == ToolType.AXE || tool == ToolType.PICKAXE; } - @Override - public ConnectedTextureBehaviour getBehaviour() { - return new StandardCTBehaviour(CTSpriteShifter.get(CTType.OMNIDIRECTIONAL, textureFrom, getRegistryName().getPath())); - } - } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/chassis/LinearChassisBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/chassis/LinearChassisBlock.java index c8967f9c4..eb61d840b 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/chassis/LinearChassisBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/chassis/LinearChassisBlock.java @@ -7,7 +7,6 @@ import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; import com.simibubi.create.foundation.block.connected.CTSpriteShifter; import com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTType; import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; -import com.simibubi.create.foundation.block.connected.IHaveConnectedTextures; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -20,7 +19,7 @@ import net.minecraft.util.Direction.AxisDirection; import net.minecraft.util.math.BlockPos; import net.minecraft.world.ILightReader; -public class LinearChassisBlock extends AbstractChassisBlock implements IHaveConnectedTextures { +public class LinearChassisBlock extends AbstractChassisBlock { public static final BooleanProperty STICKY_TOP = BooleanProperty.create("sticky_top"); public static final BooleanProperty STICKY_BOTTOM = BooleanProperty.create("sticky_bottom"); @@ -70,12 +69,7 @@ public class LinearChassisBlock extends AbstractChassisBlock implements IHaveCon return state1.getBlock() == state2.getBlock(); } - @Override - public ConnectedTextureBehaviour getBehaviour() { - return new ChassisCTBehaviour(); - } - - private static class ChassisCTBehaviour extends ConnectedTextureBehaviour { + public static class ChassisCTBehaviour extends ConnectedTextureBehaviour { static final CTSpriteShiftEntry regular = CTSpriteShifter.get(CTType.OMNIDIRECTIONAL, "translation_chassis_top"); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/InputCTBehaviour.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/CrafterCTBehaviour.java similarity index 97% rename from src/main/java/com/simibubi/create/modules/contraptions/components/crafter/InputCTBehaviour.java rename to src/main/java/com/simibubi/create/modules/contraptions/components/crafter/CrafterCTBehaviour.java index f9f139c1b..def0b71c2 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/InputCTBehaviour.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/CrafterCTBehaviour.java @@ -17,7 +17,7 @@ import net.minecraft.util.Direction.AxisDirection; import net.minecraft.util.math.BlockPos; import net.minecraft.world.ILightReader; -public class InputCTBehaviour extends ConnectedTextureBehaviour { +public class CrafterCTBehaviour extends ConnectedTextureBehaviour { static final CTSpriteShiftEntry front = CTSpriteShifter.get(CTType.OMNIDIRECTIONAL, "crafter_top", "brass_casing"); static final CTSpriteShiftEntry side = CTSpriteShifter.get(CTType.VERTICAL, "crafter_side"); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterBlock.java index 0dd6589c0..f5419212c 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterBlock.java @@ -3,8 +3,6 @@ package com.simibubi.create.modules.contraptions.components.crafter; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.block.ITE; -import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; -import com.simibubi.create.foundation.block.connected.IHaveConnectedTextures; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; @@ -40,8 +38,7 @@ import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; -public class MechanicalCrafterBlock extends HorizontalKineticBlock - implements ITE, IHaveConnectedTextures { +public class MechanicalCrafterBlock extends HorizontalKineticBlock implements ITE { public static final EnumProperty POINTING = EnumProperty.create("pointing", Pointing.class); @@ -72,16 +69,20 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock @Override public Axis getRotationAxis(BlockState state) { - return state.get(HORIZONTAL_FACING).getAxis(); + return state.get(HORIZONTAL_FACING) + .getAxis(); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { Direction face = context.getFace(); - BlockPos placedOnPos = context.getPos().offset(face.getOpposite()); - BlockState blockState = context.getWorld().getBlockState(placedOnPos); + BlockPos placedOnPos = context.getPos() + .offset(face.getOpposite()); + BlockState blockState = context.getWorld() + .getBlockState(placedOnPos); - if ((blockState.getBlock() != this) || context.getPlayer().isSneaking()) { + if ((blockState.getBlock() != this) || context.getPlayer() + .isSneaking()) { BlockState stateForPlacement = super.getStateForPlacement(context); Direction direction = stateForPlacement.get(HORIZONTAL_FACING); if (direction != face) @@ -91,7 +92,8 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock Direction otherFacing = blockState.get(HORIZONTAL_FACING); Pointing pointing = pointingFromFacing(face, otherFacing); - return getDefaultState().with(HORIZONTAL_FACING, otherFacing).with(POINTING, pointing); + return getDefaultState().with(HORIZONTAL_FACING, otherFacing) + .with(POINTING, pointing); } @Override @@ -113,7 +115,8 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock } for (Direction direction : Direction.values()) { - if (direction.getAxis() == state.get(HORIZONTAL_FACING).getAxis()) + if (direction.getAxis() == state.get(HORIZONTAL_FACING) + .getAxis()) continue; BlockPos otherPos = pos.offset(direction); @@ -122,7 +125,8 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock if (thisInput == null || otherInput == null) continue; - if (!pos.add(thisInput.data.get(0)).equals(otherPos.add(otherInput.data.get(0)))) + if (!pos.add(thisInput.data.get(0)) + .equals(otherPos.add(otherInput.data.get(0)))) continue; ConnectedInputHandler.toggleConnection(worldIn, pos, otherPos); @@ -150,7 +154,8 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { if (context.getFace() == state.get(HORIZONTAL_FACING)) { - context.getWorld().setBlockState(context.getPos(), state.cycle(POINTING)); + context.getWorld() + .setBlockState(context.getPos(), state.cycle(POINTING)); withTileEntityDo(context.getWorld(), context.getPos(), TileEntity::markDirty); return ActionResultType.SUCCESS; } @@ -160,7 +165,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock @Override public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, - BlockRayTraceResult hit) { + BlockRayTraceResult hit) { ItemStack heldItem = player.getHeldItem(handIn); boolean isHand = heldItem.isEmpty() && handIn == Hand.MAIN_HAND; @@ -285,11 +290,6 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock } } - @Override - public ConnectedTextureBehaviour getBehaviour() { - return new InputCTBehaviour(); - } - @Override public Class getTileEntityClass() { return MechanicalCrafterTileEntity.class; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/processing/BasinTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/processing/BasinTileEntityRenderer.java index 8e1d7dfa5..1700c3d70 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/processing/BasinTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/processing/BasinTileEntityRenderer.java @@ -3,7 +3,6 @@ package com.simibubi.create.modules.contraptions.processing; import java.util.Random; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.foundation.block.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.VecHelper; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java index 2e94dae02..b3642f588 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java @@ -23,8 +23,8 @@ import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Hand; @@ -64,13 +64,17 @@ public class SymmetryWandScreen extends AbstractSimiScreen { super.init(); this.setWindowSize(ScreenResources.WAND_SYMMETRY.width + 50, ScreenResources.WAND_SYMMETRY.height + 50); - labelType = new Label(guiLeft + 122, guiTop + 15, "").colored(0xFFFFFFFF).withShadow(); - labelAlign = new Label(guiLeft + 122, guiTop + 35, "").colored(0xFFFFFFFF).withShadow(); + labelType = new Label(guiLeft + 122, guiTop + 15, "").colored(0xFFFFFFFF) + .withShadow(); + labelAlign = new Label(guiLeft + 122, guiTop + 35, "").colored(0xFFFFFFFF) + .withShadow(); - int state = currentElement instanceof TriplePlaneMirror ? 2 - : currentElement instanceof CrossPlaneMirror ? 1 : 0; - areaType = new SelectionScrollInput(guiLeft + 119, guiTop + 12, 70, 14) - .forOptions(SymmetryMirror.getMirrors()).titled(mirrorType).writingTo(labelType).setState(state); + int state = + currentElement instanceof TriplePlaneMirror ? 2 : currentElement instanceof CrossPlaneMirror ? 1 : 0; + areaType = new SelectionScrollInput(guiLeft + 119, guiTop + 12, 70, 14).forOptions(SymmetryMirror.getMirrors()) + .titled(mirrorType) + .writingTo(labelType) + .setState(state); areaType.calling(position -> { switch (position) { @@ -105,8 +109,10 @@ public class SymmetryWandScreen extends AbstractSimiScreen { } areaAlign = new SelectionScrollInput(guiLeft + 119, guiTop + 32, 70, 14).forOptions(element.getAlignToolTips()) - .titled(orientation).writingTo(labelAlign).setState(element.getOrientationIndex()) - .calling(element::setOrientation); + .titled(orientation) + .writingTo(labelAlign) + .setState(element.getOrientationIndex()) + .calling(element::setOrientation); widgets.add(areaAlign); } @@ -127,7 +133,8 @@ public class SymmetryWandScreen extends AbstractSimiScreen { font.drawString(mirrorType, x - 5, y, ScreenResources.FONT_COLOR); font.drawString(orientation, x - 5, y + 20, ScreenResources.FONT_COLOR); - minecraft.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); + minecraft.getTextureManager() + .bindTexture(PlayerContainer.BLOCK_ATLAS_TEXTURE); RenderSystem.enableBlend(); renderBlock(); @@ -135,7 +142,7 @@ public class SymmetryWandScreen extends AbstractSimiScreen { RenderSystem.pushLightingAttributes(); RenderSystem.pushMatrix(); - + RenderHelper.enable(); RenderSystem.enableBlend(); RenderSystem.enableRescaleNormal(); @@ -149,7 +156,9 @@ public class SymmetryWandScreen extends AbstractSimiScreen { RenderSystem.rotatef(90 + 0.2f * animationProgress, 0, 1, 0); RenderSystem.scaled(100, -100, 100); itemRenderer.renderItem(wand, TransformType.NONE, 0xF000F0, OverlayTexture.DEFAULT_UV, new MatrixStack(), - Minecraft.getInstance().getBufferBuilders().getEntityVertexConsumers()); + Minecraft.getInstance() + .getBufferBuilders() + .getEntityVertexConsumers()); RenderSystem.disableAlphaTest(); RenderSystem.disableRescaleNormal(); @@ -161,14 +170,17 @@ public class SymmetryWandScreen extends AbstractSimiScreen { protected void renderBlock() { MatrixStack ms = new MatrixStack(); - IRenderTypeBuffer buffer = Minecraft.getInstance().getBufferBuilders().getEntityVertexConsumers(); + IRenderTypeBuffer buffer = Minecraft.getInstance() + .getBufferBuilders() + .getEntityVertexConsumers(); ms.translate(guiLeft + 15, guiTop - 117, 20); ms.multiply(new Vector3f(.3f, 1f, 0f).getDegreesQuaternion(-22.5f)); ms.scale(32, -32, 32); ms.translate(0, -5, 0); - minecraft.getBlockRendererDispatcher().renderBlock(currentElement.getModel(), ms, buffer, 0xF000F0, - OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); + minecraft.getBlockRendererDispatcher() + .renderBlock(currentElement.getModel(), ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV, + EmptyModelData.INSTANCE); } @Override diff --git a/src/main/java/com/simibubi/create/modules/palettes/AllPaletteBlocks.java b/src/main/java/com/simibubi/create/modules/palettes/AllPaletteBlocks.java index 3e5e7bbb5..6d166d544 100644 --- a/src/main/java/com/simibubi/create/modules/palettes/AllPaletteBlocks.java +++ b/src/main/java/com/simibubi/create/modules/palettes/AllPaletteBlocks.java @@ -1,8 +1,14 @@ package com.simibubi.create.modules.palettes; +import com.simibubi.create.AllCTs; import com.simibubi.create.Create; +import com.simibubi.create.foundation.block.connected.HorizontalCTBehaviour; +import com.simibubi.create.foundation.block.connected.StandardCTBehaviour; import com.simibubi.create.foundation.utility.data.BlockStateGen; +import com.tterrag.registrate.providers.DataGenContext; +import com.tterrag.registrate.providers.RegistrateBlockstateProvider; import com.tterrag.registrate.util.entry.BlockEntry; +import com.tterrag.registrate.util.nullness.NonNullBiConsumer; import net.minecraft.block.Block; import net.minecraft.block.Blocks; @@ -12,6 +18,20 @@ public class AllPaletteBlocks { private static final PalettesRegistrate REGISTRATE = Create.palettesRegistrate(); + // Windows and Glass + + public static final BlockEntry FRAMED_GLASS = + REGISTRATE.framedGlass("framed_glass", new StandardCTBehaviour(AllCTs.FRAMED_GLASS.get())); + + public static final BlockEntry HORIZONTAL_FRAMED_GLASS = + REGISTRATE.framedGlass("horizontal_framed_glass", + new HorizontalCTBehaviour(AllCTs.HORIZONTAL_FRAMED_GLASS.get(), AllCTs.FRAMED_GLASS.get())); + + public static final BlockEntry VERTICAL_FRAMED_GLASS = + REGISTRATE.framedGlass("vertical_framed_glass", new HorizontalCTBehaviour(AllCTs.VERTICAL_FRAMED_GLASS.get())); + + // Vanilla stone variant patterns + public static final PalettesVariantEntry GRANITE_VARIANTS = new PalettesVariantEntry("granite", PaletteBlockPatterns.vanillaRange, b -> b.initialProperties(() -> Blocks.GRANITE) .simpleItem() @@ -27,10 +47,13 @@ public class AllPaletteBlocks { .simpleItem() .register()); - public static final BlockEntry LIMESAND = REGISTRATE.block("limesand", p -> new SandBlock(0xD7D7C7, p)) - .initialProperties(() -> Blocks.SAND) - .blockstate((c, p) -> BlockStateGen.cubeAll(c, p, "block/palettes/" + c.getName())) - .register(); + // Create stone variants + + public static final BlockEntry LIMESAND = + REGISTRATE.createBlock("limesand", p -> new SandBlock(0xD7D7C7, p)) + .initialProperties(() -> Blocks.SAND) + .blockstate(palettesCubeAll()) + .register(); public static final BlockEntry LIMESTONE = REGISTRATE.baseBlock("limestone", Block::new, () -> Blocks.SANDSTONE) @@ -68,10 +91,11 @@ public class AllPaletteBlocks { .simpleItem() .register()); - public static final BlockEntry NATURAL_SCORIA = REGISTRATE.block("natural_scoria", ScoriaBlock::new) - .initialProperties(() -> Blocks.ANDESITE) - .blockstate((c, p) -> BlockStateGen.cubeAll(c, p, "block/palettes/" + c.getName())) - .register(); + public static final BlockEntry NATURAL_SCORIA = + REGISTRATE.createBlock("natural_scoria", ScoriaBlock::new) + .initialProperties(() -> Blocks.ANDESITE) + .blockstate(palettesCubeAll()) + .register(); public static final BlockEntry SCORIA = REGISTRATE.baseBlock("scoria", Block::new, () -> Blocks.ANDESITE) .register(); @@ -92,4 +116,7 @@ public class AllPaletteBlocks { public static void register() {} + private static NonNullBiConsumer, RegistrateBlockstateProvider> palettesCubeAll() { + return (c, p) -> BlockStateGen.cubeAll(c, p, "palettes/"); + } } diff --git a/src/main/java/com/simibubi/create/modules/palettes/CTGlassBlock.java b/src/main/java/com/simibubi/create/modules/palettes/CTGlassBlock.java deleted file mode 100644 index 74d433557..000000000 --- a/src/main/java/com/simibubi/create/modules/palettes/CTGlassBlock.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.simibubi.create.modules.palettes; - -import com.simibubi.create.AllCTs; -import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; -import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; -import com.simibubi.create.foundation.block.connected.IHaveConnectedTextures; -import com.simibubi.create.foundation.block.connected.StandardCTBehaviour; - -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.GlassBlock; -import net.minecraft.util.Direction; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -public class CTGlassBlock extends GlassBlock implements IHaveConnectedTextures { - - private boolean hasAlpha; - protected ConnectedTextureBehaviour behaviour; - - public CTGlassBlock(AllCTs spriteShift, boolean hasAlpha) { - super(Properties.from(Blocks.GLASS)); - this.hasAlpha = hasAlpha; - this.behaviour = createBehaviour(spriteShift.get()); - } - - @OnlyIn(Dist.CLIENT) - @Override - public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) { - return adjacentBlockState.getBlock() instanceof CTGlassBlock ? true - : super.isSideInvisible(state, adjacentBlockState, side); - } - - public ConnectedTextureBehaviour createBehaviour(CTSpriteShiftEntry spriteShift) { - return new StandardCTBehaviour(spriteShift); - } - -// @Override // TODO 1.15 register layer -// public BlockRenderLayer getRenderLayer() { -// return hasAlpha ? BlockRenderLayer.TRANSLUCENT : super.getRenderLayer(); -// } - - @Override - public ConnectedTextureBehaviour getBehaviour() { - return behaviour; - } - -} diff --git a/src/main/java/com/simibubi/create/modules/palettes/CTGlassPaneBlock.java b/src/main/java/com/simibubi/create/modules/palettes/CTGlassPaneBlock.java deleted file mode 100644 index 420f25fba..000000000 --- a/src/main/java/com/simibubi/create/modules/palettes/CTGlassPaneBlock.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.simibubi.create.modules.palettes; - -import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; -import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; -import com.simibubi.create.foundation.block.connected.IHaveConnectedTextures; -import com.simibubi.create.foundation.block.connected.StandardCTBehaviour; -import com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockTileEntity; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.Direction.AxisDirection; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ILightReader; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -public class CTGlassPaneBlock extends GlassPaneBlock implements IHaveConnectedTextures { - - protected CTGlassBlock ctGlass; - protected ConnectedTextureBehaviour behaviour; - - public CTGlassPaneBlock(Block ctGlass) { - super(Properties.from(Blocks.GLASS)); - this.ctGlass = (CTGlassBlock) ctGlass; - behaviour = createBehaviour(); - } - - @Override - @OnlyIn(Dist.CLIENT) - public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) { - if (side.getAxis().isVertical()) - return adjacentBlockState == state; - return super.isSideInvisible(state, adjacentBlockState, side); - } - - protected ConnectedTextureBehaviour createBehaviour() { - for (CTSpriteShiftEntry ctSpriteShiftEntry : ctGlass.getBehaviour().getAllCTShifts()) { - return new StandardCTBehaviour(ctSpriteShiftEntry) { - @Override - public boolean connectsTo(BlockState state, BlockState other, ILightReader reader, - BlockPos pos, BlockPos otherPos, Direction face) { - - TileEntity te = reader.getTileEntity(pos); - if (te instanceof WindowInABlockTileEntity) - state = ((WindowInABlockTileEntity) te).getWindowBlock(); - - TileEntity otherTE = reader.getTileEntity(otherPos); - if (otherTE instanceof WindowInABlockTileEntity) - other = ((WindowInABlockTileEntity) otherTE).getWindowBlock(); - - return state.getBlock() == other.getBlock(); - } - - @Override - protected boolean reverseUVsHorizontally(BlockState state, net.minecraft.util.Direction face) { - if (face.getAxisDirection() == AxisDirection.NEGATIVE) - return true; - return super.reverseUVsHorizontally(state, face); - } - }; - } - return null; - } - -// @Override // TODO 1.15 register layer -// public BlockRenderLayer getRenderLayer() { -// return ctGlass.getRenderLayer(); -// } - - @Override - public ConnectedTextureBehaviour getBehaviour() { - return behaviour; - } - -} diff --git a/src/main/java/com/simibubi/create/modules/palettes/CTWindowBlock.java b/src/main/java/com/simibubi/create/modules/palettes/CTWindowBlock.java deleted file mode 100644 index ccb7b51f0..000000000 --- a/src/main/java/com/simibubi/create/modules/palettes/CTWindowBlock.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.simibubi.create.modules.palettes; - -import com.simibubi.create.AllCTs; - -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.util.Direction; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -public class CTWindowBlock extends VerticalCTGlassBlock { - - public CTWindowBlock(AllCTs spriteShift, boolean hasAlpha) { - super(spriteShift, hasAlpha); - } - - @OnlyIn(Dist.CLIENT) - @Override - public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) { - return adjacentBlockState.getBlock() instanceof CTGlassBlock - ? (!RenderTypeLookup.canRenderInLayer(state, RenderType.getTranslucent()) && side.getAxis().isHorizontal() - || state.getBlock() == adjacentBlockState.getBlock()) - : super.isSideInvisible(state, adjacentBlockState, side); - } - -} diff --git a/src/main/java/com/simibubi/create/modules/palettes/ConnectedGlassBlock.java b/src/main/java/com/simibubi/create/modules/palettes/ConnectedGlassBlock.java new file mode 100644 index 000000000..27d37b542 --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/palettes/ConnectedGlassBlock.java @@ -0,0 +1,22 @@ +package com.simibubi.create.modules.palettes; + +import net.minecraft.block.BlockState; +import net.minecraft.block.GlassBlock; +import net.minecraft.util.Direction; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +public class ConnectedGlassBlock extends GlassBlock { + + public ConnectedGlassBlock(Properties p_i48392_1_) { + super(p_i48392_1_); + } + + @Override + @OnlyIn(Dist.CLIENT) + public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) { + return adjacentBlockState.getBlock() instanceof ConnectedGlassBlock ? true + : super.isSideInvisible(state, adjacentBlockState, side); + } + +} diff --git a/src/main/java/com/simibubi/create/modules/palettes/ConnectedGlassPaneBlock.java b/src/main/java/com/simibubi/create/modules/palettes/ConnectedGlassPaneBlock.java new file mode 100644 index 000000000..a73053232 --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/palettes/ConnectedGlassPaneBlock.java @@ -0,0 +1,23 @@ +package com.simibubi.create.modules.palettes; + +import net.minecraft.block.BlockState; +import net.minecraft.util.Direction; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +public class ConnectedGlassPaneBlock extends GlassPaneBlock { + + public ConnectedGlassPaneBlock(Properties builder) { + super(builder); + } + + @Override + @OnlyIn(Dist.CLIENT) + public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) { + if (side.getAxis() + .isVertical()) + return adjacentBlockState == state; + return super.isSideInvisible(state, adjacentBlockState, side); + } + +} diff --git a/src/main/java/com/simibubi/create/modules/palettes/HorizontalCTGlassBlock.java b/src/main/java/com/simibubi/create/modules/palettes/HorizontalCTGlassBlock.java deleted file mode 100644 index 3c6665ee2..000000000 --- a/src/main/java/com/simibubi/create/modules/palettes/HorizontalCTGlassBlock.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.simibubi.create.modules.palettes; - -import javax.annotation.Nullable; - -import com.simibubi.create.AllCTs; -import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; -import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; - -public class HorizontalCTGlassBlock extends CTGlassBlock { - - private AllCTs topShift; - - public HorizontalCTGlassBlock(AllCTs layerShift, @Nullable AllCTs topShift, boolean hasAlpha) { - super(layerShift, hasAlpha); - this.topShift = topShift; - behaviour = createBehaviour(layerShift.get()); - } - - @Override - public ConnectedTextureBehaviour createBehaviour(CTSpriteShiftEntry spriteShift) { - return new LayeredCTBlock.LayeredCTBehaviour(spriteShift, topShift == null ? null : topShift.get()); - } - -} diff --git a/src/main/java/com/simibubi/create/modules/palettes/LayeredCTBlock.java b/src/main/java/com/simibubi/create/modules/palettes/LayeredCTBlock.java deleted file mode 100644 index c5b988416..000000000 --- a/src/main/java/com/simibubi/create/modules/palettes/LayeredCTBlock.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.simibubi.create.modules.palettes; - -import java.util.Arrays; - -import javax.annotation.Nullable; - -import com.simibubi.create.AllCTs; -import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; -import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; -import com.simibubi.create.foundation.block.connected.IHaveConnectedTextures; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; - -public class LayeredCTBlock extends Block implements IHaveConnectedTextures { - - private LayeredCTBehaviour behaviour; - - public LayeredCTBlock(Properties properties, AllCTs layerShift) { - this(properties, layerShift, null); - } - - public LayeredCTBlock(Properties properties, AllCTs layerShift, @Nullable AllCTs topShift) { - super(properties); - behaviour = new LayeredCTBehaviour(layerShift.get(), topShift == null ? null : topShift.get()); - } - - @Override - public ConnectedTextureBehaviour getBehaviour() { - return behaviour; - } - - static class LayeredCTBehaviour extends ConnectedTextureBehaviour { - - CTSpriteShiftEntry topShift; - CTSpriteShiftEntry layerShift; - - public LayeredCTBehaviour(CTSpriteShiftEntry layerShift, CTSpriteShiftEntry topShift) { - this.layerShift = layerShift; - this.topShift = topShift; - } - - @Override - public CTSpriteShiftEntry get(BlockState state, Direction direction) { - return direction.getAxis().isHorizontal() ? layerShift : topShift; - } - - @Override - public Iterable getAllCTShifts() { - if (topShift == null) - return Arrays.asList(layerShift); - return Arrays.asList(layerShift, topShift); - } - - } - -} diff --git a/src/main/java/com/simibubi/create/modules/palettes/PalettesItemGroup.java b/src/main/java/com/simibubi/create/modules/palettes/PalettesItemGroup.java index cb1b896bb..adc37130d 100644 --- a/src/main/java/com/simibubi/create/modules/palettes/PalettesItemGroup.java +++ b/src/main/java/com/simibubi/create/modules/palettes/PalettesItemGroup.java @@ -28,7 +28,8 @@ public class PalettesItemGroup extends CreateItemGroupBase { @Override public ItemStack createIcon() { - return new ItemStack(AllBlocks.IRON_GLASS.get()); + return new ItemStack(AllBlocks.COPPER_BLOCK.get()); +// return new ItemStack(AllBlocks.IRON_GLASS.get()); } } diff --git a/src/main/java/com/simibubi/create/modules/palettes/PalettesRegistrate.java b/src/main/java/com/simibubi/create/modules/palettes/PalettesRegistrate.java index 50a1141d8..9484dfbe3 100644 --- a/src/main/java/com/simibubi/create/modules/palettes/PalettesRegistrate.java +++ b/src/main/java/com/simibubi/create/modules/palettes/PalettesRegistrate.java @@ -1,63 +1,40 @@ package com.simibubi.create.modules.palettes; import com.simibubi.create.Create; +import com.simibubi.create.foundation.registrate.CreateRegistrateBase; import com.simibubi.create.modules.Sections; -import com.tterrag.registrate.AbstractRegistrate; import com.tterrag.registrate.builders.BlockBuilder; -import com.tterrag.registrate.builders.Builder; import com.tterrag.registrate.util.NonNullLazyValue; -import com.tterrag.registrate.util.entry.RegistryEntry; import com.tterrag.registrate.util.nullness.NonNullFunction; import com.tterrag.registrate.util.nullness.NonNullSupplier; import net.minecraft.block.Block; import net.minecraft.block.Block.Properties; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.IForgeRegistryEntry; -public class PalettesRegistrate extends AbstractRegistrate { +public class PalettesRegistrate extends CreateRegistrateBase { - /** - * Create a new {@link PalettesRegistrate} and register event listeners for - * registration and data generation. Used in lieu of adding side-effects to - * constructor, so that alternate initialization strategies can be done in - * subclasses. - * - * @param modid The mod ID for which objects will be registered - * @return The {@link PalettesRegistrate} instance - */ - public static PalettesRegistrate create(String modid) { - return new PalettesRegistrate(modid).registerEventListeners(FMLJavaModLoadingContext.get() - .getModEventBus()) - .itemGroup(() -> Create.palettesCreativeTab); + protected PalettesRegistrate(String modid) { + super(modid, () -> Create.palettesCreativeTab); } public static NonNullLazyValue lazy(String modid) { - return new NonNullLazyValue<>(() -> create(modid)); + return new NonNullLazyValue<>(() -> new PalettesRegistrate(modid)); } public BlockBuilder baseBlock(String name, - NonNullFunction factory, NonNullSupplier propertiesFrom) { + NonNullFunction factory, NonNullSupplier propertiesFrom) { return super.block(name, factory).initialProperties(propertiesFrom) - .blockstate((c, p) -> { - final String location = "block/palettes/" + c.getName() + "/plain"; - p.simpleBlock(c.get(), p.models() - .cubeAll(c.getName(), p.modLoc(location))); - }) - .simpleItem(); + .blockstate((c, p) -> { + final String location = "block/palettes/" + c.getName() + "/plain"; + p.simpleBlock(c.get(), p.models() + .cubeAll(c.getName(), p.modLoc(location))); + }) + .simpleItem(); } - - protected PalettesRegistrate(String modid) { - super(modid); - } - + @Override - protected , T extends R> RegistryEntry accept(String name, - Class type, Builder builder, NonNullSupplier creator) { - RegistryEntry ret = super.accept(name, type, builder, creator); - Create.registrate() - .addToSection(ret, Sections.PALETTES); - return ret; + public Sections currentSection() { + return Sections.PALETTES; } } diff --git a/src/main/java/com/simibubi/create/modules/palettes/VerticalCTGlassBlock.java b/src/main/java/com/simibubi/create/modules/palettes/VerticalCTGlassBlock.java deleted file mode 100644 index 4c2a67f38..000000000 --- a/src/main/java/com/simibubi/create/modules/palettes/VerticalCTGlassBlock.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.simibubi.create.modules.palettes; - -import com.simibubi.create.AllCTs; -import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; -import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; -import com.simibubi.create.foundation.block.connected.StandardCTBehaviour; - -import net.minecraft.block.BlockState; -import net.minecraft.util.Direction; - -public class VerticalCTGlassBlock extends CTGlassBlock { - - public VerticalCTGlassBlock(AllCTs spriteShift, boolean hasAlpha) { - super(spriteShift, hasAlpha); - } - - @Override - public ConnectedTextureBehaviour createBehaviour(CTSpriteShiftEntry spriteShift) { - return new StandardCTBehaviour(spriteShift) { - @Override - public CTSpriteShiftEntry get(BlockState state, Direction direction) { - if (direction.getAxis().isVertical()) - return null; - return super.get(state, direction); - } - }; - } - -} diff --git a/src/main/java/com/simibubi/create/modules/palettes/WindowBlock.java b/src/main/java/com/simibubi/create/modules/palettes/WindowBlock.java new file mode 100644 index 000000000..7160e202c --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/palettes/WindowBlock.java @@ -0,0 +1,25 @@ +package com.simibubi.create.modules.palettes; + +import net.minecraft.block.BlockState; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.util.Direction; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +public class WindowBlock extends ConnectedGlassBlock { + + public WindowBlock(Properties p_i48392_1_) { + super(p_i48392_1_); + } + + @Override + @OnlyIn(Dist.CLIENT) + public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) { + return adjacentBlockState.getBlock() instanceof ConnectedGlassBlock + ? (!RenderTypeLookup.canRenderInLayer(state, RenderType.getTranslucent()) && side.getAxis() + .isHorizontal() || state.getBlock() == adjacentBlockState.getBlock()) + : super.isSideInvisible(state, adjacentBlockState, side); + } + +} diff --git a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicTableScreen.java b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicTableScreen.java index b052ee6d7..304a85c11 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicTableScreen.java +++ b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicTableScreen.java @@ -24,16 +24,16 @@ import com.simibubi.create.modules.schematics.ClientSchematicLoader; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.IHasContainer; import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.util.Util; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.client.model.data.EmptyModelData; public class SchematicTableScreen extends AbstractSimiContainerScreen - implements IHasContainer { + implements IHasContainer { private ScrollInput schematicsArea; private IconButton confirmButton; @@ -52,7 +52,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen availableSchematics = schematicSender.getAvailableSchematics(); @@ -198,7 +209,9 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen