Config shenanigans & Terraforged support

- Serverconfig now registers together with the others
- Added missing stress config entries for components without a default stress impact greater than zero
- bumped version
- Tagged stone variants from Create palettes to generate in a terraforged world type
This commit is contained in:
simibubi 2020-06-05 13:02:11 +02:00
parent cfdc9d0a5e
commit 9005eae338
12 changed files with 94 additions and 33 deletions

View file

@ -16,7 +16,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
version = 'mc1.15.2_v0.2.3' version = 'mc1.15.2_v0.2.4'
group = 'com.simibubi.create' group = 'com.simibubi.create'
archivesBaseName = 'create' archivesBaseName = 'create'

View file

@ -151,12 +151,14 @@ public class AllBlocks {
public static final BlockEntry<ShaftBlock> SHAFT = REGISTRATE.block("shaft", ShaftBlock::new) public static final BlockEntry<ShaftBlock> SHAFT = REGISTRATE.block("shaft", ShaftBlock::new)
.initialProperties(SharedProperties::stone) .initialProperties(SharedProperties::stone)
.transform(StressConfigDefaults.setNoImpact())
.blockstate(BlockStateGen.axisBlockProvider(false)) .blockstate(BlockStateGen.axisBlockProvider(false))
.simpleItem() .simpleItem()
.register(); .register();
public static final BlockEntry<CogWheelBlock> COGWHEEL = REGISTRATE.block("cogwheel", CogWheelBlock::small) public static final BlockEntry<CogWheelBlock> COGWHEEL = REGISTRATE.block("cogwheel", CogWheelBlock::small)
.initialProperties(SharedProperties::stone) .initialProperties(SharedProperties::stone)
.transform(StressConfigDefaults.setNoImpact())
.properties(p -> p.sound(SoundType.WOOD)) .properties(p -> p.sound(SoundType.WOOD))
.blockstate(BlockStateGen.axisBlockProvider(false)) .blockstate(BlockStateGen.axisBlockProvider(false))
.item(CogwheelBlockItem::new) .item(CogwheelBlockItem::new)
@ -167,6 +169,7 @@ public class AllBlocks {
REGISTRATE.block("large_cogwheel", CogWheelBlock::large) REGISTRATE.block("large_cogwheel", CogWheelBlock::large)
.initialProperties(SharedProperties::stone) .initialProperties(SharedProperties::stone)
.properties(p -> p.sound(SoundType.WOOD)) .properties(p -> p.sound(SoundType.WOOD))
.transform(StressConfigDefaults.setNoImpact())
.blockstate(BlockStateGen.axisBlockProvider(false)) .blockstate(BlockStateGen.axisBlockProvider(false))
.item(CogwheelBlockItem::new) .item(CogwheelBlockItem::new)
.build() .build()
@ -176,6 +179,7 @@ public class AllBlocks {
REGISTRATE.block("encased_shaft", EncasedShaftBlock::new) REGISTRATE.block("encased_shaft", EncasedShaftBlock::new)
.initialProperties(SharedProperties::stone) .initialProperties(SharedProperties::stone)
.properties(p -> p.nonOpaque()) .properties(p -> p.nonOpaque())
.transform(StressConfigDefaults.setNoImpact())
.blockstate(BlockStateGen.axisBlockProvider(true)) .blockstate(BlockStateGen.axisBlockProvider(true))
.item() .item()
.transform(customItemModel()) .transform(customItemModel())
@ -184,6 +188,7 @@ public class AllBlocks {
public static final BlockEntry<GearboxBlock> GEARBOX = REGISTRATE.block("gearbox", GearboxBlock::new) public static final BlockEntry<GearboxBlock> GEARBOX = REGISTRATE.block("gearbox", GearboxBlock::new)
.initialProperties(SharedProperties::stone) .initialProperties(SharedProperties::stone)
.properties(p -> p.nonOpaque()) .properties(p -> p.nonOpaque())
.transform(StressConfigDefaults.setNoImpact())
.blockstate(BlockStateGen.axisBlockProvider(true)) .blockstate(BlockStateGen.axisBlockProvider(true))
.item() .item()
.transform(customItemModel()) .transform(customItemModel())
@ -192,6 +197,7 @@ public class AllBlocks {
public static final BlockEntry<ClutchBlock> CLUTCH = REGISTRATE.block("clutch", ClutchBlock::new) public static final BlockEntry<ClutchBlock> CLUTCH = REGISTRATE.block("clutch", ClutchBlock::new)
.initialProperties(SharedProperties::stone) .initialProperties(SharedProperties::stone)
.properties(p -> p.nonOpaque()) .properties(p -> p.nonOpaque())
.transform(StressConfigDefaults.setNoImpact())
.blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p))) .blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p)))
.item() .item()
.transform(customItemModel()) .transform(customItemModel())
@ -200,6 +206,7 @@ public class AllBlocks {
public static final BlockEntry<GearshiftBlock> GEARSHIFT = REGISTRATE.block("gearshift", GearshiftBlock::new) public static final BlockEntry<GearshiftBlock> GEARSHIFT = REGISTRATE.block("gearshift", GearshiftBlock::new)
.initialProperties(SharedProperties::stone) .initialProperties(SharedProperties::stone)
.properties(p -> p.nonOpaque()) .properties(p -> p.nonOpaque())
.transform(StressConfigDefaults.setNoImpact())
.blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p))) .blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p)))
.item() .item()
.transform(customItemModel()) .transform(customItemModel())
@ -209,6 +216,7 @@ public class AllBlocks {
REGISTRATE.block("encased_belt", EncasedBeltBlock::new) REGISTRATE.block("encased_belt", EncasedBeltBlock::new)
.initialProperties(SharedProperties::stone) .initialProperties(SharedProperties::stone)
.properties(p -> p.nonOpaque()) .properties(p -> p.nonOpaque())
.transform(StressConfigDefaults.setNoImpact())
.blockstate((c, p) -> new EncasedBeltGenerator((state, suffix) -> p.models() .blockstate((c, p) -> new EncasedBeltGenerator((state, suffix) -> p.models()
.getExistingFile(p.modLoc("block/" + c.getName() + "/" + suffix))).generate(c, p)) .getExistingFile(p.modLoc("block/" + c.getName() + "/" + suffix))).generate(c, p))
.item() .item()
@ -219,6 +227,7 @@ public class AllBlocks {
REGISTRATE.block("adjustable_pulley", AdjustablePulleyBlock::new) REGISTRATE.block("adjustable_pulley", AdjustablePulleyBlock::new)
.initialProperties(SharedProperties::stone) .initialProperties(SharedProperties::stone)
.properties(p -> p.nonOpaque()) .properties(p -> p.nonOpaque())
.transform(StressConfigDefaults.setNoImpact())
.blockstate((c, p) -> new EncasedBeltGenerator((state, suffix) -> { .blockstate((c, p) -> new EncasedBeltGenerator((state, suffix) -> {
String powered = state.get(AdjustablePulleyBlock.POWERED) ? "_powered" : ""; String powered = state.get(AdjustablePulleyBlock.POWERED) ? "_powered" : "";
return p.models() return p.models()
@ -357,6 +366,7 @@ public class AllBlocks {
public static final BlockEntry<GaugeBlock> SPEEDOMETER = REGISTRATE.block("speedometer", GaugeBlock::speed) public static final BlockEntry<GaugeBlock> SPEEDOMETER = REGISTRATE.block("speedometer", GaugeBlock::speed)
.initialProperties(SharedProperties::wooden) .initialProperties(SharedProperties::wooden)
.transform(StressConfigDefaults.setNoImpact())
.blockstate(new GaugeGenerator()::generate) .blockstate(new GaugeGenerator()::generate)
.item() .item()
.transform(ModelGen.customItemModel("gauge", "_", "item")) .transform(ModelGen.customItemModel("gauge", "_", "item"))
@ -364,6 +374,7 @@ public class AllBlocks {
public static final BlockEntry<GaugeBlock> STRESSOMETER = REGISTRATE.block("stressometer", GaugeBlock::stress) public static final BlockEntry<GaugeBlock> STRESSOMETER = REGISTRATE.block("stressometer", GaugeBlock::stress)
.initialProperties(SharedProperties::wooden) .initialProperties(SharedProperties::wooden)
.transform(StressConfigDefaults.setNoImpact())
.blockstate(new GaugeGenerator()::generate) .blockstate(new GaugeGenerator()::generate)
.item() .item()
.transform(ModelGen.customItemModel("gauge", "_", "item")) .transform(ModelGen.customItemModel("gauge", "_", "item"))
@ -554,6 +565,7 @@ public class AllBlocks {
REGISTRATE.block("sequenced_gearshift", SequencedGearshiftBlock::new) REGISTRATE.block("sequenced_gearshift", SequencedGearshiftBlock::new)
.initialProperties(SharedProperties::stone) .initialProperties(SharedProperties::stone)
.properties(p -> p.nonOpaque()) .properties(p -> p.nonOpaque())
.transform(StressConfigDefaults.setNoImpact())
.blockstate(new SequencedGearshiftGenerator()::generate) .blockstate(new SequencedGearshiftGenerator()::generate)
.item() .item()
.transform(customItemModel()) .transform(customItemModel())
@ -562,6 +574,7 @@ public class AllBlocks {
public static final BlockEntry<FlywheelBlock> FLYWHEEL = REGISTRATE.block("flywheel", FlywheelBlock::new) public static final BlockEntry<FlywheelBlock> FLYWHEEL = REGISTRATE.block("flywheel", FlywheelBlock::new)
.initialProperties(SharedProperties::softMetal) .initialProperties(SharedProperties::softMetal)
.properties(p -> p.nonOpaque()) .properties(p -> p.nonOpaque())
.transform(StressConfigDefaults.setNoImpact())
.blockstate(new FlywheelGenerator()::generate) .blockstate(new FlywheelGenerator()::generate)
.item() .item()
.transform(customItemModel()) .transform(customItemModel())
@ -579,6 +592,7 @@ public class AllBlocks {
public static final BlockEntry<SpeedControllerBlock> ROTATION_SPEED_CONTROLLER = public static final BlockEntry<SpeedControllerBlock> ROTATION_SPEED_CONTROLLER =
REGISTRATE.block("rotation_speed_controller", SpeedControllerBlock::new) REGISTRATE.block("rotation_speed_controller", SpeedControllerBlock::new)
.initialProperties(SharedProperties::softMetal) .initialProperties(SharedProperties::softMetal)
.transform(StressConfigDefaults.setNoImpact())
.blockstate(BlockStateGen.horizontalAxisBlockProvider(true)) .blockstate(BlockStateGen.horizontalAxisBlockProvider(true))
.item() .item()
.transform(customItemModel()) .transform(customItemModel())

View file

@ -38,7 +38,7 @@ public class Create {
public static final String ID = "create"; public static final String ID = "create";
public static final String NAME = "Create"; public static final String NAME = "Create";
public static final String VERSION = "0.2.3"; public static final String VERSION = "0.2.4";
public static Logger logger = LogManager.getLogger(); public static Logger logger = LogManager.getLogger();
public static ItemGroup baseCreativeTab = new CreateItemGroup(); public static ItemGroup baseCreativeTab = new CreateItemGroup();
@ -54,7 +54,6 @@ public class Create {
public Create() { public Create() {
IEventBus modEventBus = FMLJavaModLoadingContext.get() IEventBus modEventBus = FMLJavaModLoadingContext.get()
.getModEventBus(); .getModEventBus();
modEventBus.addListener(Create::init);
AllBlocks.register(); AllBlocks.register();
AllItems.register(); AllItems.register();
@ -62,18 +61,16 @@ public class Create {
AllEntityTypes.register(); AllEntityTypes.register();
AllTileEntities.register(); AllTileEntities.register();
modEventBus.addListener(Create::init);
modEventBus.addGenericListener(IRecipeSerializer.class, AllRecipeTypes::register); modEventBus.addGenericListener(IRecipeSerializer.class, AllRecipeTypes::register);
modEventBus.addGenericListener(ContainerType.class, AllContainerTypes::register); modEventBus.addGenericListener(ContainerType.class, AllContainerTypes::register);
modEventBus.addGenericListener(ParticleType.class, AllParticleTypes::register); modEventBus.addGenericListener(ParticleType.class, AllParticleTypes::register);
modEventBus.addGenericListener(SoundEvent.class, AllSoundEvents::register); modEventBus.addGenericListener(SoundEvent.class, AllSoundEvents::register);
modEventBus.addListener(AllConfigs::onLoad); modEventBus.addListener(AllConfigs::onLoad);
modEventBus.addListener(AllConfigs::onReload); modEventBus.addListener(AllConfigs::onReload);
// Ensure registrate runs first
modEventBus.addListener(EventPriority.LOWEST, this::gatherData); modEventBus.addListener(EventPriority.LOWEST, this::gatherData);
CreateClient.addClientListeners(modEventBus);
CreateClient.addListeners(modEventBus); AllConfigs.register();
AllConfigs.registerClientCommon();
} }
public static void init(final FMLCommonSetupEvent event) { public static void init(final FMLCommonSetupEvent event) {
@ -84,9 +81,7 @@ public class Create {
AllPackets.registerPackets(); AllPackets.registerPackets();
AllTriggers.register(); AllTriggers.register();
AllWorldFeatures.reload(); AllWorldFeatures.reload();
AllConfigs.registerServer();
} }
public static void tick() { public static void tick() {

View file

@ -61,7 +61,7 @@ public class CreateClient {
private static CustomRenderedItems customRenderedItems; private static CustomRenderedItems customRenderedItems;
private static AllColorHandlers colorHandlers; private static AllColorHandlers colorHandlers;
public static void addListeners(IEventBus modEventBus) { public static void addClientListeners(IEventBus modEventBus) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
modEventBus.addListener(CreateClient::clientInit); modEventBus.addListener(CreateClient::clientInit);
modEventBus.addListener(CreateClient::onModelBake); modEventBus.addListener(CreateClient::onModelBake);

View file

@ -108,33 +108,35 @@ public class AllPaletteBlocks {
.register(); .register();
public static final BlockEntry<Block> LIMESTONE = public static final BlockEntry<Block> LIMESTONE =
REGISTRATE.baseBlock("limestone", Block::new, () -> Blocks.SANDSTONE) REGISTRATE.baseBlock("limestone", Block::new, () -> Blocks.SANDSTONE, true)
.register(); .register();
public static final PalettesVariantEntry LIMESTONE_VARIANTS = public static final PalettesVariantEntry LIMESTONE_VARIANTS =
new PalettesVariantEntry(PaletteStoneVariants.LIMESTONE, PaletteBlockPatterns.standardRange, LIMESTONE); new PalettesVariantEntry(PaletteStoneVariants.LIMESTONE, PaletteBlockPatterns.standardRange, LIMESTONE);
public static final BlockEntry<Block> WEATHERED_LIMESTONE = public static final BlockEntry<Block> WEATHERED_LIMESTONE =
REGISTRATE.baseBlock("weathered_limestone", Block::new, () -> Blocks.SANDSTONE) REGISTRATE.baseBlock("weathered_limestone", Block::new, () -> Blocks.SANDSTONE, true)
.register(); .register();
public static final PalettesVariantEntry WEATHERED_LIMESTONE_VARIANTS = new PalettesVariantEntry( public static final PalettesVariantEntry WEATHERED_LIMESTONE_VARIANTS = new PalettesVariantEntry(
PaletteStoneVariants.WEATHERED_LIMESTONE, PaletteBlockPatterns.standardRange, WEATHERED_LIMESTONE); PaletteStoneVariants.WEATHERED_LIMESTONE, PaletteBlockPatterns.standardRange, WEATHERED_LIMESTONE);
public static final BlockEntry<Block> DOLOMITE = public static final BlockEntry<Block> DOLOMITE =
REGISTRATE.baseBlock("dolomite", Block::new, () -> Blocks.QUARTZ_BLOCK) REGISTRATE.baseBlock("dolomite", Block::new, () -> Blocks.QUARTZ_BLOCK, true)
.register(); .register();
public static final PalettesVariantEntry DOLOMITE_VARIANTS = public static final PalettesVariantEntry DOLOMITE_VARIANTS =
new PalettesVariantEntry(PaletteStoneVariants.DOLOMITE, PaletteBlockPatterns.standardRange, DOLOMITE); new PalettesVariantEntry(PaletteStoneVariants.DOLOMITE, PaletteBlockPatterns.standardRange, DOLOMITE);
public static final BlockEntry<Block> GABBRO = REGISTRATE.baseBlock("gabbro", Block::new, () -> Blocks.ANDESITE) public static final BlockEntry<Block> GABBRO =
REGISTRATE.baseBlock("gabbro", Block::new, () -> Blocks.ANDESITE, true)
.register(); .register();
public static final PalettesVariantEntry GABBRO_VARIANTS = public static final PalettesVariantEntry GABBRO_VARIANTS =
new PalettesVariantEntry(PaletteStoneVariants.GABBRO, PaletteBlockPatterns.standardRange, GABBRO); new PalettesVariantEntry(PaletteStoneVariants.GABBRO, PaletteBlockPatterns.standardRange, GABBRO);
public static final BlockEntry<Block> SCORIA = REGISTRATE.baseBlock("scoria", Block::new, () -> Blocks.ANDESITE) public static final BlockEntry<Block> SCORIA =
REGISTRATE.baseBlock("scoria", Block::new, () -> Blocks.ANDESITE, true)
.register(); .register();
public static final BlockEntry<Block> NATURAL_SCORIA = REGISTRATE.block("natural_scoria", Block::new) public static final BlockEntry<Block> NATURAL_SCORIA = REGISTRATE.block("natural_scoria", Block::new)
@ -149,7 +151,7 @@ public class AllPaletteBlocks {
new PalettesVariantEntry(PaletteStoneVariants.SCORIA, PaletteBlockPatterns.standardRange, SCORIA); new PalettesVariantEntry(PaletteStoneVariants.SCORIA, PaletteBlockPatterns.standardRange, SCORIA);
public static final BlockEntry<Block> DARK_SCORIA = public static final BlockEntry<Block> DARK_SCORIA =
REGISTRATE.baseBlock("dark_scoria", Block::new, () -> Blocks.ANDESITE) REGISTRATE.baseBlock("dark_scoria", Block::new, () -> Blocks.ANDESITE, false)
.register(); .register();
public static final PalettesVariantEntry DARK_SCORIA_VARIANTS = public static final PalettesVariantEntry DARK_SCORIA_VARIANTS =

View file

@ -33,28 +33,29 @@ public class AllConfigs {
return config; return config;
} }
public static void registerClientCommon() { public static void register() {
CLIENT = register(CClient::new, ModConfig.Type.CLIENT); CLIENT = register(CClient::new, ModConfig.Type.CLIENT);
COMMON = register(CCommon::new, ModConfig.Type.COMMON); COMMON = register(CCommon::new, ModConfig.Type.COMMON);
for (Entry<ConfigBase, Type> pair : configs.entrySet())
if (pair.getValue() != Type.SERVER)
ModLoadingContext.get().registerConfig(pair.getValue(), pair.getKey().specification);
}
public static void registerServer() {
SERVER = register(CServer::new, ModConfig.Type.SERVER); SERVER = register(CServer::new, ModConfig.Type.SERVER);
ModLoadingContext.get().registerConfig(configs.get(SERVER), SERVER.specification);
for (Entry<ConfigBase, Type> pair : configs.entrySet())
ModLoadingContext.get()
.registerConfig(pair.getValue(), pair.getKey().specification);
} }
public static void onLoad(ModConfig.Loading event) { public static void onLoad(ModConfig.Loading event) {
for (Entry<ConfigBase, Type> pair : configs.entrySet()) for (Entry<ConfigBase, Type> pair : configs.entrySet())
if (pair.getKey().specification == event.getConfig().getSpec()) if (pair.getKey().specification == event.getConfig()
pair.getKey().onLoad(); .getSpec())
pair.getKey()
.onLoad();
} }
public static void onReload(ModConfig.Reloading event) { public static void onReload(ModConfig.Reloading event) {
for (Entry<ConfigBase, Type> pair : configs.entrySet()) for (Entry<ConfigBase, Type> pair : configs.entrySet())
if (pair.getKey().specification == event.getConfig().getSpec()) if (pair.getKey().specification == event.getConfig()
pair.getKey().onReload(); .getSpec())
pair.getKey()
.onReload();
} }
} }

View file

@ -22,6 +22,10 @@ public class StressConfigDefaults {
static Map<ResourceLocation, Double> registeredDefaultImpacts = new HashMap<>(); static Map<ResourceLocation, Double> registeredDefaultImpacts = new HashMap<>();
static Map<ResourceLocation, Double> registeredDefaultCapacities = new HashMap<>(); static Map<ResourceLocation, Double> registeredDefaultCapacities = new HashMap<>();
public static <B extends Block, P> NonNullUnaryOperator<BlockBuilder<B, P>> setNoImpact() {
return setImpact(0);
}
public static <B extends Block, P> NonNullUnaryOperator<BlockBuilder<B, P>> setImpact(double impact) { public static <B extends Block, P> NonNullUnaryOperator<BlockBuilder<B, P>> setImpact(double impact) {
return b -> { return b -> {
registeredDefaultImpacts.put(Create.asResource(b.getName()), impact); registeredDefaultImpacts.put(Create.asResource(b.getName()), impact);

View file

@ -102,12 +102,13 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
/* Palettes */ /* Palettes */
public <T extends Block> BlockBuilder<T, CreateRegistrate> baseBlock(String name, public <T extends Block> BlockBuilder<T, CreateRegistrate> baseBlock(String name,
NonNullFunction<Properties, T> factory, NonNullSupplier<Block> propertiesFrom) { NonNullFunction<Properties, T> factory, NonNullSupplier<Block> propertiesFrom, boolean TFworldGen) {
return super.block(name, factory).initialProperties(propertiesFrom) return super.block(name, factory).initialProperties(propertiesFrom)
.blockstate((c, p) -> { .blockstate((c, p) -> {
final String location = "block/palettes/" + c.getName() + "/plain"; final String location = "block/palettes/" + c.getName() + "/plain";
p.simpleBlock(c.get(), p.models() p.simpleBlock(c.get(), p.models()
.cubeAll(c.getName(), p.modLoc(location))); .cubeAll(c.getName(), p.modLoc(location)));
// TODO tag with forge:stone; if TFWorldGen == true tag with forge:wg_stone aswell
}) })
.simpleItem(); .simpleItem();
} }

View file

@ -0,0 +1,17 @@
{
"replace": false,
"values": [
"create:limestone",
"create:polished_limestone",
"create:weathered_limestone",
"create:polished_weathered_limestone",
"create:gabbro",
"create:polished_gabbro",
"create:dolomite",
"create:polished_dolomite",
"create:scoria",
"create:polished_scoria",
"create:dark_scoria",
"create:polished_dark_scoria"
]
}

View file

@ -0,0 +1,10 @@
{
"replace": false,
"values": [
"create:limestone",
"create:weathered_limestone",
"create:gabbro",
"create:dolomite",
"create:natural_scoria"
]
}

View file

@ -0,0 +1,17 @@
{
"replace": false,
"values": [
"create:limestone",
"create:polished_limestone",
"create:weathered_limestone",
"create:polished_weathered_limestone",
"create:gabbro",
"create:polished_gabbro",
"create:dolomite",
"create:polished_dolomite",
"create:scoria",
"create:polished_scoria",
"create:dark_scoria",
"create:polished_dark_scoria"
]
}