diff --git a/build.gradle b/build.gradle index cd336ef30..4f6712fe1 100644 --- a/build.gradle +++ b/build.gradle @@ -53,7 +53,7 @@ minecraft { property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP' property 'forge.logging.console.level', 'debug' property 'fml.earlyprogresswindow', 'false' - args '--mod', 'create', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources') + args '--mod', 'create', '--client', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources') mods { create { source sourceSets.main diff --git a/src/generated/resources/assets/create/blockstates/cogwheel.json b/src/generated/resources/assets/create/blockstates/cogwheel.json new file mode 100644 index 000000000..ff5735b7d --- /dev/null +++ b/src/generated/resources/assets/create/blockstates/cogwheel.json @@ -0,0 +1,16 @@ +{ + "variants": { + "axis=x": { + "model": "create:block/cogwheel", + "x": 90, + "y": 90 + }, + "axis=y": { + "model": "create:block/cogwheel" + }, + "axis=z": { + "model": "create:block/cogwheel", + "x": 90 + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/blockstates/encased_shaft.json b/src/generated/resources/assets/create/blockstates/encased_shaft.json new file mode 100644 index 000000000..36ed2c8ee --- /dev/null +++ b/src/generated/resources/assets/create/blockstates/encased_shaft.json @@ -0,0 +1,16 @@ +{ + "variants": { + "axis=x": { + "model": "create:block/encased_shaft/block", + "x": 90, + "y": 90 + }, + "axis=y": { + "model": "create:block/encased_shaft/block" + }, + "axis=z": { + "model": "create:block/encased_shaft/block", + "x": 90 + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/blockstates/large_cogwheel.json b/src/generated/resources/assets/create/blockstates/large_cogwheel.json new file mode 100644 index 000000000..6c1b017c6 --- /dev/null +++ b/src/generated/resources/assets/create/blockstates/large_cogwheel.json @@ -0,0 +1,16 @@ +{ + "variants": { + "axis=x": { + "model": "create:block/large_cogwheel", + "x": 90, + "y": 90 + }, + "axis=y": { + "model": "create:block/large_cogwheel" + }, + "axis=z": { + "model": "create:block/large_cogwheel", + "x": 90 + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/blockstates/schematicannon.json b/src/generated/resources/assets/create/blockstates/schematicannon.json index 98cce083b..293ef7572 100644 --- a/src/generated/resources/assets/create/blockstates/schematicannon.json +++ b/src/generated/resources/assets/create/blockstates/schematicannon.json @@ -1,7 +1,7 @@ { "variants": { "": { - "model": "create:block/schematicannon/base" + "model": "create:block/schematicannon/block" } } } \ No newline at end of file diff --git a/src/generated/resources/assets/create/blockstates/shaft.json b/src/generated/resources/assets/create/blockstates/shaft.json new file mode 100644 index 000000000..05a711a6e --- /dev/null +++ b/src/generated/resources/assets/create/blockstates/shaft.json @@ -0,0 +1,16 @@ +{ + "variants": { + "axis=x": { + "model": "create:block/shaft", + "x": 90, + "y": 90 + }, + "axis=y": { + "model": "create:block/shaft" + }, + "axis=z": { + "model": "create:block/shaft", + "x": 90 + } + } +} \ 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 cd2c76fa9..2e017b080 100644 --- a/src/generated/resources/assets/create/lang/en_ud.json +++ b/src/generated/resources/assets/create/lang/en_ud.json @@ -1,4 +1,5 @@ { + "block.create.cogwheel": "\u05DF\u01DD\u01DD\u0265\u028Dbo\u0186", "block.create.creative_crate": "\u01DD\u0287\u0250\u0279\u0186 \u01DD\u028C\u0131\u0287\u0250\u01DD\u0279\u0186", "block.create.dark_scoria_bricks_slab": "q\u0250\u05DFS s\u029E\u0254\u0131\u0279\u15FA \u0250\u0131\u0279o\u0254S \u029E\u0279\u0250\u15E1", "block.create.dark_scoria_bricks_stairs": "s\u0279\u0131\u0250\u0287S s\u029E\u0254\u0131\u0279\u15FA \u0250\u0131\u0279o\u0254S \u029E\u0279\u0250\u15E1", @@ -8,12 +9,14 @@ "block.create.dolomite_slab": "q\u0250\u05DFS \u01DD\u0287\u0131\u026Fo\u05DFo\u15E1", "block.create.dolomite_stairs": "s\u0279\u0131\u0250\u0287S \u01DD\u0287\u0131\u026Fo\u05DFo\u15E1", "block.create.dolomite_wall": "\u05DF\u05DF\u0250M \u01DD\u0287\u0131\u026Fo\u05DFo\u15E1", + "block.create.encased_shaft": "\u0287\u025F\u0250\u0265S p\u01DDs\u0250\u0254u\u018E", "block.create.gabbro_bricks_stairs": "s\u0279\u0131\u0250\u0287S s\u029E\u0254\u0131\u0279\u15FA o\u0279qq\u0250\u2141", "block.create.gabbro_bricks_wall": "\u05DF\u05DF\u0250M s\u029E\u0254\u0131\u0279\u15FA o\u0279qq\u0250\u2141", "block.create.gabbro_slab": "q\u0250\u05DFS o\u0279qq\u0250\u2141", "block.create.gabbro_stairs": "s\u0279\u0131\u0250\u0287S o\u0279qq\u0250\u2141", "block.create.gabbro_wall": "\u05DF\u05DF\u0250M o\u0279qq\u0250\u2141", "block.create.indented_gabbro_slab": "q\u0250\u05DFS o\u0279qq\u0250\u2141 p\u01DD\u0287u\u01DDpuI", + "block.create.large_cogwheel": "\u05DF\u01DD\u01DD\u0265\u028Dbo\u0186 \u01DDb\u0279\u0250\uA780", "block.create.limestone_bricks_slab": "q\u0250\u05DFS s\u029E\u0254\u0131\u0279\u15FA \u01DDuo\u0287s\u01DD\u026F\u0131\uA780", "block.create.limestone_bricks_stairs": "s\u0279\u0131\u0250\u0287S s\u029E\u0254\u0131\u0279\u15FA \u01DDuo\u0287s\u01DD\u026F\u0131\uA780", "block.create.limestone_bricks_wall": "\u05DF\u05DF\u0250M s\u029E\u0254\u0131\u0279\u15FA \u01DDuo\u0287s\u01DD\u026F\u0131\uA780", @@ -29,6 +32,7 @@ "block.create.scoria_slab": "q\u0250\u05DFS \u0250\u0131\u0279o\u0254S", "block.create.scoria_stairs": "s\u0279\u0131\u0250\u0287S \u0250\u0131\u0279o\u0254S", "block.create.scoria_wall": "\u05DF\u05DF\u0250M \u0250\u0131\u0279o\u0254S", + "block.create.shaft": "\u0287\u025F\u0250\u0265S", "block.create.weathered_limestone_bricks_slab": "q\u0250\u05DFS s\u029E\u0254\u0131\u0279\u15FA \u01DDuo\u0287s\u01DD\u026F\u0131\uA780 p\u01DD\u0279\u01DD\u0265\u0287\u0250\u01DDM", "block.create.weathered_limestone_bricks_stairs": "s\u0279\u0131\u0250\u0287S s\u029E\u0254\u0131\u0279\u15FA \u01DDuo\u0287s\u01DD\u026F\u0131\uA780 p\u01DD\u0279\u01DD\u0265\u0287\u0250\u01DDM", "block.create.weathered_limestone_bricks_wall": "\u05DF\u05DF\u0250M s\u029E\u0254\u0131\u0279\u15FA \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 69c7e745c..1ee2e27b6 100644 --- a/src/generated/resources/assets/create/lang/en_us.json +++ b/src/generated/resources/assets/create/lang/en_us.json @@ -1,4 +1,5 @@ { + "block.create.cogwheel": "Cogwheel", "block.create.creative_crate": "Creative Crate", "block.create.dark_scoria_bricks_slab": "Dark Scoria Bricks Slab", "block.create.dark_scoria_bricks_stairs": "Dark Scoria Bricks Stairs", @@ -8,12 +9,14 @@ "block.create.dolomite_slab": "Dolomite Slab", "block.create.dolomite_stairs": "Dolomite Stairs", "block.create.dolomite_wall": "Dolomite Wall", + "block.create.encased_shaft": "Encased Shaft", "block.create.gabbro_bricks_stairs": "Gabbro Bricks Stairs", "block.create.gabbro_bricks_wall": "Gabbro Bricks Wall", "block.create.gabbro_slab": "Gabbro Slab", "block.create.gabbro_stairs": "Gabbro Stairs", "block.create.gabbro_wall": "Gabbro Wall", "block.create.indented_gabbro_slab": "Indented Gabbro Slab", + "block.create.large_cogwheel": "Large Cogwheel", "block.create.limestone_bricks_slab": "Limestone Bricks Slab", "block.create.limestone_bricks_stairs": "Limestone Bricks Stairs", "block.create.limestone_bricks_wall": "Limestone Bricks Wall", @@ -29,6 +32,7 @@ "block.create.scoria_slab": "Scoria Slab", "block.create.scoria_stairs": "Scoria Stairs", "block.create.scoria_wall": "Scoria Wall", + "block.create.shaft": "Shaft", "block.create.weathered_limestone_bricks_slab": "Weathered Limestone Bricks Slab", "block.create.weathered_limestone_bricks_stairs": "Weathered Limestone Bricks Stairs", "block.create.weathered_limestone_bricks_wall": "Weathered Limestone Bricks Wall", diff --git a/src/generated/resources/assets/create/models/item/cogwheel.json b/src/generated/resources/assets/create/models/item/cogwheel.json new file mode 100644 index 000000000..16377e46c --- /dev/null +++ b/src/generated/resources/assets/create/models/item/cogwheel.json @@ -0,0 +1,3 @@ +{ + "parent": "create:block/cogwheel" +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/models/item/encased_shaft.json b/src/generated/resources/assets/create/models/item/encased_shaft.json new file mode 100644 index 000000000..479412d0e --- /dev/null +++ b/src/generated/resources/assets/create/models/item/encased_shaft.json @@ -0,0 +1,3 @@ +{ + "parent": "create:block/encased_shaft/item" +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/models/item/large_cogwheel.json b/src/generated/resources/assets/create/models/item/large_cogwheel.json new file mode 100644 index 000000000..1d97dd7b9 --- /dev/null +++ b/src/generated/resources/assets/create/models/item/large_cogwheel.json @@ -0,0 +1,3 @@ +{ + "parent": "create:block/large_cogwheel" +} \ No newline at end of file diff --git a/src/generated/resources/assets/create/models/item/schematicannon.json b/src/generated/resources/assets/create/models/item/schematicannon.json index 8c3c48b30..98a189b7f 100644 --- a/src/generated/resources/assets/create/models/item/schematicannon.json +++ b/src/generated/resources/assets/create/models/item/schematicannon.json @@ -1,3 +1,3 @@ { - "parent": "create:block/schematicannon/base" + "parent": "create:block/schematicannon/item" } \ No newline at end of file diff --git a/src/generated/resources/assets/create/models/item/shaft.json b/src/generated/resources/assets/create/models/item/shaft.json new file mode 100644 index 000000000..ba560cdde --- /dev/null +++ b/src/generated/resources/assets/create/models/item/shaft.json @@ -0,0 +1,3 @@ +{ + "parent": "create:block/shaft" +} \ 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 f1cb5a459..d772890a8 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -50,13 +50,9 @@ import com.simibubi.create.modules.contraptions.redstone.ContactBlock; import com.simibubi.create.modules.contraptions.relays.advanced.SpeedControllerBlock; import com.simibubi.create.modules.contraptions.relays.advanced.sequencer.SequencedGearshiftBlock; import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock; -import com.simibubi.create.modules.contraptions.relays.elementary.CogWheelBlock; -import com.simibubi.create.modules.contraptions.relays.elementary.CogwheelBlockItem; -import com.simibubi.create.modules.contraptions.relays.elementary.ShaftBlock; import com.simibubi.create.modules.contraptions.relays.encased.AdjustablePulleyBlock; import com.simibubi.create.modules.contraptions.relays.encased.ClutchBlock; import com.simibubi.create.modules.contraptions.relays.encased.EncasedBeltBlock; -import com.simibubi.create.modules.contraptions.relays.encased.EncasedShaftBlock; import com.simibubi.create.modules.contraptions.relays.encased.GearshiftBlock; import com.simibubi.create.modules.contraptions.relays.gauge.GaugeBlock; import com.simibubi.create.modules.contraptions.relays.gearbox.GearboxBlock; @@ -122,13 +118,14 @@ public enum AllBlocks implements NonNullSupplier { _1_(Sections.KINETICS), - SHAFT(() -> new ShaftBlock(Properties.from(Blocks.ANDESITE))), - COGWHEEL(() -> new CogWheelBlock(false), (b, p) -> new CogwheelBlockItem(b, p, false)), - LARGE_COGWHEEL(() -> new CogWheelBlock(true), (b, p) -> new CogwheelBlockItem(b, p, true)), - ENCASED_SHAFT(EncasedShaftBlock::new), +// SHAFT(() -> new ShaftBlock(Properties.from(Blocks.ANDESITE))), +// COGWHEEL(() -> new CogWheelBlock(false), (b, p) -> new CogwheelBlockItem(b, p, false)), +// LARGE_COGWHEEL(() -> new CogWheelBlock(true), (b, p) -> new CogwheelBlockItem(b, p, true)), +// ENCASED_SHAFT(EncasedShaftBlock::new), GEARBOX(GearboxBlock::new), CLUTCH(ClutchBlock::new), GEARSHIFT(GearshiftBlock::new), + ENCASED_BELT(EncasedBeltBlock::new), ADJUSTABLE_PULLEY(AdjustablePulleyBlock::new), BELT(BeltBlock::new, ComesWith.NO_BLOCKITEM), diff --git a/src/main/java/com/simibubi/create/AllBlocksNew.java b/src/main/java/com/simibubi/create/AllBlocksNew.java index 2b4f8f9f8..2b9886edb 100644 --- a/src/main/java/com/simibubi/create/AllBlocksNew.java +++ b/src/main/java/com/simibubi/create/AllBlocksNew.java @@ -2,28 +2,39 @@ package com.simibubi.create; import static com.simibubi.create.modules.Sections.SCHEMATICS; +import com.simibubi.create.foundation.utility.data.BlockStateGen; +import com.simibubi.create.modules.Sections; +import com.simibubi.create.modules.contraptions.relays.elementary.CogWheelBlock; +import com.simibubi.create.modules.contraptions.relays.elementary.CogwheelBlockItem; +import com.simibubi.create.modules.contraptions.relays.elementary.ShaftBlock; +import com.simibubi.create.modules.contraptions.relays.encased.EncasedShaftBlock; import com.simibubi.create.modules.schematics.block.CreativeCrateBlock; import com.simibubi.create.modules.schematics.block.SchematicTableBlock; import com.simibubi.create.modules.schematics.block.SchematicannonBlock; import com.tterrag.registrate.util.RegistryEntry; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.block.SoundType; +import net.minecraft.item.ItemStack; +import net.minecraftforge.registries.IForgeRegistryEntry; public class AllBlocksNew { private static final CreateRegistrate REGISTRATE = Create.registrate(); - // Tools for strucuture movement and replication static { REGISTRATE.startSection(SCHEMATICS); } public static final RegistryEntry SCHEMATICANNON = REGISTRATE.block("schematicannon", SchematicannonBlock::new) .initialProperties(() -> Blocks.DISPENSER) - .blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), prov.models().getExistingFile(prov.modLoc("block/" + ctx.getName() + "/base")))) + .blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), BlockStateGen.partialBaseModel(ctx, prov))) .item() - .model((ctx, prov) -> prov.blockItem(ctx.getEntry()::getBlock, "/item")) + .model(BlockStateGen::customItemModel) .build() .register(); - + + public static final RegistryEntry CREATIVE_CRATE = REGISTRATE.block("creative_crate", CreativeCrateBlock::new) .initialProperties(() -> Blocks.CHEST) .blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), prov.models().getExistingFile(ctx.getId()))) @@ -35,6 +46,51 @@ public class AllBlocksNew { .blockstate((ctx, prov) -> prov.horizontalBlock(ctx.getEntry(), prov.models().getExistingFile(ctx.getId()), 0)) .simpleItem() .register(); - + + static { REGISTRATE.startSection(Sections.KINETICS); } + + public static final RegistryEntry SHAFT = REGISTRATE.block("shaft", ShaftBlock::new) + .initialProperties(SharedProperties::kinetic) + .blockstate((c, p) -> BlockStateGen.axisKineticBlock(c, p, BlockStateGen.standardModel(c, p))) + .simpleItem() + .register(); + + public static final RegistryEntry COGWHEEL = REGISTRATE.block("cogwheel", CogWheelBlock::small) + .initialProperties(SharedProperties::kinetic) + .properties(p -> p.sound(SoundType.WOOD)) + .blockstate((c, p) -> BlockStateGen.axisKineticBlock(c, p, BlockStateGen.standardModel(c, p))) + .item(CogwheelBlockItem::new).build() + .register(); + + public static final RegistryEntry LARGE_COGWHEEL = REGISTRATE.block("large_cogwheel", CogWheelBlock::large) + .initialProperties(SharedProperties::kinetic) + .properties(p -> p.sound(SoundType.WOOD)) + .blockstate((c, p) -> BlockStateGen.axisKineticBlock(c, p, BlockStateGen.standardModel(c, p))) + .item(CogwheelBlockItem::new).build() + .register(); + + public static final RegistryEntry ENCASED_SHAFT = REGISTRATE.block("encased_shaft", EncasedShaftBlock::new) + .initialProperties(SharedProperties::kinetic) + .blockstate((c, p) -> BlockStateGen.axisKineticBlock(c, p, BlockStateGen.partialBaseModel(c, p))) + .item() + .model(BlockStateGen::customItemModel) + .build() + .register(); + public static void register() {} + + // Ideally these following three methods would be part of the RegistryEntry instances + + public static > boolean equals(RegistryEntry entry, BlockState state) { + return entry.map(state.getBlock()::equals).get(); + } + + public static ItemStack asStack(RegistryEntry entry) { + return new ItemStack(entry.get()); + } + + public static BlockState getDefault(RegistryEntry entry) { + return entry.get().getDefaultState(); + } + } diff --git a/src/main/java/com/simibubi/create/AllEntities.java b/src/main/java/com/simibubi/create/AllEntities.java index 23d7e223b..1fd227817 100644 --- a/src/main/java/com/simibubi/create/AllEntities.java +++ b/src/main/java/com/simibubi/create/AllEntities.java @@ -67,6 +67,7 @@ public enum AllEntities { @SuppressWarnings("unchecked") // TODO 1.15 this generic stuff is incompatible with the enum system - need strong types @OnlyIn(value = Dist.CLIENT) public static void registerRenderers() { + RenderingRegistry.registerEntityRenderingHandler((EntityType) STATIONARY_CONTRAPTION.type, ContraptionEntityRenderer::new); RenderingRegistry.registerEntityRenderingHandler((EntityType) CONTRAPTION.type, ContraptionEntityRenderer::new); RenderingRegistry.registerEntityRenderingHandler((EntityType) SUPER_GLUE.type, SuperGlueRenderer::new); } diff --git a/src/main/java/com/simibubi/create/AllTileEntities.java b/src/main/java/com/simibubi/create/AllTileEntities.java index d2df8cd2f..a280c36e8 100644 --- a/src/main/java/com/simibubi/create/AllTileEntities.java +++ b/src/main/java/com/simibubi/create/AllTileEntities.java @@ -108,11 +108,11 @@ public enum AllTileEntities { SCHEMATICTABLE(SchematicTableTileEntity::new, AllBlocksNew.SCHEMATIC_TABLE), // Kinetics - SHAFT(ShaftTileEntity::new, AllBlocks.SHAFT, AllBlocks.COGWHEEL, AllBlocks.LARGE_COGWHEEL, AllBlocks.ENCASED_SHAFT), + SHAFT(ShaftTileEntity::new, AllBlocksNew.SHAFT, AllBlocksNew.COGWHEEL, AllBlocksNew.LARGE_COGWHEEL, AllBlocksNew.ENCASED_SHAFT), MOTOR(MotorTileEntity::new, AllBlocks.CREATIVE_MOTOR), GEARBOX(GearboxTileEntity::new, AllBlocks.GEARBOX), TURNTABLE(TurntableTileEntity::new, AllBlocks.TURNTABLE), - ENCASED_SHAFT(EncasedShaftTileEntity::new, AllBlocks.ENCASED_SHAFT, AllBlocks.ENCASED_BELT), + ENCASED_SHAFT(EncasedShaftTileEntity::new, AllBlocksNew.ENCASED_SHAFT, AllBlocks.ENCASED_BELT), ADJUSTABLE_PULLEY(AdjustablePulleyTileEntity::new, AllBlocks.ADJUSTABLE_PULLEY), ENCASED_FAN(EncasedFanTileEntity::new, AllBlocks.ENCASED_FAN), NOZZLE(NozzleTileEntity::new, AllBlocks.NOZZLE), diff --git a/src/main/java/com/simibubi/create/CreateItemGroup.java b/src/main/java/com/simibubi/create/CreateItemGroup.java index d6cb24cbc..fbcf9fd1d 100644 --- a/src/main/java/com/simibubi/create/CreateItemGroup.java +++ b/src/main/java/com/simibubi/create/CreateItemGroup.java @@ -23,7 +23,7 @@ public final class CreateItemGroup extends ItemGroup { @Override public ItemStack createIcon() { - return new ItemStack(AllBlocks.COGWHEEL.get()); + return AllBlocksNew.asStack(AllBlocksNew.COGWHEEL); } @Override diff --git a/src/main/java/com/simibubi/create/SharedProperties.java b/src/main/java/com/simibubi/create/SharedProperties.java new file mode 100644 index 000000000..3b20b2a97 --- /dev/null +++ b/src/main/java/com/simibubi/create/SharedProperties.java @@ -0,0 +1,12 @@ +package com.simibubi.create; + +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; + +public class SharedProperties { + + static Block kinetic() { + return Blocks.ANDESITE; + } + +} diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java index 63dd2cfa2..bf212b18a 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java @@ -1,14 +1,22 @@ package com.simibubi.create.compat.jei.category.animations; +import com.simibubi.create.AllBlocksNew; import com.simibubi.create.foundation.utility.AnimationTickHolder; import mezz.jei.api.gui.drawable.IDrawable; +import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; +import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.util.Direction.Axis; public abstract class AnimatedKinetics implements IDrawable { public static float getCurrentAngle() { return ((AnimationTickHolder.ticks + Minecraft.getInstance().getRenderPartialTicks()) * 4f) % 360; } + + protected BlockState shaft(Axis axis) { + return AllBlocksNew.getDefault(AllBlocksNew.SHAFT).with(BlockStateProperties.AXIS, axis); + } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedPress.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedPress.java index fbdd14a87..133e0e788 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedPress.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedPress.java @@ -5,6 +5,7 @@ import static com.simibubi.create.foundation.utility.AnimationTickHolder.ticks; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllBlocksNew; import com.simibubi.create.foundation.gui.ScreenElementRenderer; import net.minecraft.block.BlockState; @@ -17,11 +18,11 @@ import net.minecraft.util.Direction.Axis; public class AnimatedPress extends AnimatedKinetics { private boolean basin; - + public AnimatedPress(boolean basin) { this.basin = basin; } - + @Override public int getWidth() { return 50; @@ -53,7 +54,7 @@ public class AnimatedPress extends AnimatedKinetics { RenderSystem.pushMatrix(); ScreenElementRenderer.renderModel(this::head); RenderSystem.popMatrix(); - + if (basin) { RenderSystem.pushMatrix(); ScreenElementRenderer.renderBlock(this::basin); @@ -68,7 +69,7 @@ public class AnimatedPress extends AnimatedKinetics { RenderSystem.translatef(t, -t, -t); RenderSystem.rotatef(getCurrentAngle() * 2, 1, 0, 0); RenderSystem.translatef(-t, t, t); - return AllBlocks.SHAFT.get().getDefaultState().with(BlockStateProperties.AXIS, Axis.Z); + return AllBlocksNew.getDefault(AllBlocksNew.SHAFT).with(BlockStateProperties.AXIS, Axis.Z); } private BlockState body() { @@ -92,7 +93,7 @@ public class AnimatedPress extends AnimatedKinetics { RenderSystem.translated(0, -verticalOffset * 50, 0); return AllBlockPartials.MECHANICAL_PRESS_HEAD.get(); } - + private BlockState basin() { RenderSystem.translatef(0, 85, 0); return AllBlocks.BASIN.get().getDefaultState(); diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java index 12e7a048c..85d83d134 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java @@ -48,7 +48,7 @@ public class AnimatedSaw extends AnimatedKinetics { RenderSystem.translatef(t, -t, t); RenderSystem.rotatef(-getCurrentAngle() * 2, 0, 0, 1); RenderSystem.translatef(-t, t, -t); - return AllBlocks.SHAFT.get().getDefaultState().with(BlockStateProperties.AXIS, Axis.X); + return shaft(Axis.X); } private BlockState block() { 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 new file mode 100644 index 000000000..d3eaf3691 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/utility/data/BlockStateGen.java @@ -0,0 +1,60 @@ + +package com.simibubi.create.foundation.utility.data; + +import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock; +import com.tterrag.registrate.providers.DataGenContext; +import com.tterrag.registrate.providers.RegistrateBlockstateProvider; +import com.tterrag.registrate.providers.RegistrateItemModelProvider; +import com.tterrag.registrate.util.nullness.NonnullType; + +import net.minecraft.block.Block; +import net.minecraft.block.RotatedPillarBlock; +import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; +import net.minecraft.util.Direction.Axis; +import net.minecraftforge.client.model.generators.ItemModelBuilder; +import net.minecraftforge.client.model.generators.ModelFile.ExistingModelFile; +import net.minecraftforge.client.model.generators.VariantBlockStateBuilder; + +public class BlockStateGen { + + /** + * Equivalent to BlockStateProvider#axisBlock without the need for a + * RotatedPillarBlock instance + */ + public static VariantBlockStateBuilder axisKineticBlock( + DataGenContext ctx, RegistrateBlockstateProvider prov, ExistingModelFile model) { + RotatedPillarKineticBlock block = ctx.getEntry(); + return prov.getVariantBuilder(block).partialState().with(RotatedPillarBlock.AXIS, Axis.Y).modelForState() + .modelFile(model).addModel().partialState().with(RotatedPillarBlock.AXIS, Axis.Z).modelForState() + .modelFile(model).rotationX(90).addModel().partialState().with(RotatedPillarBlock.AXIS, Axis.X) + .modelForState().modelFile(model).rotationX(90).rotationY(90).addModel(); + } + + /** + * Custom block models packaged with other partials. Example: + * models/block/schematicannon/block.json + */ + public static ExistingModelFile partialBaseModel(@NonnullType DataGenContext ctx, + @NonnullType RegistrateBlockstateProvider prov) { + return prov.models().getExistingFile(prov.modLoc("block/" + ctx.getName() + "/block")); + } + + /** + * Custom block model from models/block/x.json + */ + public static ExistingModelFile standardModel(@NonnullType DataGenContext ctx, + @NonnullType RegistrateBlockstateProvider prov) { + return prov.models().getExistingFile(prov.modLoc("block/" + ctx.getName())); + } + + /** + * Generate item model inheriting from a seperate model in + * models/block/x/item.json + */ + public static ItemModelBuilder customItemModel(@NonnullType DataGenContext ctx, + @NonnullType RegistrateItemModelProvider prov) { + return prov.blockItem(ctx.getEntry()::getBlock, "/item"); + } + +} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/RotationPropagator.java b/src/main/java/com/simibubi/create/modules/contraptions/RotationPropagator.java index 55f24ce90..add7a990a 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/RotationPropagator.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/RotationPropagator.java @@ -1,7 +1,7 @@ package com.simibubi.create.modules.contraptions; import static com.simibubi.create.AllBlocks.BELT; -import static com.simibubi.create.AllBlocks.LARGE_COGWHEEL; +import static com.simibubi.create.modules.contraptions.relays.elementary.CogWheelBlock.isLargeCog; import static net.minecraft.state.properties.BlockStateProperties.AXIS; import java.util.LinkedList; @@ -90,18 +90,18 @@ public class RotationPropagator { } // Gear <-> Large Gear - if (LARGE_COGWHEEL.typeOf(stateFrom) && definitionTo.hasIntegratedCogwheel(world, to.getPos(), stateTo)) - if (isLargeToSmallGear(stateFrom, stateTo, definitionTo, diff)) + if (isLargeCog(stateFrom) && definitionTo.hasIntegratedCogwheel(world, to.getPos(), stateTo)) + if (isLargeToSmallCog(stateFrom, stateTo, definitionTo, diff)) return -2f; - if (LARGE_COGWHEEL.typeOf(stateTo) && definitionFrom.hasIntegratedCogwheel(world, from.getPos(), stateFrom)) - if (isLargeToSmallGear(stateTo, stateFrom, definitionFrom, diff)) + if (isLargeCog(stateTo) && definitionFrom.hasIntegratedCogwheel(world, from.getPos(), stateFrom)) + if (isLargeToSmallCog(stateTo, stateFrom, definitionFrom, diff)) return -.5f; // Gear <-> Gear if (connectedByGears) { if (diff.manhattanDistance(BlockPos.ZERO) != 1) return 0; - if (LARGE_COGWHEEL.typeOf(stateTo)) + if (isLargeCog(stateTo)) return 0; if (direction.getAxis() == definitionFrom.getRotationAxis(stateFrom)) return 0; @@ -118,9 +118,9 @@ public class RotationPropagator { final BlockPos diff = to.getPos().subtract(from.getPos()); // Rotation Speed Controller <-> Large Gear - if (isLargeGearToSpeedController(stateFrom, stateTo, diff)) + if (isLargeCogToSpeedController(stateFrom, stateTo, diff)) return SpeedControllerTileEntity.getConveyedSpeed(from, to, true); - if (isLargeGearToSpeedController(stateTo, stateFrom, diff)) + if (isLargeCogToSpeedController(stateTo, stateFrom, diff)) return SpeedControllerTileEntity.getConveyedSpeed(to, from, false); float rotationSpeedModifier = getRotationSpeedModifier(from, to); @@ -128,7 +128,7 @@ public class RotationPropagator { } private static boolean isLargeToLargeGear(BlockState from, BlockState to, BlockPos diff) { - if (!LARGE_COGWHEEL.typeOf(from) || !LARGE_COGWHEEL.typeOf(to)) + if (!isLargeCog(from) || !isLargeCog(to)) return false; Axis fromAxis = from.get(AXIS); Axis toAxis = to.get(AXIS); @@ -161,7 +161,7 @@ public class RotationPropagator { return 1; } - private static boolean isLargeToSmallGear(BlockState from, BlockState to, IRotate defTo, BlockPos diff) { + private static boolean isLargeToSmallCog(BlockState from, BlockState to, IRotate defTo, BlockPos diff) { Axis axisFrom = from.get(AXIS); if (axisFrom != defTo.getRotationAxis(to)) return false; @@ -176,8 +176,8 @@ public class RotationPropagator { return true; } - private static boolean isLargeGearToSpeedController(BlockState from, BlockState to, BlockPos diff) { - if (!LARGE_COGWHEEL.typeOf(from) || !AllBlocks.ROTATION_SPEED_CONTROLLER.typeOf(to)) + private static boolean isLargeCogToSpeedController(BlockState from, BlockState to, BlockPos diff) { + if (!isLargeCog(from) || !AllBlocks.ROTATION_SPEED_CONTROLLER.typeOf(to)) return false; if (!diff.equals(BlockPos.ZERO.up()) && !diff.equals(BlockPos.ZERO.down())) return false; @@ -301,7 +301,7 @@ public class RotationPropagator { TileEntity tileEntity = worldIn.getTileEntity(neighbourPos); if (!(tileEntity instanceof KineticTileEntity)) continue; - + final KineticTileEntity neighbourTE = (KineticTileEntity) tileEntity; if (!neighbourTE.hasSource() || !neighbourTE.source.equals(pos)) continue; @@ -383,9 +383,9 @@ public class RotationPropagator { final BlockState stateTo = to.getBlockState(); final BlockPos diff = to.getPos().subtract(from.getPos()); - if (isLargeGearToSpeedController(stateFrom, stateTo, diff)) + if (isLargeCogToSpeedController(stateFrom, stateTo, diff)) return true; - if (isLargeGearToSpeedController(stateTo, stateFrom, diff)) + if (isLargeCogToSpeedController(stateTo, stateFrom, diff)) return true; return getRotationSpeedModifier(from, to) != 0; } @@ -413,7 +413,7 @@ public class RotationPropagator { // Some Blocks can interface diagonally BlockState blockState = te.getBlockState(); - boolean isLargeWheel = LARGE_COGWHEEL.typeOf(blockState); + boolean isLargeWheel = isLargeCog(blockState); if (!(blockState.getBlock() instanceof IRotate)) return neighbours; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntityRenderer.java index ed4e4fe5c..fcf38b909 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntityRenderer.java @@ -2,7 +2,6 @@ package com.simibubi.create.modules.contraptions.base; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.simibubi.create.AllBlocks; import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.block.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -10,6 +9,7 @@ import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.SuperByteBufferCache.Compartment; import com.simibubi.create.modules.contraptions.KineticDebugger; +import com.simibubi.create.modules.contraptions.relays.elementary.CogWheelBlock; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -83,7 +83,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer { public HandCrankBlock() { - super(Properties.from(AllBlocks.COGWHEEL.get())); + super(Properties.from(Blocks.OAK_PLANKS)); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java index 80e3e0eec..4fa2b2d0f 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java @@ -11,6 +11,7 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllBlocksNew; import com.simibubi.create.foundation.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.block.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -138,7 +139,7 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer protected BlockState getRenderedBlockState(KineticTileEntity te) { BlockState state = te.getBlockState(); - return AllBlocks.SHAFT.get().getDefaultState().with(AXIS, ((IRotate) state.getBlock()).getRotationAxis(state)); + return AllBlocksNew.getDefault(AllBlocksNew.SHAFT).with(AXIS, ((IRotate) state.getBlock()).getRotationAxis(state)); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/SpeedControllerBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/SpeedControllerBlock.java index 44430f5e3..281b020d7 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/SpeedControllerBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/SpeedControllerBlock.java @@ -1,6 +1,5 @@ package com.simibubi.create.modules.contraptions.relays.advanced; -import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.utility.AllShapes; import com.simibubi.create.modules.contraptions.base.HorizontalAxisKineticBlock; import com.simibubi.create.modules.contraptions.relays.elementary.CogWheelBlock; @@ -34,7 +33,7 @@ public class SpeedControllerBlock extends HorizontalAxisKineticBlock { @Override public BlockState getStateForPlacement(BlockItemUseContext context) { BlockState above = context.getWorld().getBlockState(context.getPos().up()); - if (AllBlocks.LARGE_COGWHEEL.typeOf(above) && above.get(CogWheelBlock.AXIS).isHorizontal()) + if (CogWheelBlock.isLargeCog(above) && above.get(CogWheelBlock.AXIS).isHorizontal()) return getDefaultState().with(HORIZONTAL_AXIS, above.get(CogWheelBlock.AXIS) == Axis.X ? Axis.Z : Axis.X); return super.getStateForPlacement(context); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/SpeedControllerRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/SpeedControllerRenderer.java index e2d78df28..a37c6f80f 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/SpeedControllerRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/SpeedControllerRenderer.java @@ -1,7 +1,7 @@ package com.simibubi.create.modules.contraptions.relays.advanced; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllBlocksNew; import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.behaviour.base.SmartTileEntityRenderer; import com.simibubi.create.foundation.utility.SuperByteBuffer; @@ -30,7 +30,7 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer, IHaveColorHandler { +public class BeltBlock extends HorizontalKineticBlock implements ITE, IHaveColorHandler { public static final IProperty SLOPE = EnumProperty.create("slope", Slope.class); public static final IProperty PART = EnumProperty.create("part", Part.class); @@ -78,7 +78,8 @@ public class BeltBlock extends HorizontalKineticBlock return false; try { return getTileEntity(world, pos).hasPulley(); - } catch (TileEntityException e) {} + } catch (TileEntityException e) { + } return false; } @@ -106,7 +107,7 @@ public class BeltBlock extends HorizontalKineticBlock drops.addAll(AllBlocks.BRASS_CASING.getDefault().getDrops(builder)); TileEntity tileEntity = builder.get(LootParameters.BLOCK_ENTITY); if (tileEntity instanceof BeltTileEntity && ((BeltTileEntity) tileEntity).hasPulley()) - drops.addAll(AllBlocks.SHAFT.getDefault().getDrops(builder)); + drops.addAll(AllBlocksNew.getDefault(AllBlocksNew.SHAFT).getDrops(builder)); return drops; } @@ -199,7 +200,7 @@ public class BeltBlock extends HorizontalKineticBlock if (player.isSneaking() || !player.isAllowEdit()) return ActionResultType.PASS; ItemStack heldItem = player.getHeldItem(handIn); - boolean isShaft = heldItem.getItem() == AllBlocks.SHAFT.get().asItem(); + boolean isShaft = heldItem.getItem() == AllBlocksNew.SHAFT.get().asItem(); boolean isCasing = heldItem.getItem() == AllBlocks.BRASS_CASING.get().asItem(); boolean isDye = Tags.Items.DYES.contains(heldItem.getItem()); boolean isHand = heldItem.isEmpty() && handIn == Hand.MAIN_HAND; @@ -284,7 +285,7 @@ public class BeltBlock extends HorizontalKineticBlock belt.attachKinetics(); } if (!player.isCreative()) - player.inventory.placeItemBackInInventory(world, new ItemStack(AllBlocks.SHAFT.get())); + player.inventory.placeItemBackInInventory(world, AllBlocksNew.asStack(AllBlocksNew.SHAFT)); return ActionResultType.SUCCESS; } @@ -370,7 +371,8 @@ public class BeltBlock extends HorizontalKineticBlock return BeltShapes.getCollisionShape(state); } - } catch (TileEntityException e) {} + } catch (TileEntityException e) { + } return shape; } @@ -490,7 +492,7 @@ public class BeltBlock extends HorizontalKineticBlock } BlockState shaftState = - AllBlocks.SHAFT.get().getDefaultState().with(BlockStateProperties.AXIS, getRotationAxis(currentState)); + AllBlocksNew.getDefault(AllBlocksNew.SHAFT).with(BlockStateProperties.AXIS, getRotationAxis(currentState)); world.setBlockState(currentPos, hasPulley ? shaftState : Blocks.AIR.getDefaultState(), 3); world.playEvent(2001, currentPos, Block.getStateId(currentState)); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/item/BeltConnectorHandler.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/item/BeltConnectorHandler.java index 078ae6d02..c47b2c662 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/item/BeltConnectorHandler.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/item/BeltConnectorHandler.java @@ -4,9 +4,9 @@ import java.util.LinkedList; import java.util.List; import java.util.Random; -import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.config.AllConfigs; +import com.simibubi.create.modules.contraptions.relays.elementary.ShaftBlock; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; @@ -68,7 +68,7 @@ public class BeltConnectorHandler { if (world.getBlockState(selected).getMaterial().isReplaceable()) return; - if (!AllBlocks.SHAFT.typeOf(world.getBlockState(selected))) + if (!ShaftBlock.isShaft(world.getBlockState(selected))) selected = selected.offset(((BlockRayTraceResult) rayTrace).getFace()); if (!selected.withinDistance(first, AllConfigs.SERVER.kinetics.maxBeltLength.get())) return; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/item/BeltConnectorItem.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/item/BeltConnectorItem.java index fe4b44830..02934b59b 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/item/BeltConnectorItem.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/item/BeltConnectorItem.java @@ -106,7 +106,7 @@ public class BeltConnectorItem extends BlockItem implements IAddedByOther { for (BlockPos pos : beltsToCreate) { BeltBlock.Part part = pos.equals(start) ? Part.START : pos.equals(end) ? Part.END : Part.MIDDLE; - boolean pulley = AllBlocks.SHAFT.typeOf(world.getBlockState(pos)); + boolean pulley = ShaftBlock.isShaft(world.getBlockState(pos)); if (part == Part.MIDDLE && pulley) part = Part.PULLEY; world.setBlockState(pos, beltBlock.with(BeltBlock.SLOPE, slope).with(BeltBlock.PART, part) @@ -204,7 +204,7 @@ public class BeltConnectorItem extends BlockItem implements IAddedByOther { for (BlockPos currentPos = first.add(step); !currentPos.equals(second) && limit-- > 0; currentPos = currentPos.add(step)) { BlockState blockState = world.getBlockState(currentPos); - if (AllBlocks.SHAFT.typeOf(blockState) && blockState.get(ShaftBlock.AXIS) == axis) + if (ShaftBlock.isShaft(blockState) && blockState.get(ShaftBlock.AXIS) == axis) continue; if (!blockState.getMaterial().isReplaceable()) return false; @@ -217,7 +217,7 @@ public class BeltConnectorItem extends BlockItem implements IAddedByOther { public static boolean validateAxis(World world, BlockPos pos) { if (!world.isAreaLoaded(pos, 1)) return false; - if (!AllBlocks.SHAFT.typeOf(world.getBlockState(pos))) + if (!ShaftBlock.isShaft(world.getBlockState(pos))) return false; if (world.getBlockState(pos).get(BlockStateProperties.AXIS) == Axis.Y) return false; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogWheelBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogWheelBlock.java index 646af6a35..7ac0fd914 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogWheelBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogWheelBlock.java @@ -1,13 +1,13 @@ package com.simibubi.create.modules.contraptions.relays.elementary; import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllBlocksNew; import com.simibubi.create.foundation.utility.AllShapes; import com.simibubi.create.modules.contraptions.base.IRotate; import com.simibubi.create.modules.contraptions.relays.advanced.SpeedControllerBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; @@ -23,10 +23,18 @@ import net.minecraft.world.World; public class CogWheelBlock extends ShaftBlock { - private boolean isLarge; + boolean isLarge; - public CogWheelBlock(boolean large) { - super(Properties.from(Blocks.GRANITE)); + public static CogWheelBlock small(Properties properties) { + return new CogWheelBlock(false, properties); + } + + public static CogWheelBlock large(Properties properties) { + return new CogWheelBlock(true, properties); + } + + private CogWheelBlock(boolean large, Properties properties) { + super(properties); isLarge = large; } @@ -42,7 +50,7 @@ public class CogWheelBlock extends ShaftBlock { continue; BlockState blockState = worldIn.getBlockState(pos.offset(facing)); - if (AllBlocks.LARGE_COGWHEEL.typeOf(blockState) || isLarge && AllBlocks.COGWHEEL.typeOf(blockState)) + if (isLargeCog(blockState) || isLarge && isSmallCog(blockState)) return false; } return true; @@ -81,6 +89,14 @@ public class CogWheelBlock extends ShaftBlock { public float getParticleInitialRadius() { return isLarge ? 1f : .75f; } + + public static boolean isSmallCog(BlockState state) { + return AllBlocksNew.equals(AllBlocksNew.COGWHEEL, state); + } + + public static boolean isLargeCog(BlockState state) { + return AllBlocksNew.equals(AllBlocksNew.LARGE_COGWHEEL, state); + } public void fillItemGroup(ItemGroup group, NonNullList items) { items.add(new ItemStack(this)); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogwheelBlockItem.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogwheelBlockItem.java index ef1f12939..907025a45 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogwheelBlockItem.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogwheelBlockItem.java @@ -1,9 +1,7 @@ package com.simibubi.create.modules.contraptions.relays.elementary; -import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItemUseContext; @@ -18,9 +16,9 @@ public class CogwheelBlockItem extends BlockItem { boolean large; - public CogwheelBlockItem(Block block, Properties builder, boolean isLarge) { + public CogwheelBlockItem(CogWheelBlock block, Properties builder) { super(block, builder); - large = isLarge; + large = block.isLarge; } @Override @@ -34,7 +32,7 @@ public class CogwheelBlockItem extends BlockItem { if (face.getAxis() == placedOnState.get(CogWheelBlock.AXIS)) return super.tryPlace(context); - boolean placedOnLarge = AllBlocks.LARGE_COGWHEEL.typeOf(placedOnState); + boolean placedOnLarge = CogWheelBlock.isLargeCog(placedOnState); if (placedOnLarge || large) { boolean largeOnLarge = placedOnLarge && large; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/ShaftBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/ShaftBlock.java index 236cb7b45..1a083a50a 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/ShaftBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/ShaftBlock.java @@ -1,5 +1,6 @@ package com.simibubi.create.modules.contraptions.relays.elementary; +import com.simibubi.create.AllBlocksNew; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.utility.AllShapes; import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock; @@ -65,6 +66,10 @@ public class ShaftBlock extends RotatedPillarKineticBlock { super.fillItemGroup(group, items); AllItems.BELT_CONNECTOR.get().fillItemGroup(group, items); } + + public static boolean isShaft(BlockState state) { + return AllBlocksNew.equals(AllBlocksNew.SHAFT, state); + } // IRotate: diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftBlock.java index 5887fec71..620f84795 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftBlock.java @@ -3,7 +3,6 @@ package com.simibubi.create.modules.contraptions.relays.encased; import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock; import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; import net.minecraft.block.material.PushReaction; import net.minecraft.item.BlockItemUseContext; import net.minecraft.tileentity.TileEntity; @@ -15,8 +14,8 @@ import net.minecraft.world.IWorldReader; public class EncasedShaftBlock extends RotatedPillarKineticBlock { - public EncasedShaftBlock() { - super(Properties.from(Blocks.ANDESITE)); + public EncasedShaftBlock(Properties properties) { + super(properties); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftTileEntityRenderer.java index 3a6d788c0..e0400836e 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftTileEntityRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.modules.contraptions.relays.encased; -import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllBlocksNew; import com.simibubi.create.modules.contraptions.base.KineticTileEntity; import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer; @@ -16,7 +16,7 @@ public class EncasedShaftTileEntityRenderer extends KineticTileEntityRenderer { @Override protected BlockState getRenderedBlockState(KineticTileEntity te) { - return AllBlocks.SHAFT.get().getDefaultState().with(BlockStateProperties.AXIS, + return AllBlocksNew.getDefault(AllBlocksNew.SHAFT).with(BlockStateProperties.AXIS, te.getBlockState().get(BlockStateProperties.AXIS)); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/GearshiftBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/GearshiftBlock.java index c9e17daea..a0acd3d04 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/GearshiftBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/GearshiftBlock.java @@ -9,6 +9,7 @@ import com.simibubi.create.modules.contraptions.relays.gearbox.GearshiftTileEnti import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer.Builder; @@ -27,7 +28,7 @@ public class GearshiftBlock extends EncasedShaftBlock implements ITE