mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-24 14:06:42 +01:00
Update Registrate, remove now-unnecessary support code for block entries
This commit is contained in:
parent
3eee3d2c87
commit
7832e79b13
19 changed files with 38 additions and 80 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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<Block> {
|
|||
NO_BLOCKITEM, WALL, FENCE, FENCE_GATE, SLAB, STAIRS
|
||||
}
|
||||
|
||||
public final RegistryEntry<? extends Block> block;
|
||||
public final ImmutableList<RegistryEntry<? extends Block>> alsoRegistered;
|
||||
public final BlockEntry<? extends Block> block;
|
||||
public final ImmutableList<BlockEntry<? extends Block>> alsoRegistered;
|
||||
public final Sections section;
|
||||
|
||||
AllBlocks(Sections section) {
|
||||
|
@ -371,7 +372,7 @@ public enum AllBlocks implements NonNullSupplier<Block> {
|
|||
.transform(applyTags(tags)).transform(b -> registerItemBlock(b, customItemCreator, comesWith))
|
||||
.register();
|
||||
|
||||
ImmutableList.Builder<RegistryEntry<? extends Block>> alsoRegistered = ImmutableList.builder();
|
||||
ImmutableList.Builder<BlockEntry<? extends Block>> 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<Block> {
|
|||
return state.getBlock() == get();
|
||||
}
|
||||
|
||||
private RegistryEntry<? extends Block> makeRelatedBlock(RegistryEntry<? extends Block> block, ComesWith feature) {
|
||||
private BlockEntry<? extends Block> makeRelatedBlock(RegistryEntry<? extends Block> block, ComesWith feature) {
|
||||
NonNullFunction<Block.Properties, ? extends Block> creator;
|
||||
final Tag<Block> tag;
|
||||
|
||||
|
|
|
@ -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<SchematicannonBlock> 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<SchematicTableBlock> 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<ShaftBlock> SHAFT = REGISTRATE.block("shaft", ShaftBlock::new, b -> b
|
||||
public static final BlockEntry<ShaftBlock> 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<CogWheelBlock> COGWHEEL = REGISTRATE.block("cogwheel", CogWheelBlock::small, b -> b
|
||||
public static final BlockEntry<CogWheelBlock> 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<CogWheelBlock> 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<EncasedShaftBlock> 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<B extends Block> implements Supplier<B> {
|
||||
|
||||
private RegistryEntry<B> delegate;
|
||||
|
||||
public BlockEntry(RegistryEntry<B> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<CreateRegistrate> {
|
|||
return ret;
|
||||
}
|
||||
|
||||
// TODO: find a better way to wrap the registry entries
|
||||
public <T extends Block> AllBlocksNew.BlockEntry<T> block(String name, NonNullFunction<Properties, T> factory,
|
||||
NonNullFunction<BlockBuilder<T, CreateRegistrate>, RegistryEntry<T>> registerFunc) {
|
||||
return new AllBlocksNew.BlockEntry<T>(registerFunc.apply(super.block(name, factory)));
|
||||
}
|
||||
|
||||
public Sections getSection(RegistryEntry<?> entry) {
|
||||
return sectionLookup.getOrDefault(entry, Sections.UNASSIGNED);
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer<DeployerT
|
|||
BlockState state = te.getBlockState();
|
||||
if (!AllBlocks.DEPLOYER.typeOf(state))
|
||||
return Blocks.AIR.getDefaultState();
|
||||
return AllBlocksNew.SHAFT.getDefault().with(AXIS, ((IRotate) state.getBlock()).getRotationAxis(state));
|
||||
return AllBlocksNew.SHAFT.getDefaultState().with(AXIS, ((IRotate) state.getBlock()).getRotationAxis(state));
|
||||
}
|
||||
|
||||
private static SuperByteBuffer renderAndTransform(World world, AllBlockPartials renderBlock,
|
||||
|
|
|
@ -39,7 +39,7 @@ public class MechanicalPressTileEntityRenderer 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(HORIZONTAL_FACING).getAxis());
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public class SawTileEntityRenderer extends SafeTileEntityRenderer<SawTileEntity>
|
|||
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer<SpeedContro
|
|||
private SuperByteBuffer getRotatedModel(SpeedControllerTileEntity te) {
|
||||
BlockState state = te.getBlockState();
|
||||
return CreateClient.bufferCache.renderBlockIn(KineticTileEntityRenderer.KINETIC_TILE,
|
||||
AllBlocksNew.SHAFT.getDefault().with(ShaftBlock.AXIS, state.get(SpeedControllerBlock.HORIZONTAL_AXIS)));
|
||||
AllBlocksNew.SHAFT.getDefaultState().with(ShaftBlock.AXIS, state.get(SpeedControllerBlock.HORIZONTAL_AXIS)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
|||
drops.addAll(AllBlocks.BRASS_CASING.getDefault().getDrops(builder));
|
||||
TileEntity tileEntity = builder.get(LootParameters.BLOCK_ENTITY);
|
||||
if (tileEntity instanceof BeltTileEntity && ((BeltTileEntity) tileEntity).hasPulley())
|
||||
drops.addAll(AllBlocksNew.SHAFT.getDefault().getDrops(builder));
|
||||
drops.addAll(AllBlocksNew.SHAFT.getDefaultState().getDrops(builder));
|
||||
return drops;
|
||||
}
|
||||
|
||||
|
@ -504,7 +504,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
|||
}
|
||||
|
||||
BlockState shaftState =
|
||||
AllBlocksNew.SHAFT.getDefault().with(BlockStateProperties.AXIS, getRotationAxis(currentState));
|
||||
AllBlocksNew.SHAFT.getDefaultState().with(BlockStateProperties.AXIS, getRotationAxis(currentState));
|
||||
world.setBlockState(currentPos, hasPulley ? shaftState : Blocks.AIR.getDefaultState(), 3);
|
||||
world.playEvent(2001, currentPos, Block.getStateId(currentState));
|
||||
}
|
||||
|
|
|
@ -91,11 +91,11 @@ public class CogWheelBlock extends ShaftBlock {
|
|||
}
|
||||
|
||||
public static boolean isSmallCog(BlockState state) {
|
||||
return AllBlocksNew.COGWHEEL.typeOf(state);
|
||||
return AllBlocksNew.COGWHEEL.has(state);
|
||||
}
|
||||
|
||||
public static boolean isLargeCog(BlockState state) {
|
||||
return AllBlocksNew.LARGE_COGWHEEL.typeOf(state);
|
||||
return AllBlocksNew.LARGE_COGWHEEL.has(state);
|
||||
}
|
||||
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue