mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
Default fallback
- Make stress value getters fallback to default value map if provider is absent - Rename StressConfigDefaults to BlockStressDefaults and move to block package - Rename StressConfigValues to BlockStressValues and move to block package
This commit is contained in:
parent
0dea880665
commit
b31f5f5d78
9 changed files with 88 additions and 76 deletions
|
@ -162,7 +162,7 @@ import com.simibubi.create.content.schematics.block.SchematicTableBlock;
|
|||
import com.simibubi.create.content.schematics.block.SchematicannonBlock;
|
||||
import com.simibubi.create.foundation.block.DyedBlockList;
|
||||
import com.simibubi.create.foundation.block.ItemUseOverrides;
|
||||
import com.simibubi.create.foundation.config.StressConfigDefaults;
|
||||
import com.simibubi.create.foundation.block.BlockStressDefaults;
|
||||
import com.simibubi.create.foundation.data.AssetLookup;
|
||||
import com.simibubi.create.foundation.data.BlockStateGen;
|
||||
import com.simibubi.create.foundation.data.BuilderTransformers;
|
||||
|
@ -250,7 +250,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<ShaftBlock> SHAFT = REGISTRATE.block("shaft", ShaftBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate(BlockStateGen.axisBlockProvider(false))
|
||||
.onRegister(CreateRegistrate.blockModel(() -> BracketedKineticBlockModel::new))
|
||||
.simpleItem()
|
||||
|
@ -258,7 +258,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<CogWheelBlock> COGWHEEL = REGISTRATE.block("cogwheel", CogWheelBlock::small)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.properties(p -> p.sound(SoundType.WOOD))
|
||||
.blockstate(BlockStateGen.axisBlockProvider(false))
|
||||
.onRegister(CreateRegistrate.blockModel(() -> BracketedKineticBlockModel::new))
|
||||
|
@ -270,7 +270,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("large_cogwheel", CogWheelBlock::large)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(p -> p.sound(SoundType.WOOD))
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate(BlockStateGen.axisBlockProvider(false))
|
||||
.onRegister(CreateRegistrate.blockModel(() -> BracketedKineticBlockModel::new))
|
||||
.item(CogwheelBlockItem::new)
|
||||
|
@ -290,7 +290,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<GearboxBlock> GEARBOX = REGISTRATE.block("gearbox", GearboxBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.onRegister(CreateRegistrate.connectedTextures(new EncasedCTBehaviour(AllSpriteShifts.ANDESITE_CASING)))
|
||||
.onRegister(CreateRegistrate.casingConnectivity((block, cc) -> cc.make(block, AllSpriteShifts.ANDESITE_CASING,
|
||||
(s, f) -> f.getAxis() == s.getValue(GearboxBlock.AXIS))))
|
||||
|
@ -302,7 +302,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<ClutchBlock> CLUTCH = REGISTRATE.block("clutch", ClutchBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p)))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
|
@ -311,7 +311,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<GearshiftBlock> GEARSHIFT = REGISTRATE.block("gearshift", GearshiftBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate((c, p) -> BlockStateGen.axisBlock(c, p, AssetLookup.forPowered(c, p)))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
|
@ -321,7 +321,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("encased_chain_drive", EncasedBeltBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate((c, p) -> new EncasedBeltGenerator((state, suffix) -> p.models()
|
||||
.getExistingFile(p.modLoc("block/" + c.getName() + "/" + suffix))).generate(c, p))
|
||||
.item()
|
||||
|
@ -332,7 +332,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("adjustable_chain_gearshift", AdjustablePulleyBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate((c, p) -> new EncasedBeltGenerator((state, suffix) -> {
|
||||
String powered = state.getValue(AdjustablePulleyBlock.POWERED) ? "_powered" : "";
|
||||
return p.models()
|
||||
|
@ -351,7 +351,7 @@ public class AllBlocks {
|
|||
.properties(p -> p.sound(SoundType.WOOL))
|
||||
.properties(p -> p.strength(0.8F))
|
||||
.blockstate(new BeltGenerator()::generate)
|
||||
.transform(StressConfigDefaults.setImpact(1.0))
|
||||
.transform(BlockStressDefaults.setImpact(1.0))
|
||||
.onRegister(CreateRegistrate.blockModel(() -> BeltModel::new))
|
||||
.register();
|
||||
|
||||
|
@ -360,7 +360,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::stone)
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.blockstate(new CreativeMotorGenerator()::generate)
|
||||
.transform(StressConfigDefaults.setCapacity(16384.0))
|
||||
.transform(BlockStressDefaults.setCapacity(16384.0))
|
||||
.item()
|
||||
.properties(p -> p.rarity(Rarity.EPIC))
|
||||
.transform(customItemModel())
|
||||
|
@ -371,7 +371,7 @@ public class AllBlocks {
|
|||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.blockstate(BlockStateGen.directionalBlockProviderIgnoresWaterlogged(false))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(StressConfigDefaults.setCapacity(16.0))
|
||||
.transform(BlockStressDefaults.setCapacity(16.0))
|
||||
.simpleItem()
|
||||
.register();
|
||||
|
||||
|
@ -379,8 +379,8 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::stone)
|
||||
.blockstate(BlockStateGen.directionalBlockProvider(true))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(StressConfigDefaults.setCapacity(16.0))
|
||||
.transform(StressConfigDefaults.setImpact(2.0))
|
||||
.transform(BlockStressDefaults.setCapacity(16.0))
|
||||
.transform(BlockStressDefaults.setImpact(2.0))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
.register();
|
||||
|
@ -397,14 +397,14 @@ public class AllBlocks {
|
|||
public static final BlockEntry<TurntableBlock> TURNTABLE = REGISTRATE.block("turntable", TurntableBlock::new)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.standardModel(c, p)))
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.simpleItem()
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<HandCrankBlock> HAND_CRANK = REGISTRATE.block("hand_crank", HandCrankBlock::new)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.blockstate(BlockStateGen.directionalBlockProvider(true))
|
||||
.transform(StressConfigDefaults.setCapacity(8.0))
|
||||
.transform(BlockStressDefaults.setCapacity(8.0))
|
||||
.tag(AllBlockTags.BRITTLE.tag)
|
||||
.onRegister(ItemUseOverrides::addBlock)
|
||||
.item()
|
||||
|
@ -426,7 +426,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<MillstoneBlock> MILLSTONE = REGISTRATE.block("millstone", MillstoneBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p)))
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
.register();
|
||||
|
@ -437,7 +437,7 @@ public class AllBlocks {
|
|||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.blockstate(BlockStateGen.axisBlockProvider(false))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(StressConfigDefaults.setImpact(8.0))
|
||||
.transform(BlockStressDefaults.setImpact(8.0))
|
||||
.simpleItem()
|
||||
.register();
|
||||
|
||||
|
@ -456,7 +456,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::stone)
|
||||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.blockstate(BlockStateGen.horizontalBlockProvider(true))
|
||||
.transform(StressConfigDefaults.setImpact(8.0))
|
||||
.transform(BlockStressDefaults.setImpact(8.0))
|
||||
.item(AssemblyOperatorBlockItem::new)
|
||||
.transform(customItemModel())
|
||||
.register();
|
||||
|
@ -467,7 +467,7 @@ public class AllBlocks {
|
|||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p)))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.item(AssemblyOperatorBlockItem::new)
|
||||
.transform(customItemModel())
|
||||
.register();
|
||||
|
@ -521,7 +521,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::stone)
|
||||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.blockstate((c, p) -> p.horizontalBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p), 180))
|
||||
.transform(StressConfigDefaults.setImpact(2.0))
|
||||
.transform(BlockStressDefaults.setImpact(2.0))
|
||||
.item(EjectorItem::new)
|
||||
.transform(customItemModel())
|
||||
.register();
|
||||
|
@ -545,7 +545,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<GaugeBlock> SPEEDOMETER = REGISTRATE.block("speedometer", GaugeBlock::speed)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate(new GaugeGenerator()::generate)
|
||||
.item()
|
||||
.transform(ModelGen.customItemModel("gauge", "_", "item"))
|
||||
|
@ -553,7 +553,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<GaugeBlock> STRESSOMETER = REGISTRATE.block("stressometer", GaugeBlock::stress)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate(new GaugeGenerator()::generate)
|
||||
.item()
|
||||
.transform(ModelGen.customItemModel("gauge", "_", "item"))
|
||||
|
@ -607,7 +607,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::softMetal)
|
||||
.blockstate(BlockStateGen.directionalBlockProviderIgnoresWaterlogged(true))
|
||||
.onRegister(CreateRegistrate.blockModel(() -> PipeAttachmentModel::new))
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
.register();
|
||||
|
@ -681,7 +681,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<HosePulleyBlock> HOSE_PULLEY = REGISTRATE.block("hose_pulley", HosePulleyBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.blockstate(BlockStateGen.horizontalBlockProvider(true))
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
.register();
|
||||
|
@ -775,14 +775,14 @@ public class AllBlocks {
|
|||
public static final BlockEntry<WindmillBearingBlock> WINDMILL_BEARING =
|
||||
REGISTRATE.block("windmill_bearing", WindmillBearingBlock::new)
|
||||
.transform(BuilderTransformers.bearing("windmill", "gearbox", true))
|
||||
.transform(StressConfigDefaults.setCapacity(512.0))
|
||||
.transform(BlockStressDefaults.setCapacity(512.0))
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<MechanicalBearingBlock> MECHANICAL_BEARING =
|
||||
REGISTRATE.block("mechanical_bearing", MechanicalBearingBlock::new)
|
||||
.transform(BuilderTransformers.bearing("mechanical", "gearbox", false))
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.onRegister(addMovementBehaviour(new StabilizedBearingMovementBehaviour()))
|
||||
.register();
|
||||
|
@ -790,7 +790,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<ClockworkBearingBlock> CLOCKWORK_BEARING =
|
||||
REGISTRATE.block("clockwork_bearing", ClockworkBearingBlock::new)
|
||||
.transform(BuilderTransformers.bearing("clockwork", "brass_gearbox", false))
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.register();
|
||||
|
||||
|
@ -798,7 +798,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::stone)
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.blockstate(BlockStateGen.horizontalAxisBlockProvider(true))
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
.register();
|
||||
|
@ -906,7 +906,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<DrillBlock> MECHANICAL_DRILL = REGISTRATE.block("mechanical_drill", DrillBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.blockstate(BlockStateGen.directionalBlockProvider(true))
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.onRegister(addMovementBehaviour(new DrillMovementBehaviour()))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
|
@ -915,7 +915,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<SawBlock> MECHANICAL_SAW = REGISTRATE.block("mechanical_saw", SawBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.blockstate(new SawGenerator()::generate)
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.onRegister(addMovementBehaviour(new SawMovementBehaviour()))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.item()
|
||||
|
@ -925,7 +925,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<DeployerBlock> DEPLOYER = REGISTRATE.block("deployer", DeployerBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.blockstate(BlockStateGen.directionalAxisBlockProvider())
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.onRegister(addMovementBehaviour(new DeployerMovementBehaviour()))
|
||||
.item(AssemblyOperatorBlockItem::new)
|
||||
.transform(customItemModel())
|
||||
|
@ -1067,7 +1067,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.blockstate(BlockStateGen.horizontalBlockProvider(true))
|
||||
.transform(StressConfigDefaults.setImpact(2.0))
|
||||
.transform(BlockStressDefaults.setImpact(2.0))
|
||||
.onRegister(CreateRegistrate.connectedTextures(new CrafterCTBehaviour()))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.item()
|
||||
|
@ -1079,7 +1079,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::stone)
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate(new SequencedGearshiftGenerator()::generate)
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
|
@ -1088,7 +1088,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<FlywheelBlock> FLYWHEEL = REGISTRATE.block("flywheel", FlywheelBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(AbstractBlock.Properties::noOcclusion)
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate(new FlywheelGenerator()::generate)
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
|
@ -1099,7 +1099,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::softMetal)
|
||||
.tag(AllBlockTags.BRITTLE.tag)
|
||||
.blockstate(BlockStateGen.horizontalBlockProvider(true))
|
||||
.transform(StressConfigDefaults.setCapacity(1024.0))
|
||||
.transform(BlockStressDefaults.setCapacity(1024.0))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
.register();
|
||||
|
@ -1108,7 +1108,7 @@ public class AllBlocks {
|
|||
REGISTRATE.block("rotation_speed_controller", SpeedControllerBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.blockstate(BlockStateGen.horizontalAxisBlockProvider(true))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
|
@ -1127,7 +1127,7 @@ public class AllBlocks {
|
|||
.modelFile(AssetLookup.partialBaseModel(c, p))
|
||||
.rotationX(s.getValue(ArmBlock.CEILING) ? 180 : 0)
|
||||
.build()))
|
||||
.transform(StressConfigDefaults.setImpact(2.0))
|
||||
.transform(BlockStressDefaults.setImpact(2.0))
|
||||
.item(ArmItem::new)
|
||||
.transform(customItemModel())
|
||||
.register();
|
||||
|
@ -1318,7 +1318,7 @@ public class AllBlocks {
|
|||
.initialProperties(SharedProperties::softMetal)
|
||||
.blockstate((c, p) -> p.horizontalBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p)))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.loot((lt, block) -> {
|
||||
Builder builder = LootTable.lootTable();
|
||||
IBuilder survivesExplosion = SurvivesExplosion.survivesExplosion();
|
||||
|
|
|
@ -18,8 +18,8 @@ import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
|
|||
import com.simibubi.create.content.contraptions.goggles.IHaveHoveringInformation;
|
||||
import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel;
|
||||
import com.simibubi.create.content.contraptions.relays.gearbox.GearboxBlock;
|
||||
import com.simibubi.create.foundation.block.BlockStressValues;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.config.StressConfigValues;
|
||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||
import com.simibubi.create.foundation.sound.SoundScapes;
|
||||
import com.simibubi.create.foundation.sound.SoundScapes.AmbienceGroup;
|
||||
|
@ -166,13 +166,13 @@ public abstract class KineticTileEntity extends SmartTileEntity
|
|||
}
|
||||
|
||||
public float calculateStressApplied() {
|
||||
float impact = (float) StressConfigValues.getImpact(getStressConfigKey());
|
||||
float impact = (float) BlockStressValues.getImpact(getStressConfigKey());
|
||||
this.lastStressApplied = impact;
|
||||
return impact;
|
||||
}
|
||||
|
||||
public float calculateAddedStressCapacity() {
|
||||
float capacity = (float) StressConfigValues.getCapacity(getStressConfigKey());
|
||||
float capacity = (float) BlockStressValues.getCapacity(getStressConfigKey());
|
||||
this.lastCapacityProvided = capacity;
|
||||
return capacity;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simibubi.create.content.contraptions.components.flywheel.engine;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.config.StressConfigValues;
|
||||
import com.simibubi.create.foundation.block.BlockStressValues;
|
||||
|
||||
import net.minecraft.block.AbstractFurnaceBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -29,7 +29,7 @@ public class FurnaceEngineTileEntity extends EngineTileEntity {
|
|||
boolean active = state.hasProperty(AbstractFurnaceBlock.LIT) && state.getValue(AbstractFurnaceBlock.LIT);
|
||||
float speed = active ? 16 * modifier : 0;
|
||||
float capacity =
|
||||
(float) (active ? StressConfigValues.getCapacity(AllBlocks.FURNACE_ENGINE.get())
|
||||
(float) (active ? BlockStressValues.getCapacity(AllBlocks.FURNACE_ENGINE.get())
|
||||
: 0);
|
||||
|
||||
appliedCapacity = capacity;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.foundation.config;
|
||||
package com.simibubi.create.foundation.block;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -9,7 +9,7 @@ import com.tterrag.registrate.util.nullness.NonNullUnaryOperator;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class StressConfigDefaults {
|
||||
public class BlockStressDefaults {
|
||||
|
||||
/**
|
||||
* Increment this number if all stress entries should be forced to update in the next release.
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.foundation.config;
|
||||
package com.simibubi.create.foundation.block;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -8,7 +8,7 @@ import javax.annotation.Nullable;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class StressConfigValues {
|
||||
public class BlockStressValues {
|
||||
|
||||
private static final Map<String, IStressValueProvider> PROVIDERS = new HashMap<>();
|
||||
|
||||
|
@ -23,58 +23,67 @@ public class StressConfigValues {
|
|||
|
||||
@Nullable
|
||||
public static IStressValueProvider getProvider(Block block) {
|
||||
ResourceLocation key = block.getRegistryName();
|
||||
String namespace = key.getNamespace();
|
||||
IStressValueProvider provider = getProvider(namespace);
|
||||
return provider;
|
||||
return getProvider(block.getRegistryName().getNamespace());
|
||||
}
|
||||
|
||||
public static double getImpact(Block block) {
|
||||
IStressValueProvider provider = getProvider(block);
|
||||
ResourceLocation blockId = block.getRegistryName();
|
||||
IStressValueProvider provider = getProvider(blockId.getNamespace());
|
||||
if (provider != null) {
|
||||
return provider.getImpact(block);
|
||||
}
|
||||
Double defaultImpact = BlockStressDefaults.DEFAULT_IMPACTS.get(blockId);
|
||||
if (defaultImpact != null) {
|
||||
return defaultImpact;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static double getCapacity(Block block) {
|
||||
IStressValueProvider provider = getProvider(block);
|
||||
ResourceLocation blockId = block.getRegistryName();
|
||||
IStressValueProvider provider = getProvider(blockId.getNamespace());
|
||||
if (provider != null) {
|
||||
return provider.getCapacity(block);
|
||||
}
|
||||
Double defaultCapacity = BlockStressDefaults.DEFAULT_CAPACITIES.get(blockId);
|
||||
if (defaultCapacity != null) {
|
||||
return defaultCapacity;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean hasImpact(Block block) {
|
||||
IStressValueProvider provider = getProvider(block);
|
||||
ResourceLocation blockId = block.getRegistryName();
|
||||
IStressValueProvider provider = getProvider(blockId.getNamespace());
|
||||
if (provider != null) {
|
||||
return provider.hasImpact(block);
|
||||
}
|
||||
return false;
|
||||
return BlockStressDefaults.DEFAULT_IMPACTS.containsKey(blockId);
|
||||
}
|
||||
|
||||
public static boolean hasCapacity(Block block) {
|
||||
IStressValueProvider provider = getProvider(block);
|
||||
ResourceLocation blockId = block.getRegistryName();
|
||||
IStressValueProvider provider = getProvider(blockId.getNamespace());
|
||||
if (provider != null) {
|
||||
return provider.hasCapacity(block);
|
||||
}
|
||||
return false;
|
||||
return BlockStressDefaults.DEFAULT_CAPACITIES.containsKey(blockId);
|
||||
}
|
||||
|
||||
public interface IStressValueProvider {
|
||||
/**
|
||||
* Gets the impact of a block.
|
||||
* Gets the stress impact of a block.
|
||||
*
|
||||
* @param block The block.
|
||||
* @return the impact value of the block, or 0 if it does not have one.
|
||||
* @return the stress impact value of the block, or 0 if it does not have one.
|
||||
*/
|
||||
double getImpact(Block block);
|
||||
|
||||
/**
|
||||
* Gets the capacity of a block.
|
||||
* Gets the stress capacity of a block.
|
||||
*
|
||||
* @param block The block.
|
||||
* @return the capacity value of the block, or 0 if it does not have one.
|
||||
* @return the stress capacity value of the block, or 0 if it does not have one.
|
||||
*/
|
||||
double getCapacity(Block block);
|
||||
|
|
@ -7,6 +7,8 @@ import java.util.function.Supplier;
|
|||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.simibubi.create.foundation.block.BlockStressValues;
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
|
@ -41,7 +43,7 @@ public class AllConfigs {
|
|||
for (Entry<ConfigBase, Type> pair : configs.entrySet())
|
||||
context.registerConfig(pair.getValue(), pair.getKey().specification);
|
||||
|
||||
StressConfigValues.registerProvider(context.getActiveNamespace(), SERVER.kinetics.stressValues);
|
||||
BlockStressValues.registerProvider(context.getActiveNamespace(), SERVER.kinetics.stressValues);
|
||||
}
|
||||
|
||||
public static void onLoad(ModConfig.Loading event) {
|
||||
|
|
|
@ -6,7 +6,8 @@ import java.util.Map;
|
|||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.contraptions.components.crank.ValveHandleBlock;
|
||||
import com.simibubi.create.foundation.config.StressConfigValues.IStressValueProvider;
|
||||
import com.simibubi.create.foundation.block.BlockStressDefaults;
|
||||
import com.simibubi.create.foundation.block.BlockStressValues.IStressValueProvider;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -22,7 +23,7 @@ public class CStress extends ConfigBase implements IStressValueProvider {
|
|||
protected void registerAll(Builder builder) {
|
||||
builder.comment("", Comments.su, Comments.impact)
|
||||
.push("impact");
|
||||
StressConfigDefaults.DEFAULT_IMPACTS
|
||||
BlockStressDefaults.DEFAULT_IMPACTS
|
||||
.forEach((r, i) -> {
|
||||
if (r.getNamespace().equals(Create.ID))
|
||||
getImpacts().put(r, builder.define(r.getPath(), i));
|
||||
|
@ -31,7 +32,7 @@ public class CStress extends ConfigBase implements IStressValueProvider {
|
|||
|
||||
builder.comment("", Comments.su, Comments.capacity)
|
||||
.push("capacity");
|
||||
StressConfigDefaults.DEFAULT_CAPACITIES
|
||||
BlockStressDefaults.DEFAULT_CAPACITIES
|
||||
.forEach((r, i) -> {
|
||||
if (r.getNamespace().equals(Create.ID))
|
||||
getCapacities().put(r, builder.define(r.getPath(), i));
|
||||
|
@ -82,7 +83,7 @@ public class CStress extends ConfigBase implements IStressValueProvider {
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "stressValues.v" + StressConfigDefaults.FORCED_UPDATE_VERSION;
|
||||
return "stressValues.v" + BlockStressDefaults.FORCED_UPDATE_VERSION;
|
||||
}
|
||||
|
||||
public Map<ResourceLocation, ConfigValue<Double>> getImpacts() {
|
||||
|
|
|
@ -23,8 +23,8 @@ import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.
|
|||
import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelItem;
|
||||
import com.simibubi.create.content.logistics.block.inventories.CrateBlock;
|
||||
import com.simibubi.create.foundation.block.ItemUseOverrides;
|
||||
import com.simibubi.create.foundation.block.BlockStressDefaults;
|
||||
import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry;
|
||||
import com.simibubi.create.foundation.config.StressConfigDefaults;
|
||||
import com.tterrag.registrate.builders.BlockBuilder;
|
||||
import com.tterrag.registrate.util.nullness.NonNullUnaryOperator;
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class BuilderTransformers {
|
|||
.blockstate((c, p) -> p.horizontalBlock(c.get(), p.models()
|
||||
.getExistingFile(p.modLoc("block/cuckoo_clock/block"))))
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(StressConfigDefaults.setImpact(1.0))
|
||||
.transform(BlockStressDefaults.setImpact(1.0))
|
||||
.item()
|
||||
.transform(ModelGen.customItemModel("cuckoo_clock", "item"));
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class BuilderTransformers {
|
|||
(block, cc) -> cc.make(block, casingShift, (s, f) -> f.getAxis() != s.getValue(EncasedShaftBlock.AXIS))))
|
||||
.blockstate((c, p) -> axisBlock(c, p, blockState -> p.models()
|
||||
.getExistingFile(p.modLoc("block/encased_shaft/block_" + casing)), true))
|
||||
.transform(StressConfigDefaults.setNoImpact())
|
||||
.transform(BlockStressDefaults.setNoImpact())
|
||||
.loot((p, b) -> p.dropOther(b, AllBlocks.SHAFT.get()))
|
||||
.item()
|
||||
.model(AssetLookup.customBlockItemModel("encased_shaft", "item_" + casing))
|
||||
|
@ -133,7 +133,7 @@ public class BuilderTransformers {
|
|||
.properties(p -> p.noOcclusion())
|
||||
.blockstate(new MechanicalPistonGenerator(type)::generate)
|
||||
.addLayer(() -> RenderType::cutoutMipped)
|
||||
.transform(StressConfigDefaults.setImpact(4.0))
|
||||
.transform(BlockStressDefaults.setImpact(4.0))
|
||||
.item()
|
||||
.transform(ModelGen.customItemModel("mechanical_piston", type.getSerializedName(), "item"));
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@ import com.simibubi.create.content.contraptions.base.IRotate.StressImpact;
|
|||
import com.simibubi.create.content.contraptions.components.fan.EncasedFanBlock;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.engine.FurnaceEngineBlock;
|
||||
import com.simibubi.create.content.contraptions.components.waterwheel.WaterWheelBlock;
|
||||
import com.simibubi.create.foundation.block.BlockStressValues;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.config.CKinetics;
|
||||
import com.simibubi.create.foundation.config.StressConfigValues;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -106,8 +106,8 @@ public class ItemDescription {
|
|||
}
|
||||
|
||||
boolean hasSpeedRequirement = minimumRequiredSpeedLevel != SpeedLevel.NONE;
|
||||
boolean hasStressImpact = StressImpact.isEnabled() && showStressImpact && StressConfigValues.getImpact(block) > 0;
|
||||
boolean hasStressCapacity = StressImpact.isEnabled() && StressConfigValues.hasCapacity(block);
|
||||
boolean hasStressImpact = StressImpact.isEnabled() && showStressImpact && BlockStressValues.getImpact(block) > 0;
|
||||
boolean hasStressCapacity = StressImpact.isEnabled() && BlockStressValues.hasCapacity(block);
|
||||
|
||||
if (hasSpeedRequirement) {
|
||||
List<ITextComponent> speedLevels =
|
||||
|
@ -130,7 +130,7 @@ public class ItemDescription {
|
|||
|
||||
if (hasStressImpact) {
|
||||
List<ITextComponent> stressLevels = Lang.translatedOptions("tooltip.stressImpact", "low", "medium", "high");
|
||||
double impact = StressConfigValues.getImpact(block);
|
||||
double impact = BlockStressValues.getImpact(block);
|
||||
StressImpact impactId = impact >= config.highStressImpact.get() ? StressImpact.HIGH
|
||||
: (impact >= config.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW);
|
||||
int index = impactId.ordinal();
|
||||
|
@ -151,7 +151,7 @@ public class ItemDescription {
|
|||
if (hasStressCapacity) {
|
||||
List<ITextComponent> stressCapacityLevels =
|
||||
Lang.translatedOptions("tooltip.capacityProvided", "low", "medium", "high");
|
||||
double capacity = StressConfigValues.getCapacity(block);
|
||||
double capacity = BlockStressValues.getCapacity(block);
|
||||
StressImpact impactId = capacity >= config.highCapacity.get() ? StressImpact.LOW
|
||||
: (capacity >= config.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH);
|
||||
int index = StressImpact.values().length - 2 - impactId.ordinal();
|
||||
|
|
Loading…
Reference in a new issue