diff --git a/build.gradle b/build.gradle index 4f6712fe1..d17b34cd1 100644 --- a/build.gradle +++ b/build.gradle @@ -97,7 +97,7 @@ configurations { dependencies { minecraft 'net.minecraftforge:forge:1.15.2-31.1.36' - def registrate = "com.tterrag.registrate:Registrate:MC1.15.2-0.0.3.8" + def registrate = "com.tterrag.registrate:Registrate:MC1.15.2-0.0.3.9" implementation fg.deobf(registrate) shade registrate diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 056137c83..017a2de3b 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -87,7 +87,8 @@ 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; -import com.tterrag.registrate.util.RegistryEntry; +import com.tterrag.registrate.util.entry.BlockEntry; +import com.tterrag.registrate.util.entry.RegistryEntry; import com.tterrag.registrate.util.nullness.NonNullBiConsumer; import com.tterrag.registrate.util.nullness.NonNullBiFunction; import com.tterrag.registrate.util.nullness.NonNullFunction; @@ -334,8 +335,8 @@ public enum AllBlocks implements NonNullSupplier { NO_BLOCKITEM, WALL, FENCE, FENCE_GATE, SLAB, STAIRS } - public final RegistryEntry block; - public final ImmutableList> alsoRegistered; + public final BlockEntry block; + public final ImmutableList> alsoRegistered; public final Sections section; AllBlocks(Sections section) { @@ -371,7 +372,7 @@ public enum AllBlocks implements NonNullSupplier { .transform(applyTags(tags)).transform(b -> registerItemBlock(b, customItemCreator, comesWith)) .register(); - ImmutableList.Builder> alsoRegistered = ImmutableList.builder(); + ImmutableList.Builder> alsoRegistered = ImmutableList.builder(); for (ComesWith with : comesWith) { if (with != ComesWith.NO_BLOCKITEM) { alsoRegistered.add(makeRelatedBlock(this.block, with)); @@ -413,7 +414,7 @@ public enum AllBlocks implements NonNullSupplier { return state.getBlock() == get(); } - private RegistryEntry makeRelatedBlock(RegistryEntry block, ComesWith feature) { + private BlockEntry makeRelatedBlock(RegistryEntry block, ComesWith feature) { NonNullFunction creator; final Tag tag; diff --git a/src/main/java/com/simibubi/create/AllBlocksNew.java b/src/main/java/com/simibubi/create/AllBlocksNew.java index 9f3fff496..8012ae2d3 100644 --- a/src/main/java/com/simibubi/create/AllBlocksNew.java +++ b/src/main/java/com/simibubi/create/AllBlocksNew.java @@ -2,8 +2,6 @@ package com.simibubi.create; import static com.simibubi.create.modules.Sections.SCHEMATICS; -import java.util.function.Supplier; - import com.simibubi.create.foundation.utility.data.BlockStateGen; import com.simibubi.create.modules.Sections; import com.simibubi.create.modules.contraptions.relays.elementary.CogWheelBlock; @@ -12,13 +10,10 @@ 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.SchematicTableBlock; import com.simibubi.create.modules.schematics.block.SchematicannonBlock; -import com.tterrag.registrate.util.RegistryEntry; +import com.tterrag.registrate.util.entry.BlockEntry; -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; public class AllBlocksNew { @@ -29,86 +24,58 @@ public class AllBlocksNew { } public static final BlockEntry SCHEMATICANNON = - REGISTRATE.block("schematicannon", SchematicannonBlock::new, b -> b + REGISTRATE.block("schematicannon", SchematicannonBlock::new) .initialProperties(() -> Blocks.DISPENSER) .blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), BlockStateGen.partialBaseModel(ctx, prov))) .item() .model(BlockStateGen::customItemModel) .build() - .register()); + .register(); public static final BlockEntry SCHEMATIC_TABLE = - REGISTRATE.block("schematic_table", SchematicTableBlock::new, b -> b + REGISTRATE.block("schematic_table", SchematicTableBlock::new) .initialProperties(() -> Blocks.LECTERN) .blockstate((ctx, prov) -> prov.horizontalBlock(ctx.getEntry(), prov.models() .getExistingFile(ctx.getId()), 0)) .simpleItem() - .register()); + .register(); static { REGISTRATE.startSection(Sections.KINETICS); } - public static final BlockEntry SHAFT = REGISTRATE.block("shaft", ShaftBlock::new, b -> b + public static final BlockEntry SHAFT = REGISTRATE.block("shaft", ShaftBlock::new) .initialProperties(SharedProperties::kinetic) .blockstate((c, p) -> BlockStateGen.axisKineticBlock(c, p, BlockStateGen.standardModel(c, p))) .simpleItem() - .register()); + .register(); - public static final BlockEntry COGWHEEL = REGISTRATE.block("cogwheel", CogWheelBlock::small, b -> b + public static final BlockEntry 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()); + .register(); public static final BlockEntry LARGE_COGWHEEL = - REGISTRATE.block("large_cogwheel", CogWheelBlock::large, b -> b + 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()); + .register(); public static final BlockEntry ENCASED_SHAFT = - REGISTRATE.block("encased_shaft", EncasedShaftBlock::new, b -> b + 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()); + .register(); public static void register() { } - - public static class BlockEntry implements Supplier { - - private RegistryEntry delegate; - - public BlockEntry(RegistryEntry entry) { - this.delegate = entry; - } - - public boolean typeOf(BlockState state) { - return get() == state.getBlock(); - } - - public ItemStack asStack() { - return new ItemStack(get()); - } - - public BlockState getDefault() { - return get().getDefaultState(); - } - - @Override - public B get() { - return delegate.get(); - } - - } - } diff --git a/src/main/java/com/simibubi/create/CreateItemGroup.java b/src/main/java/com/simibubi/create/CreateItemGroup.java index 360a09daf..a9f24a52b 100644 --- a/src/main/java/com/simibubi/create/CreateItemGroup.java +++ b/src/main/java/com/simibubi/create/CreateItemGroup.java @@ -1,7 +1,7 @@ package com.simibubi.create; import com.simibubi.create.foundation.item.IAddedByOther; -import com.tterrag.registrate.util.RegistryEntry; +import com.tterrag.registrate.util.entry.RegistryEntry; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/simibubi/create/CreateRegistrate.java b/src/main/java/com/simibubi/create/CreateRegistrate.java index 1f062d2c5..51a59d6e4 100644 --- a/src/main/java/com/simibubi/create/CreateRegistrate.java +++ b/src/main/java/com/simibubi/create/CreateRegistrate.java @@ -6,15 +6,11 @@ import java.util.Map.Entry; 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.RegistryEntry; -import com.tterrag.registrate.util.nullness.NonNullFunction; +import com.tterrag.registrate.util.entry.RegistryEntry; 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; @@ -64,12 +60,6 @@ public class CreateRegistrate extends AbstractRegistrate { return ret; } - // TODO: find a better way to wrap the registry entries - public AllBlocksNew.BlockEntry block(String name, NonNullFunction factory, - NonNullFunction, RegistryEntry> registerFunc) { - return new AllBlocksNew.BlockEntry(registerFunc.apply(super.block(name, factory))); - } - public Sections getSection(RegistryEntry entry) { return sectionLookup.getOrDefault(entry, Sections.UNASSIGNED); } 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 5e484c685..13d5e322d 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 @@ -17,7 +17,7 @@ public abstract class AnimatedKinetics implements IDrawable { } protected BlockState shaft(Axis axis) { - return AllBlocksNew.SHAFT.getDefault().with(BlockStateProperties.AXIS, axis); + return AllBlocksNew.SHAFT.getDefaultState().with(BlockStateProperties.AXIS, axis); } protected AllBlockPartials cogwheel() { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonTileEntityRenderer.java index 0c80000d3..a9e81d5e6 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonTileEntityRenderer.java @@ -17,7 +17,7 @@ public class MechanicalPistonTileEntityRenderer extends KineticTileEntityRendere @Override protected BlockState getRenderedBlockState(KineticTileEntity te) { - return AllBlocksNew.SHAFT.getDefault().with(BlockStateProperties.AXIS, + return AllBlocksNew.SHAFT.getDefaultState().with(BlockStateProperties.AXIS, ((IRotate) te.getBlockState().getBlock()).getRotationAxis(te.getBlockState())); } 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 9df178d1c..adcd960ec 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 @@ -139,7 +139,7 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer protected BlockState getRenderedBlockState(KineticTileEntity te) { BlockState state = te.getBlockState(); - return AllBlocksNew.SHAFT.getDefault().with(AXIS, ((IRotate) state.getBlock()).getRotationAxis(state)); + return AllBlocksNew.SHAFT.getDefaultState().with(AXIS, ((IRotate) state.getBlock()).getRotationAxis(state)); } } 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 37f122b25..fb1eec01e 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 @@ -30,7 +30,7 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer items) { 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 7b045d2bd..5bbafa21f 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 @@ -96,7 +96,7 @@ public class CogwheelBlockItem extends BlockItem { continue; if (blockState.get(CogWheelBlock.AXIS) != axis) continue; - if (AllBlocksNew.LARGE_COGWHEEL.typeOf(blockState) == large) + if (AllBlocksNew.LARGE_COGWHEEL.has(blockState) == large) continue; AllTriggers.triggerFor(AllTriggers.SHIFTING_GEARS, player); } 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 fd8642d97..36f4e026b 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 @@ -66,7 +66,7 @@ public class ShaftBlock extends RotatedPillarKineticBlock { } public static boolean isShaft(BlockState state) { - return AllBlocksNew.SHAFT.typeOf(state); + return AllBlocksNew.SHAFT.has(state); } // IRotate: 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 453e9719b..f84638507 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 @@ -16,7 +16,7 @@ public class EncasedShaftTileEntityRenderer extends KineticTileEntityRenderer { @Override protected BlockState getRenderedBlockState(KineticTileEntity te) { - return AllBlocksNew.SHAFT.getDefault().with(BlockStateProperties.AXIS, + return AllBlocksNew.SHAFT.getDefaultState().with(BlockStateProperties.AXIS, te.getBlockState().get(BlockStateProperties.AXIS)); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeTileEntityRenderer.java index 88a8be2ed..f4e2a3ce0 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeTileEntityRenderer.java @@ -60,7 +60,7 @@ public class GaugeTileEntityRenderer extends KineticTileEntityRenderer { @Override protected BlockState getRenderedBlockState(KineticTileEntity te) { - return AllBlocksNew.SHAFT.getDefault().with(BlockStateProperties.AXIS, + return AllBlocksNew.SHAFT.getDefaultState().with(BlockStateProperties.AXIS, ((IRotate) te.getBlockState().getBlock()).getRotationAxis(te.getBlockState())); } diff --git a/src/main/java/com/simibubi/create/modules/schematics/block/LaunchedItem.java b/src/main/java/com/simibubi/create/modules/schematics/block/LaunchedItem.java index 8ef4cd460..9019d0cbd 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/block/LaunchedItem.java +++ b/src/main/java/com/simibubi/create/modules/schematics/block/LaunchedItem.java @@ -152,7 +152,7 @@ public abstract class LaunchedItem { BlockPos offset = BeltBlock.nextSegmentPosition(state, BlockPos.ZERO, isStart); int i = length - 1; Axis axis = state.get(BeltBlock.HORIZONTAL_FACING).rotateY().getAxis(); - world.setBlockState(target, AllBlocksNew.SHAFT.getDefault().with(ShaftBlock.AXIS, axis)); + world.setBlockState(target, AllBlocksNew.SHAFT.getDefaultState().with(ShaftBlock.AXIS, axis)); BeltConnectorItem .createBelts(world, target, target.add(offset.getX() * i, offset.getY() * i, offset.getZ() * i)); } diff --git a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonTileEntity.java index 65d3bca0e..de6d1d252 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonTileEntity.java @@ -504,7 +504,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC } if (!isLastSegment) blockState = (blockState.get(BeltBlock.PART) == Part.MIDDLE) ? Blocks.AIR.getDefaultState() - : AllBlocksNew.SHAFT.getDefault().with(ShaftBlock.AXIS, facing.rotateY().getAxis()); + : AllBlocksNew.SHAFT.getDefaultState().with(ShaftBlock.AXIS, facing.rotateY().getAxis()); return blockState; }