Connected Textures and Registrate

- CT behaviour is no longer tied to blocks implementing interfaces
- Custom models and connected textures can now be assigned in a custom blockbuider
- Ported framed glass to Palette Registrate
This commit is contained in:
simibubi 2020-05-13 21:56:46 +02:00
parent bf57058e4e
commit 7536e22eed
54 changed files with 793 additions and 693 deletions

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "create:block/framed_glass"
}
}
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "create:block/horizontal_framed_glass"
}
}
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "create:block/vertical_framed_glass"
}
}
}

View file

@ -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",

View file

@ -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",

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "create:block/palettes/framed_glass"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "create:block/palettes/framed_glass"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "create:block/palettes/framed_glass"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "create:block/framed_glass"
}

View file

@ -0,0 +1,3 @@
{
"parent": "create:block/horizontal_framed_glass"
}

View file

@ -0,0 +1,3 @@
{
"parent": "create:block/vertical_framed_glass"
}

View file

@ -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<Block> {
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<Block> {
_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(

View file

@ -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<SchematicannonBlock> 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<SchematicTableBlock> 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<ShaftBlock> SHAFT = REGISTRATE.block("shaft", ShaftBlock::new)
.initialProperties(SharedProperties::kinetic)
.blockstate(BlockStateGen.axisBlockProvider(false))
.simpleItem()
.register();
public static final BlockEntry<ShaftBlock> SHAFT = REGISTRATE.createBlock("shaft", ShaftBlock::new)
.initialProperties(SharedProperties::kinetic)
.blockstate(BlockStateGen.axisBlockProvider(false))
.simpleItem()
.register();
public static final BlockEntry<CogWheelBlock> COGWHEEL = REGISTRATE.block("cogwheel", CogWheelBlock::small)
public static final BlockEntry<CogWheelBlock> 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<CogWheelBlock> 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<CogWheelBlock> 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<EncasedShaftBlock> 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<GearboxBlock> 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<ClutchBlock> 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<GearboxBlock> GEARBOX = REGISTRATE.createBlock("gearbox", GearboxBlock::new)
.initialProperties(SharedProperties::kinetic)
.blockstate(BlockStateGen.axisBlockProvider(true))
.item()
.model(AssetLookup::customItemModel)
.build()
.register();
public static final BlockEntry<GearshiftBlock> 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<ClutchBlock> 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<GearshiftBlock> 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() {}
}

View file

@ -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);
}
}

View file

@ -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();

View file

@ -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<ResourceLocation, IBakedModel> 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<ModelResourceLocation> getAllBlockStateModelLocations(AllBlocks block) {
protected static List<ModelResourceLocation> getAllBlockStateModelLocations(Block block) {
List<ModelResourceLocation> 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 <T extends IBakedModel> void swapModels(Map<ResourceLocation, IBakedModel> modelRegistry,
ModelResourceLocation location, Function<IBakedModel, T> factory) {
ModelResourceLocation location, Function<IBakedModel, T> factory) {
modelRegistry.put(location, factory.apply(modelRegistry.get(location)));
}
@OnlyIn(Dist.CLIENT)
protected static <T extends IBakedModel> void swapModels(Map<ResourceLocation, IBakedModel> modelRegistry,
List<ModelResourceLocation> locations, Function<IBakedModel, T> factory) {
List<ModelResourceLocation> locations, Function<IBakedModel, T> factory) {
locations.forEach(location -> {
swapModels(modelRegistry, location, factory);
});
}
public static CustomBlockModels getCustomBlockModels() {
if (customBlockModels == null)
customBlockModels = new CustomBlockModels();
return customBlockModels;
}
}

View file

@ -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<CreateRegistrate> {
/**
* 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<CreateRegistrate> lazy(String modid) {
return new NonNullLazyValue<>(() -> create(modid));
}
protected CreateRegistrate(String modid) {
super(modid);
}
private Map<RegistryEntry<?>, Sections> sectionLookup = new IdentityHashMap<>();
private Sections section;
public CreateRegistrate startSection(Sections section) {
this.section = section;
return self();
}
public Sections currentSection() {
return section;
}
@Override
protected <R extends IForgeRegistryEntry<R>, T extends R> RegistryEntry<T> accept(String name,
Class<? super R> type, Builder<R, T, ?, ?> builder, NonNullSupplier<? extends T> creator) {
RegistryEntry<T> 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);
}
}

View file

@ -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<IBakedModel> {
}
}
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;

View file

@ -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;
}
}
}

View file

@ -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<Integer, Integer> 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;
}
}

View file

@ -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);
}
}

View file

@ -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<CTSpriteShiftEntry> getAllCTShifts() {
if (topShift == null)
return Arrays.asList(layerShift);
return Arrays.asList(layerShift, topShift);
}
}

View file

@ -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);
}
}

View file

@ -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<Pair<Supplier<? extends Block>, NonNullFunction<IBakedModel, ? extends IBakedModel>>> registered;
private Map<Block, NonNullFunction<IBakedModel, ? extends IBakedModel>> customModels;
public CustomBlockModels() {
registered = new ArrayList<>();
customModels = new IdentityHashMap<>();
}
public void register(Supplier<? extends Block> entry,
NonNullFunction<IBakedModel, ? extends IBakedModel> behaviour) {
registered.add(Pair.of(entry, behaviour));
}
public void foreach(NonNullBiConsumer<Block, NonNullFunction<IBakedModel, ? extends IBakedModel>> 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()));
}
}

View file

@ -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<ResourceLocation, TextureAtlasSprite> textureMap = Minecraft.getInstance().getSpriteAtlas(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
Function<ResourceLocation, TextureAtlasSprite> textureMap = Minecraft.getInstance()
.getSpriteAtlas(PlayerContainer.BLOCK_ATLAS_TEXTURE);
original = textureMap.apply(originalTextureLocation);
target = textureMap.apply(targetTextureLocation);
}

View file

@ -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<T extends Block, P> extends BlockBuilder<T, P> {
private List<NonNullConsumer<BlockEntry<T>>> registerCallbacks;
protected CreateBlockBuilder(AbstractRegistrate<?> owner, P parent, String name, BuilderCallback callback,
NonNullFunction<Properties, T> factory, NonNullSupplier<Properties> initialProperties) {
super(owner, parent, name, callback, factory, initialProperties);
registerCallbacks = new LinkedList<>();
}
public static <T extends Block, P> CreateBlockBuilder<T, P> create(AbstractRegistrate<?> owner, P parent,
String name, BuilderCallback callback, NonNullFunction<Block.Properties, T> factory, Material material) {
return (CreateBlockBuilder<T, P>) new CreateBlockBuilder<>(owner, parent, name, callback, factory,
() -> Block.Properties.create(material)).defaultBlockstate()
.defaultLoot()
.defaultLang();
}
public CreateBlockBuilder<T, P> connectedTextures(ConnectedTextureBehaviour behaviour) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> registerConnectedTexture(behaviour));
return this;
}
public CreateBlockBuilder<T, P> onRegister(NonNullConsumer<BlockEntry<T>> callback) {
registerCallbacks.add(callback);
return this;
}
@Override
public BlockEntry<T> register() {
BlockEntry<T> 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<IBakedModel, ? extends IBakedModel> modelFunc) {
onRegister(entry -> CreateClient.getCustomBlockModels().register(entry, modelFunc));
}
}

View file

@ -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<CreateRegistrate> {
/**
* 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<CreateRegistrate> lazy(String modid) {
return new NonNullLazyValue<>(() -> new CreateRegistrate(modid));
}
}

View file

@ -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<C extends AbstractRegistrate<C>> extends AbstractRegistrate<C> {
protected CreateRegistrateBase(String modid, NonNullSupplier<ItemGroup> creativeTab) {
super(modid);
registerEventListeners(FMLJavaModLoadingContext.get()
.getModEventBus());
itemGroup(creativeTab);
}
private static Map<RegistryEntry<?>, Sections> sectionLookup = new IdentityHashMap<>();
private Sections section;
public void startSection(Sections section) {
this.section = section;
}
public Sections currentSection() {
return section;
}
@Override
protected <R extends IForgeRegistryEntry<R>, T extends R> RegistryEntry<T> accept(String name,
Class<? super R> type, Builder<R, T, ?, ?> builder, NonNullSupplier<? extends T> creator) {
RegistryEntry<T> ret = super.accept(name, type, builder, creator);
sectionLookup.put(ret, currentSection());
return ret;
}
@SuppressWarnings("unchecked")
public <T extends Block, P> CreateBlockBuilder<T, P> createBlock(String name,
NonNullFunction<Block.Properties, T> factory) {
return (CreateBlockBuilder<T, P>) super.block(name, factory);
}
@Override
public <T extends Block, P> CreateBlockBuilder<T, P> block(P parent, String name,
NonNullFunction<Block.Properties, T> 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<ConnectedGlassBlock> 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();
}
}

View file

@ -18,36 +18,42 @@ import net.minecraftforge.client.model.generators.ModelFile;
public class BlockStateGen {
public static <T extends Block> NonNullBiConsumer<DataGenContext<Block, T>, 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 <T extends Block> void axisBlock(DataGenContext<Block, T> ctx, RegistrateBlockstateProvider prov,
Function<BlockState, ModelFile> modelFunc) {
Function<BlockState, ModelFile> 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 <T extends Block> void cubeAll(DataGenContext<Block, T> ctx, RegistrateBlockstateProvider prov,
String texturePath) {
String textureSubDir) {
cubeAll(ctx, prov, textureSubDir, ctx.getName());
}
public static <T extends Block> void cubeAll(DataGenContext<Block, T> 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 <T extends Block> void pavedBlock(DataGenContext<Block, T> 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());
}
}

View file

@ -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()));
}
}

View file

@ -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");

View file

@ -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");

View file

@ -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<MechanicalCrafterTileEntity>, IHaveConnectedTextures {
public class MechanicalCrafterBlock extends HorizontalKineticBlock implements ITE<MechanicalCrafterTileEntity> {
public static final EnumProperty<Pointing> 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<MechanicalCrafterTileEntity> getTileEntityClass() {
return MechanicalCrafterTileEntity.class;

View file

@ -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;

View file

@ -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

View file

@ -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<ConnectedGlassBlock> FRAMED_GLASS =
REGISTRATE.framedGlass("framed_glass", new StandardCTBehaviour(AllCTs.FRAMED_GLASS.get()));
public static final BlockEntry<ConnectedGlassBlock> HORIZONTAL_FRAMED_GLASS =
REGISTRATE.framedGlass("horizontal_framed_glass",
new HorizontalCTBehaviour(AllCTs.HORIZONTAL_FRAMED_GLASS.get(), AllCTs.FRAMED_GLASS.get()));
public static final BlockEntry<ConnectedGlassBlock> 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<SandBlock> 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<SandBlock> LIMESAND =
REGISTRATE.createBlock("limesand", p -> new SandBlock(0xD7D7C7, p))
.initialProperties(() -> Blocks.SAND)
.blockstate(palettesCubeAll())
.register();
public static final BlockEntry<Block> LIMESTONE =
REGISTRATE.baseBlock("limestone", Block::new, () -> Blocks.SANDSTONE)
@ -68,10 +91,11 @@ public class AllPaletteBlocks {
.simpleItem()
.register());
public static final BlockEntry<ScoriaBlock> 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<ScoriaBlock> NATURAL_SCORIA =
REGISTRATE.createBlock("natural_scoria", ScoriaBlock::new)
.initialProperties(() -> Blocks.ANDESITE)
.blockstate(palettesCubeAll())
.register();
public static final BlockEntry<Block> SCORIA = REGISTRATE.baseBlock("scoria", Block::new, () -> Blocks.ANDESITE)
.register();
@ -92,4 +116,7 @@ public class AllPaletteBlocks {
public static void register() {}
private static <T extends Block> NonNullBiConsumer<DataGenContext<Block, T>, RegistrateBlockstateProvider> palettesCubeAll() {
return (c, p) -> BlockStateGen.cubeAll(c, p, "palettes/");
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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());
}
}

View file

@ -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<CTSpriteShiftEntry> getAllCTShifts() {
if (topShift == null)
return Arrays.asList(layerShift);
return Arrays.asList(layerShift, topShift);
}
}
}

View file

@ -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());
}
}

View file

@ -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<PalettesRegistrate> {
public class PalettesRegistrate extends CreateRegistrateBase<PalettesRegistrate> {
/**
* 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<PalettesRegistrate> lazy(String modid) {
return new NonNullLazyValue<>(() -> create(modid));
return new NonNullLazyValue<>(() -> new PalettesRegistrate(modid));
}
public <T extends Block> BlockBuilder<T, PalettesRegistrate> baseBlock(String name,
NonNullFunction<Properties, T> factory, NonNullSupplier<Block> propertiesFrom) {
NonNullFunction<Properties, T> factory, NonNullSupplier<Block> 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 <R extends IForgeRegistryEntry<R>, T extends R> RegistryEntry<T> accept(String name,
Class<? super R> type, Builder<R, T, ?, ?> builder, NonNullSupplier<? extends T> creator) {
RegistryEntry<T> ret = super.accept(name, type, builder, creator);
Create.registrate()
.addToSection(ret, Sections.PALETTES);
return ret;
public Sections currentSection() {
return Sections.PALETTES;
}
}

View file

@ -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);
}
};
}
}

View file

@ -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);
}
}

View file

@ -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<SchematicTableContainer>
implements IHasContainer<SchematicTableContainer> {
implements IHasContainer<SchematicTableContainer> {
private ScrollInput schematicsArea;
private IconButton confirmButton;
@ -52,7 +52,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
private float lastChasingProgress;
public SchematicTableScreen(SchematicTableContainer container, PlayerInventory playerInventory,
ITextComponent title) {
ITextComponent title) {
super(container, playerInventory, title);
}
@ -71,8 +71,10 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
schematicsLabel = new Label(mainLeft + 36, mainTop + 26, "").withShadow();
schematicsLabel.text = "";
if (!availableSchematics.isEmpty()) {
schematicsArea = new SelectionScrollInput(mainLeft + 33, mainTop + 23, 134, 14)
.forOptions(availableSchematics).titled(availableSchematicsTitle).writingTo(schematicsLabel);
schematicsArea =
new SelectionScrollInput(mainLeft + 33, mainTop + 23, 134, 14).forOptions(availableSchematics)
.titled(availableSchematicsTitle)
.writingTo(schematicsLabel);
widgets.add(schematicsArea);
widgets.add(schematicsLabel);
}
@ -101,12 +103,14 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
int mainTop = guiTop - 16;
ScreenResources.PLAYER_INVENTORY.draw(this, x - 16, y + 70 + 14);
font.drawString(playerInventory.getDisplayName().getFormattedText(), x - 15 + 7, y + 64 + 26, 0x666666);
font.drawString(playerInventory.getDisplayName()
.getFormattedText(), x - 15 + 7, y + 64 + 26, 0x666666);
SCHEMATIC_TABLE.draw(this, mainLeft, mainTop);
if (container.getTileEntity().isUploading)
font.drawString(uploading, mainLeft + 76, mainTop + 10, ScreenResources.FONT_COLOR);
else if (container.getSlot(1).getHasStack())
else if (container.getSlot(1)
.getHasStack())
font.drawString(finished, mainLeft + 60, mainTop + 10, ScreenResources.FONT_COLOR);
else
font.drawString(title, mainLeft + 60, mainTop + 10, ScreenResources.FONT_COLOR);
@ -115,13 +119,14 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
font.drawStringWithShadow(noSchematics, mainLeft + 39, mainTop + 26, 0xFFDD44);
}
minecraft.getTextureManager().bindTexture(SCHEMATIC_TABLE_PROGRESS.location);
minecraft.getTextureManager()
.bindTexture(SCHEMATIC_TABLE_PROGRESS.location);
int width = (int) (SCHEMATIC_TABLE_PROGRESS.width
* MathHelper.lerp(partialTicks, lastChasingProgress, chasingProgress));
* MathHelper.lerp(partialTicks, lastChasingProgress, chasingProgress));
int height = SCHEMATIC_TABLE_PROGRESS.height;
RenderSystem.disableLighting();
blit(mainLeft + 94, mainTop + 56, SCHEMATIC_TABLE_PROGRESS.startX, SCHEMATIC_TABLE_PROGRESS.startY, width,
height);
height);
RenderSystem.pushMatrix();
@ -137,10 +142,15 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
RenderSystem.rotatef(50, -.5f, 1, -.2f);
RenderSystem.scaled(50, -50, 50);
Minecraft.getInstance().getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
minecraft.getBlockRendererDispatcher().renderBlock(AllBlocksNew.SCHEMATIC_TABLE.get().getDefaultState(),
new MatrixStack(), getMinecraft().getBufferBuilders().getEntityVertexConsumers(), 0xF000F0,
OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE);
Minecraft.getInstance()
.getTextureManager()
.bindTexture(PlayerContainer.BLOCK_ATLAS_TEXTURE);
minecraft.getBlockRendererDispatcher()
.renderBlock(AllBlocksNew.SCHEMATIC_TABLE.get()
.getDefaultState(), new MatrixStack(),
getMinecraft().getBufferBuilders()
.getEntityVertexConsumers(),
0xF000F0, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE);
RenderSystem.disableAlphaTest();
RenderSystem.disableRescaleNormal();
@ -151,7 +161,8 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
@Override
public void tick() {
super.tick();
boolean finished = container.getSlot(1).getHasStack();
boolean finished = container.getSlot(1)
.getHasStack();
if (container.getTileEntity().isUploading || finished) {
if (finished) {
@ -189,7 +200,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
ClientSchematicLoader schematicSender = CreateClient.schematicSender;
if (confirmButton.active && confirmButton.isHovered() && ((SchematicTableContainer) container).canWrite()
&& schematicsArea != null) {
&& schematicsArea != null) {
lastChasingProgress = chasingProgress = progress = 0;
List<String> availableSchematics = schematicSender.getAvailableSchematics();
@ -198,7 +209,9 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
}
if (folderButton.isHovered()) {
Util.getOSType().openFile(Paths.get("schematics/").toFile());
Util.getOSType()
.openFile(Paths.get("schematics/")
.toFile());
}
if (refreshButton.isHovered()) {
@ -208,7 +221,9 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
if (!availableSchematics.isEmpty()) {
schematicsArea = new SelectionScrollInput(guiLeft - 56 + 33, guiTop - 16 + 23, 134, 14)
.forOptions(availableSchematics).titled(availableSchematicsTitle).writingTo(schematicsLabel);
.forOptions(availableSchematics)
.titled(availableSchematicsTitle)
.writingTo(schematicsLabel);
widgets.add(schematicsArea);
} else {
schematicsArea = null;

View file

@ -25,9 +25,9 @@ import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RegionRenderCacheBuilder;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.inventory.container.PlayerContainer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.client.ForgeHooksClient;
@ -92,7 +92,9 @@ public class SchematicRenderer {
RenderSystem.enableAlphaTest();
RenderSystem.enableBlend();
Minecraft.getInstance().getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
Minecraft.getInstance()
.getTextureManager()
.bindTexture(PlayerContainer.BLOCK_ATLAS_TEXTURE);
for (RenderType layer : RenderType.getBlockLayers()) {
if (!usedBlockRenderLayers.contains(layer)) {

View file

@ -1,5 +0,0 @@
{
"variants": {
"": { "model": "create:block/palettes/framed_glass" }
}
}

View file

@ -1,5 +0,0 @@
{
"variants": {
"": { "model": "create:block/palettes/framed_glass" }
}
}

View file

@ -1,5 +0,0 @@
{
"variants": {
"": { "model": "create:block/palettes/framed_glass" }
}
}

View file

@ -1,6 +0,0 @@
{
"parent": "block/cube_all",
"textures": {
"all": "create:block/framed_glass"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B