mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-24 14:06:42 +01:00
Configure Everything
- Added config file handling for server and client parameters, also adresses #6 - Attached most constants to a config value
This commit is contained in:
parent
68e3be9b43
commit
6fb5da3d6a
30 changed files with 463 additions and 154 deletions
|
@ -20,7 +20,7 @@ archivesBaseName = 'create'
|
|||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'snapshot', version: '20190902-1.14.3'
|
||||
mappings channel: 'snapshot', version: '20190910-1.14.3'
|
||||
|
||||
runs {
|
||||
client {
|
||||
|
@ -58,7 +58,7 @@ minecraft {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
minecraft 'net.minecraftforge:forge:1.14.4-28.0.83'
|
||||
minecraft 'net.minecraftforge:forge:1.14.4-28.0.102'
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
|
@ -14,9 +14,11 @@ import net.minecraft.item.ItemGroup;
|
|||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
|
||||
@EventBusSubscriber(bus = Bus.MOD)
|
||||
|
@ -34,13 +36,19 @@ public class Create {
|
|||
public static InWorldItemProcessingHandler itemProcessingHandler;
|
||||
public static MovingConstructHandler constructHandler;
|
||||
|
||||
public static ModConfig config;
|
||||
|
||||
public Create() {
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, CreateConfig.specification);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CreateClientConfig.specification);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void init(final FMLCommonSetupEvent event) {
|
||||
schematicReceiver = new ServerSchematicLoader();
|
||||
itemProcessingHandler = new InWorldItemProcessingHandler();
|
||||
frequencyHandler = new FrequencyHandler();
|
||||
constructHandler = new MovingConstructHandler();
|
||||
|
||||
AllPackets.registerPackets();
|
||||
}
|
||||
|
||||
|
@ -60,6 +68,14 @@ public class Create {
|
|||
AllRecipes.register(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void createConfigs(ModConfig.ModConfigEvent event) {
|
||||
if (event.getConfig().getSpec() == CreateClientConfig.specification)
|
||||
return;
|
||||
|
||||
config = event.getConfig();
|
||||
}
|
||||
|
||||
public static void tick() {
|
||||
schematicReceiver.tick();
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import com.simibubi.create.modules.schematics.client.SchematicAndQuillHandler;
|
|||
import com.simibubi.create.modules.schematics.client.SchematicHandler;
|
||||
import com.simibubi.create.modules.schematics.client.SchematicHologram;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
|
||||
@EventBusSubscriber(value = Dist.CLIENT, bus = Bus.MOD)
|
||||
@EventBusSubscriber(bus = Bus.MOD)
|
||||
public class CreateClient {
|
||||
|
||||
public static ClientSchematicLoader schematicSender;
|
||||
|
@ -19,6 +19,8 @@ public class CreateClient {
|
|||
public static SchematicHologram schematicHologram;
|
||||
public static SchematicAndQuillHandler schematicAndQuillHandler;
|
||||
|
||||
public static ModConfig config;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void clientInit(FMLClientSetupEvent event) {
|
||||
schematicSender = new ClientSchematicLoader();
|
||||
|
@ -32,6 +34,14 @@ public class CreateClient {
|
|||
AllItems.registerColorHandlers();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void createConfigs(ModConfig.ModConfigEvent event) {
|
||||
if (event.getConfig().getSpec() == CreateConfig.specification)
|
||||
return;
|
||||
|
||||
config = event.getConfig();
|
||||
}
|
||||
|
||||
public static void gameTick() {
|
||||
schematicSender.tick();
|
||||
schematicAndQuillHandler.tick();
|
||||
|
|
26
src/main/java/com/simibubi/create/CreateClientConfig.java
Normal file
26
src/main/java/com/simibubi/create/CreateClientConfig.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package com.simibubi.create;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
|
||||
public class CreateClientConfig {
|
||||
|
||||
public static final ForgeConfigSpec specification;
|
||||
public static final CreateClientConfig instance;
|
||||
|
||||
static {
|
||||
final Pair<CreateClientConfig, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder()
|
||||
.configure(CreateClientConfig::new);
|
||||
|
||||
specification = specPair.getRight();
|
||||
instance = specPair.getLeft();
|
||||
}
|
||||
|
||||
CreateClientConfig(final ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("Client-only settings").push("client");
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
}
|
257
src/main/java/com/simibubi/create/CreateConfig.java
Normal file
257
src/main/java/com/simibubi/create/CreateConfig.java
Normal file
|
@ -0,0 +1,257 @@
|
|||
package com.simibubi.create;
|
||||
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.Builder;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
|
||||
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
|
||||
|
||||
public class CreateConfig {
|
||||
|
||||
public static final ForgeConfigSpec specification;
|
||||
public static final CreateConfig parameters;
|
||||
|
||||
static {
|
||||
final Pair<CreateConfig, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(CreateConfig::new);
|
||||
|
||||
specification = specPair.getRight();
|
||||
parameters = specPair.getLeft();
|
||||
}
|
||||
|
||||
// Schematics
|
||||
public IntValue maxSchematics, maxTotalSchematicSize, maxSchematicPacketSize, schematicIdleTimeout;
|
||||
public IntValue schematicannonDelay, schematicannonSkips;
|
||||
public DoubleValue schematicannonGunpowderWorth, schematicannonFuelUsage;
|
||||
public ConfigValue<String> schematicPath;
|
||||
|
||||
// Curiosities
|
||||
public IntValue maxSymmetryWandRange;
|
||||
|
||||
// Contraptions
|
||||
public IntValue maxBeltLength, crushingDamage, maxMotorSpeed, maxRotationSpeed;
|
||||
public IntValue fanMaxPushDistance, fanMaxPullDistance, fanBlockCheckRate, fanRotationArgmax;
|
||||
public IntValue maxChassisForTranslation, maxChassisForRotation, maxChassisRange, maxPistonPoles;
|
||||
|
||||
// Logistics
|
||||
public IntValue extractorDelay, extractorAmount, linkRange;
|
||||
|
||||
// Gardens
|
||||
public DoubleValue cocoaLogGrowthSpeed;
|
||||
|
||||
CreateConfig(final ForgeConfigSpec.Builder builder) {
|
||||
|
||||
// Schematics
|
||||
initSchematics(builder);
|
||||
initContraptions(builder);
|
||||
initCuriosities(builder);
|
||||
initLogistics(builder);
|
||||
initGardens(builder);
|
||||
}
|
||||
|
||||
private void initGardens(Builder builder) {
|
||||
builder.comment("The Gardens Module").push("gardens");
|
||||
String basePath = "create.config.gardens";
|
||||
String name = "";
|
||||
|
||||
name = "cocoaLogGrowthSpeed";
|
||||
cocoaLogGrowthSpeed = builder
|
||||
.comment("", "% of random Ticks causing a Cocoa log to grow.")
|
||||
.translation(basePath + name).defineInRange(name, 0D, 20D, 100D);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
private void initLogistics(Builder builder) {
|
||||
builder.comment("The Logistics Module").push("logistics");
|
||||
String basePath = "create.config.logistics";
|
||||
String name = "";
|
||||
|
||||
name = "extractorDelay";
|
||||
extractorDelay = builder
|
||||
.comment("", "The amount of game ticks an Extractor waits after pulling an item successfully.")
|
||||
.translation(basePath + name).defineInRange(name, 20, 1, Integer.MAX_VALUE);
|
||||
|
||||
name = "extractorAmount";
|
||||
extractorAmount = builder
|
||||
.comment("", "The amount of items an extractor pulls at a time without an applied filter.")
|
||||
.translation(basePath + name).defineInRange(name, 16, 1, 64);
|
||||
|
||||
name = "linkRange";
|
||||
linkRange = builder
|
||||
.comment("", "Maximum possible range in blocks of redstone link connections.")
|
||||
.translation(basePath + name).defineInRange(name, 128, 4, Integer.MAX_VALUE);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
private void initContraptions(Builder builder) {
|
||||
builder.comment("The Contraptions Module").push("contraptions");
|
||||
String basePath = "create.config.contraptions";
|
||||
String name = "";
|
||||
|
||||
name = "maxBeltLength";
|
||||
maxBeltLength = builder
|
||||
.comment("", "Maximum length in blocks of mechanical belts.")
|
||||
.translation(basePath + name).defineInRange(name, 20, 5, Integer.MAX_VALUE);
|
||||
|
||||
name = "crushingDamage";
|
||||
crushingDamage = builder
|
||||
.comment("", "Damage dealt by active Crushing Wheels.")
|
||||
.translation(basePath + name).defineInRange(name, 4, 0, Integer.MAX_VALUE);
|
||||
|
||||
{
|
||||
builder.comment("Encased Fan").push("encasedFan");
|
||||
basePath = "create.config.contraptions.encasedFan";
|
||||
|
||||
name = "fanBlockCheckRate";
|
||||
fanBlockCheckRate = builder
|
||||
.comment("", "Game ticks between Fans checking for anything blocking their air flow.")
|
||||
.translation(basePath + name).defineInRange(name, 100, 20, Integer.MAX_VALUE);
|
||||
|
||||
name = "fanMaxPushDistance";
|
||||
fanMaxPushDistance = builder
|
||||
.comment("", "Maximum distance in blocks Fans can push entities.")
|
||||
.translation(basePath + name).defineInRange(name, 20, 1, Integer.MAX_VALUE);
|
||||
|
||||
name = "fanMaxPullDistance";
|
||||
fanMaxPullDistance = builder
|
||||
.comment("", "Maximum distance in blocks from where Fans can pull entities.")
|
||||
.translation(basePath + name).defineInRange(name, 5, 1, Integer.MAX_VALUE);
|
||||
|
||||
name = "fanRotationArgmax";
|
||||
fanRotationArgmax = builder
|
||||
.comment("", "Rotation speed at which the maximum stats of fans are reached.")
|
||||
.translation(basePath + name).defineInRange(name, 8192, 64, Integer.MAX_VALUE);
|
||||
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
{
|
||||
builder.comment("Mechanical Pistons and Bearings").push("constructs");
|
||||
basePath = "create.config.contraptions.constructs";
|
||||
|
||||
name = "maxChassisRange";
|
||||
maxChassisRange = builder
|
||||
.comment("", "Maximum value of a chassis attachment range.")
|
||||
.translation(basePath + name).defineInRange(name, 16, 1, Integer.MAX_VALUE);
|
||||
|
||||
name = "maxChassisForRotation";
|
||||
maxChassisForRotation = builder
|
||||
.comment("", "Maximum amount of chassis blocks movable by a Mechanical Bearing.")
|
||||
.translation(basePath + name).defineInRange(name, 16, 1, Integer.MAX_VALUE);
|
||||
|
||||
name = "maxChassisForTranslation";
|
||||
maxChassisForTranslation = builder
|
||||
.comment("", "Maximum amount of chassis blocks movable by a Mechanical Piston.")
|
||||
.translation(basePath + name).defineInRange(name, 16, 1, Integer.MAX_VALUE);
|
||||
|
||||
name = "maxPistonPoles";
|
||||
maxPistonPoles = builder
|
||||
.comment("", "Maximum amount of extension poles behind a Mechanical Piston.")
|
||||
.translation(basePath + name).defineInRange(name, 64, 1, Integer.MAX_VALUE);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
name = "maxMotorSpeed";
|
||||
maxMotorSpeed = builder
|
||||
.comment("", "Maximum allowed speed of a configurable motor.")
|
||||
.translation(basePath + name).defineInRange(name, 4096, 64, Integer.MAX_VALUE);
|
||||
|
||||
name = "maxRotationSpeed";
|
||||
maxRotationSpeed = builder
|
||||
.comment("", "Maximum allowed rotation speed for any Kinetic Tile.")
|
||||
.translation(basePath + name).defineInRange(name, 16384, 64, Integer.MAX_VALUE);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
private void initCuriosities(Builder builder) {
|
||||
builder.comment("The Curiosities Module").push("curiosities");
|
||||
String basePath = "create.config.curiosities";
|
||||
String name = "";
|
||||
|
||||
name = "maxSymmetryWandRange";
|
||||
maxSymmetryWandRange = builder
|
||||
.comment("", "The Maximum Distance to an active mirror for the symmetry wand to trigger.")
|
||||
.translation(basePath + name).defineInRange(name, 50, 10, Integer.MAX_VALUE);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
public void initSchematics(final ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("The Schematics Module").push("schematics");
|
||||
String basePath = "create.config.schematics";
|
||||
String name = "";
|
||||
|
||||
name = "maxSchematics";
|
||||
maxSchematics = builder
|
||||
.comment("", "The amount of Schematics a player can upload until previous ones are overwritten.")
|
||||
.translation(basePath + name).defineInRange(name, 10, 1, Integer.MAX_VALUE);
|
||||
|
||||
name = "schematicPath";
|
||||
schematicPath = builder.comment("", "The file location where uploaded Schematics are stored.").define(name,
|
||||
"schematics/uploaded", this::isValidPath);
|
||||
|
||||
name = "maxTotalSchematicSize";
|
||||
maxTotalSchematicSize = builder
|
||||
.comment("", "[in KiloBytes]", "The maximum allowed file size of uploaded Schematics.")
|
||||
.translation(basePath + name).defineInRange(name, 256, 16, Integer.MAX_VALUE);
|
||||
|
||||
name = "maxSchematicPacketSize";
|
||||
maxSchematicPacketSize = builder
|
||||
.comment("", "[in Bytes]", "The maximum packet size uploaded Schematics are split into.")
|
||||
.translation(basePath + name).defineInRange(name, 1024, 256, 32767);
|
||||
|
||||
name = "schematicIdleTimeout";
|
||||
schematicIdleTimeout = builder.comment("",
|
||||
"Amount of game ticks without new packets arriving until an active schematic upload process is discarded.")
|
||||
.translation(basePath + name).defineInRange(name, 600, 100, Integer.MAX_VALUE);
|
||||
|
||||
{
|
||||
builder.comment("Schematicannon").push("schematicannon");
|
||||
basePath = "create.config.schematics.schematicannon";
|
||||
|
||||
name = "schematicannonDelay";
|
||||
schematicannonDelay = builder.comment("",
|
||||
"Amount of game ticks between shots of the cannon. Higher => Slower")
|
||||
.translation(basePath + name).defineInRange(name, 10, 1, Integer.MAX_VALUE);
|
||||
|
||||
name = "schematicannonSkips";
|
||||
schematicannonSkips = builder.comment("",
|
||||
"Amount of block positions per tick scanned by a running cannon. Higher => Faster")
|
||||
.translation(basePath + name).defineInRange(name, 10, 1, Integer.MAX_VALUE);
|
||||
|
||||
name = "schematicannonGunpowderWorth";
|
||||
schematicannonGunpowderWorth = builder.comment("",
|
||||
"% of Schematicannon's Fuel filled by 1 Gunpowder.")
|
||||
.translation(basePath + name).defineInRange(name, 20D, 0D, 100D);
|
||||
|
||||
name = "schematicannonFuelUsage";
|
||||
schematicannonFuelUsage = builder.comment("",
|
||||
"% of Schematicannon's Fuel used for each fired block.")
|
||||
.translation(basePath + name).defineInRange(name, 0.05D, 0D, 100D);
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
private boolean isValidPath(Object path) {
|
||||
if (!(path instanceof String))
|
||||
return false;
|
||||
try {
|
||||
Paths.get((String) path);
|
||||
return true;
|
||||
} catch (InvalidPathException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
|
@ -22,9 +23,13 @@ import net.minecraft.nbt.JsonToNBT;
|
|||
public class FilesHelper {
|
||||
|
||||
public static void createFolderIfMissing(String name) {
|
||||
if (!Files.isDirectory(Paths.get(name))) {
|
||||
Path path = Paths.get(name);
|
||||
if (path.getParent() != null)
|
||||
createFolderIfMissing(path.getParent().toString());
|
||||
|
||||
if (!Files.isDirectory(path)) {
|
||||
try {
|
||||
Files.createDirectory(Paths.get(name));
|
||||
Files.createDirectory(path);
|
||||
} catch (IOException e) {
|
||||
Create.logger.warn("Could not create Folder: " + name);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.simibubi.create.modules.contraptions;
|
||||
|
||||
import static com.simibubi.create.CreateConfig.parameters;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -176,7 +178,7 @@ public class RotationPropagator {
|
|||
|
||||
if ((neighbourTE.isSource())
|
||||
|| neighbourTE.hasSource() && !neighbourTE.getSource().equals(updateTE.getPos())) {
|
||||
if (neighbourTE.getSpeed() != newSpeed) {
|
||||
if (neighbourTE.getSpeed() != newSpeed || Math.abs(newSpeed) > parameters.maxRotationSpeed.get()) {
|
||||
world.destroyBlock(pos, true);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.generators;
|
|||
|
||||
import com.simibubi.create.AllPackets;
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.CreateConfig;
|
||||
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
|
||||
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
|
@ -9,7 +10,6 @@ import net.minecraft.util.math.MathHelper;
|
|||
|
||||
public class MotorTileEntity extends KineticTileEntity implements ITickableTileEntity {
|
||||
|
||||
public static final int MAX_SPEED = 4096;
|
||||
public static final int DEFAULT_SPEED = 64;
|
||||
public int newSpeed;
|
||||
public int lastModified;
|
||||
|
@ -44,7 +44,7 @@ public class MotorTileEntity extends KineticTileEntity implements ITickableTileE
|
|||
public void setSpeedValueLazily(int speed) {
|
||||
if (newSpeed == speed)
|
||||
return;
|
||||
newSpeed = MathHelper.clamp(speed, 1, MAX_SPEED);
|
||||
newSpeed = MathHelper.clamp(speed, 1, CreateConfig.parameters.maxMotorSpeed.get());
|
||||
this.lastModified = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.UUID;
|
|||
|
||||
import com.simibubi.create.AllRecipes;
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.CreateConfig;
|
||||
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -142,7 +143,7 @@ public class CrushingWheelControllerTileEntity extends SyncedTileEntity implemen
|
|||
return;
|
||||
|
||||
if (!(processingEntity instanceof ItemEntity)) {
|
||||
processingEntity.attackEntityFrom(damageSource, 4);
|
||||
processingEntity.attackEntityFrom(damageSource, CreateConfig.parameters.crushingDamage.get());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simibubi.create.modules.contraptions.receivers;
|
||||
|
||||
import static com.simibubi.create.CreateConfig.parameters;
|
||||
import static net.minecraft.state.properties.BlockStateProperties.AXIS;
|
||||
import static net.minecraft.util.Direction.AxisDirection.NEGATIVE;
|
||||
import static net.minecraft.util.Direction.AxisDirection.POSITIVE;
|
||||
|
@ -44,30 +45,20 @@ import net.minecraft.util.math.Vec3i;
|
|||
|
||||
public class EncasedFanTileEntity extends KineticTileEntity implements ITickableTileEntity {
|
||||
|
||||
public static final int PUSH_DISTANCE_MAX = 20;
|
||||
public static final int PULL_DISTANCE_MAX = 5;
|
||||
public static final int DISTANCE_ARGMAX = 6400;
|
||||
|
||||
public static final float PUSH_FORCE_MAX = 20;
|
||||
public static final float PULL_FORCE_MAX = 10;
|
||||
public static final int FORCE_ARGMAX = 6400;
|
||||
|
||||
public static final int BLOCK_CHECK_UPDATE_DELAY = 100;
|
||||
public static final Map<Block, List<FanEffect>> effects = new HashMap<>();
|
||||
|
||||
private static DamageSource damageSourceFire = new DamageSource("create.fan_fire").setDifficultyScaled()
|
||||
.setFireDamage();
|
||||
private static DamageSource damageSourceLava = new DamageSource("create.fan_lava").setDifficultyScaled()
|
||||
.setFireDamage();
|
||||
|
||||
protected BlockState frontBlock;
|
||||
protected float pushDistance;
|
||||
protected float pullDistance;
|
||||
protected float pushForce;
|
||||
protected float pullForce;
|
||||
protected AxisAlignedBB frontBB;
|
||||
protected AxisAlignedBB backBB;
|
||||
|
||||
protected int blockCheckCooldown;
|
||||
protected BlockState frontBlock;
|
||||
|
||||
protected boolean findLoadedItems;
|
||||
protected boolean findFrontBlock;
|
||||
public List<ProcessedItem> items;
|
||||
|
@ -157,7 +148,7 @@ public class EncasedFanTileEntity extends KineticTileEntity implements ITickable
|
|||
frontBB = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
|
||||
backBB = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
|
||||
items = new ArrayList<>();
|
||||
if (effects.isEmpty())
|
||||
// if (effects.isEmpty())
|
||||
initEffects();
|
||||
}
|
||||
|
||||
|
@ -165,8 +156,8 @@ public class EncasedFanTileEntity extends KineticTileEntity implements ITickable
|
|||
effects.clear();
|
||||
|
||||
List<FanEffect> standardFX = new ArrayList<>(2);
|
||||
standardFX.add(new FanEffect(ParticleTypes.BUBBLE_POP, 1 / 4f, 1 / 8f, 1 / 8f, 1));
|
||||
standardFX.add(new FanEffect(new RedstoneParticleData(1, 1, 1, 1), 1 / 2f, 1 / 32f, 0f, 512f));
|
||||
standardFX.add(new FanEffect(ParticleTypes.BUBBLE_POP, 1 / 4f, 1 / 4f, 1 / 3f, 1));
|
||||
standardFX.add(new FanEffect(new RedstoneParticleData(1, 1, 1, 1), 1 / 2f, 1 / 32f, 1/16f, 512f));
|
||||
effects.put(Blocks.AIR, standardFX);
|
||||
|
||||
List<FanEffect> waterFX = new ArrayList<>(2);
|
||||
|
@ -207,8 +198,6 @@ public class EncasedFanTileEntity extends KineticTileEntity implements ITickable
|
|||
|
||||
pushDistance = compound.getFloat("PushDistance");
|
||||
pullDistance = compound.getFloat("PullDistance");
|
||||
pushForce = compound.getFloat("PushForce");
|
||||
pullForce = compound.getFloat("PullForce");
|
||||
|
||||
ListNBT itemsNBT = compound.getList("Items", 10);
|
||||
items.clear();
|
||||
|
@ -223,8 +212,6 @@ public class EncasedFanTileEntity extends KineticTileEntity implements ITickable
|
|||
public CompoundNBT write(CompoundNBT compound) {
|
||||
compound.putFloat("PushDistance", pushDistance);
|
||||
compound.putFloat("PullDistance", pullDistance);
|
||||
compound.putFloat("PushForce", pushForce);
|
||||
compound.putFloat("PullForce", pullForce);
|
||||
|
||||
ListNBT itemsNBT = new ListNBT();
|
||||
for (ProcessedItem item : items) {
|
||||
|
@ -244,13 +231,10 @@ public class EncasedFanTileEntity extends KineticTileEntity implements ITickable
|
|||
return;
|
||||
|
||||
float speed = Math.abs(this.speed);
|
||||
float distanceFactor = Math.min(speed / DISTANCE_ARGMAX, 1);
|
||||
float forceFactor = Math.min(speed / FORCE_ARGMAX, 1);
|
||||
float distanceFactor = Math.min(speed / parameters.fanRotationArgmax.get(), 1);
|
||||
|
||||
pushDistance = MathHelper.lerp(distanceFactor, 3, PUSH_DISTANCE_MAX);
|
||||
pullDistance = MathHelper.lerp(distanceFactor, 1.5f, PULL_DISTANCE_MAX);
|
||||
pushForce = MathHelper.lerp(forceFactor, 1, PUSH_FORCE_MAX);
|
||||
pullForce = MathHelper.lerp(forceFactor, 1, PULL_FORCE_MAX);
|
||||
pushDistance = MathHelper.lerp(distanceFactor, 3, parameters.fanMaxPushDistance.get());
|
||||
pullDistance = MathHelper.lerp(distanceFactor, 1.5f, parameters.fanMaxPullDistance.get());
|
||||
|
||||
Direction direction = getAirFlow();
|
||||
if (speed != 0) {
|
||||
|
@ -345,7 +329,7 @@ public class EncasedFanTileEntity extends KineticTileEntity implements ITickable
|
|||
}
|
||||
|
||||
if (!world.isRemote && blockCheckCooldown-- <= 0) {
|
||||
blockCheckCooldown = BLOCK_CHECK_UPDATE_DELAY;
|
||||
blockCheckCooldown = parameters.fanBlockCheckRate.get();
|
||||
updateReachAndForce();
|
||||
}
|
||||
|
||||
|
@ -459,9 +443,10 @@ public class EncasedFanTileEntity extends KineticTileEntity implements ITickable
|
|||
float s = (float) (speed * 1 / modifier
|
||||
/ (entity.getPositionVec().distanceTo(center) / (push ? pushDistance : pullDistance)));
|
||||
Vec3d motion = entity.getMotion();
|
||||
double xIn = flow.getX() * s - motion.x;
|
||||
double yIn = flow.getY() * s - motion.y;
|
||||
double zIn = flow.getZ() * s - motion.z;
|
||||
float maxSpeedModifier = 5;
|
||||
double xIn = MathHelper.clamp(flow.getX() * s - motion.x, -maxSpeedModifier, maxSpeedModifier);
|
||||
double yIn = MathHelper.clamp(flow.getY() * s - motion.y, -maxSpeedModifier, maxSpeedModifier);
|
||||
double zIn = MathHelper.clamp(flow.getZ() * s - motion.z, -maxSpeedModifier, maxSpeedModifier);
|
||||
entity.setMotion(motion.add(new Vec3d(xIn, yIn, zIn).mul(flow.getX(), flow.getY(), flow.getZ()).scale(1 / 8f)));
|
||||
entity.fallDistance = 0;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import net.minecraft.util.math.MathHelper;
|
|||
public class ChassisTileEntity extends SyncedTileEntity implements ITickableTileEntity {
|
||||
|
||||
public static final int MAX_RANGE = 16;
|
||||
public static final int DEFAULT_RANGE = 8;
|
||||
private int range;
|
||||
|
||||
public int newRange;
|
||||
|
@ -19,7 +18,7 @@ public class ChassisTileEntity extends SyncedTileEntity implements ITickableTile
|
|||
|
||||
public ChassisTileEntity() {
|
||||
super(AllTileEntities.CHASSIS.type);
|
||||
newRange = range = DEFAULT_RANGE;
|
||||
newRange = range = MAX_RANGE / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create.modules.contraptions.receivers.constructs;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.CreateConfig;
|
||||
import com.simibubi.create.foundation.utility.ItemDescription;
|
||||
import com.simibubi.create.modules.contraptions.base.KineticBlock;
|
||||
|
||||
|
@ -120,7 +121,8 @@ public class MechanicalPistonBlock extends KineticBlock {
|
|||
BlockPos pistonHead = null;
|
||||
BlockPos pistonBase = pos;
|
||||
|
||||
for (int offset = 1; offset < TranslationConstruct.MAX_EXTENSIONS; offset++) {
|
||||
Integer maxPoles = CreateConfig.parameters.maxPistonPoles.get();
|
||||
for (int offset = 1; offset < maxPoles; offset++) {
|
||||
BlockPos currentPos = pos.offset(direction, offset);
|
||||
BlockState block = worldIn.getBlockState(currentPos);
|
||||
|
||||
|
@ -140,7 +142,7 @@ public class MechanicalPistonBlock extends KineticBlock {
|
|||
.forEach(p -> worldIn.destroyBlock(p, !player.isCreative()));
|
||||
}
|
||||
|
||||
for (int offset = 1; offset < TranslationConstruct.MAX_EXTENSIONS; offset++) {
|
||||
for (int offset = 1; offset < maxPoles; offset++) {
|
||||
BlockPos currentPos = pos.offset(direction.getOpposite(), offset);
|
||||
BlockState block = worldIn.getBlockState(currentPos);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create.modules.contraptions.receivers.constructs;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.CreateConfig;
|
||||
import com.simibubi.create.foundation.block.IWithoutBlockItem;
|
||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||
import com.simibubi.create.modules.contraptions.receivers.constructs.MechanicalPistonBlock.PistonState;
|
||||
|
@ -65,7 +66,7 @@ public class MechanicalPistonHeadBlock extends ProperDirectionalBlock implements
|
|||
BlockPos pistonHead = pos;
|
||||
BlockPos pistonBase = null;
|
||||
|
||||
for (int offset = 1; offset < TranslationConstruct.MAX_EXTENSIONS; offset++) {
|
||||
for (int offset = 1; offset < CreateConfig.parameters.maxPistonPoles.get(); offset++) {
|
||||
BlockPos currentPos = pos.offset(direction.getOpposite(), offset);
|
||||
BlockState block = worldIn.getBlockState(currentPos);
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.simibubi.create.modules.contraptions.receivers.constructs;
|
||||
|
||||
import static com.simibubi.create.CreateConfig.parameters;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
@ -207,8 +209,8 @@ public class MechanicalPistonTileEntity extends KineticTileEntity implements ITi
|
|||
BlockPos relativePos = BlockPos.ZERO.offset(movementDirection, getModulatedOffset(newOffset));
|
||||
|
||||
// Other moving Pistons
|
||||
int maxPossibleRange = TranslationConstruct.MAX_EXTENSIONS + TranslationConstruct.MAX_CHAINED_BLOCKS
|
||||
+ TranslationConstruct.MAX_CHAINED_CHASSIS;
|
||||
int maxPossibleRange = parameters.maxPistonPoles.get() + parameters.maxChassisRange.get()
|
||||
+ parameters.maxChassisForTranslation.get();
|
||||
Iterator<MechanicalPistonTileEntity> iterator = Create.constructHandler.getOtherMovingPistonsInWorld(this)
|
||||
.iterator();
|
||||
pistonLoop: while (iterator.hasNext()) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.receivers.constructs;
|
|||
import java.util.List;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.CreateConfig;
|
||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||
import com.simibubi.create.foundation.utility.ITooltip;
|
||||
import com.simibubi.create.foundation.utility.ItemDescription;
|
||||
|
@ -55,7 +56,8 @@ public class PistonPoleBlock extends ProperDirectionalBlock implements ITooltip
|
|||
BlockPos pistonBase = null;
|
||||
|
||||
for (int modifier : new int[] { 1, -1 }) {
|
||||
for (int offset = modifier; modifier * offset < TranslationConstruct.MAX_EXTENSIONS; offset += modifier) {
|
||||
for (int offset = modifier; modifier * offset < CreateConfig.parameters.maxPistonPoles
|
||||
.get(); offset += modifier) {
|
||||
BlockPos currentPos = pos.offset(direction, offset);
|
||||
BlockState block = worldIn.getBlockState(currentPos);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.CreateConfig;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.PistonBlock;
|
||||
|
@ -24,8 +25,6 @@ import net.minecraft.world.gen.feature.template.Template.BlockInfo;
|
|||
|
||||
public class RotationConstruct {
|
||||
|
||||
public static final int MAX_CHAINED_CHASSIS = 10;
|
||||
|
||||
protected Map<BlockPos, BlockInfo> blocks;
|
||||
|
||||
public RotationConstruct() {
|
||||
|
@ -62,7 +61,7 @@ public class RotationConstruct {
|
|||
|
||||
blocks.put(blockPos, new BlockInfo(blockPos.subtract(pos), state, null));
|
||||
|
||||
// Get attached blocks by chassis
|
||||
// Get attached blocks by chassis
|
||||
} else {
|
||||
List<BlockInfo> attachedBlocksByChassis = getAttachedBlocksByChassis(world, direction, chassis);
|
||||
if (attachedBlocksByChassis == null)
|
||||
|
@ -139,7 +138,7 @@ public class RotationConstruct {
|
|||
|
||||
private List<BlockInfo> collectChassis(World world, BlockPos pos, Direction direction) {
|
||||
List<BlockInfo> chassis = new ArrayList<>();
|
||||
for (int distance = 1; distance <= MAX_CHAINED_CHASSIS; distance++) {
|
||||
for (int distance = 1; distance <= CreateConfig.parameters.maxChassisForRotation.get(); distance++) {
|
||||
BlockPos currentPos = pos.offset(direction, distance);
|
||||
if (!world.isBlockPresent(currentPos))
|
||||
return chassis;
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.receivers.constructs;
|
|||
import static com.simibubi.create.AllBlocks.MECHANICAL_PISTON_HEAD;
|
||||
import static com.simibubi.create.AllBlocks.PISTON_POLE;
|
||||
import static com.simibubi.create.AllBlocks.STICKY_MECHANICAL_PISTON;
|
||||
import static com.simibubi.create.CreateConfig.parameters;
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -34,10 +35,6 @@ import net.minecraft.world.gen.feature.template.Template.BlockInfo;
|
|||
|
||||
public class TranslationConstruct {
|
||||
|
||||
public static final int MAX_EXTENSIONS = 20;
|
||||
public static final int MAX_CHAINED_CHASSIS = 12;
|
||||
public static final int MAX_CHAINED_BLOCKS = 8;
|
||||
|
||||
protected Map<BlockPos, BlockInfo> blocks;
|
||||
protected List<BlockInfo> actors;
|
||||
|
||||
|
@ -120,7 +117,7 @@ public class TranslationConstruct {
|
|||
extensionsInFront++;
|
||||
nextBlock = world.getBlockState(actualStart.offset(direction));
|
||||
|
||||
if (extensionsInFront > MAX_EXTENSIONS)
|
||||
if (extensionsInFront > parameters.maxPistonPoles.get())
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -143,7 +140,7 @@ public class TranslationConstruct {
|
|||
extensionsInBack++;
|
||||
nextBlock = world.getBlockState(end.offset(direction.getOpposite()));
|
||||
|
||||
if (extensionsInFront + extensionsInBack > MAX_EXTENSIONS)
|
||||
if (extensionsInFront + extensionsInBack > parameters.maxPistonPoles.get())
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -184,7 +181,7 @@ public class TranslationConstruct {
|
|||
collisionBoxFront = new AxisAlignedBB(blockPos);
|
||||
|
||||
} else {
|
||||
for (int distance = 1; distance <= MAX_CHAINED_BLOCKS + 1; distance++) {
|
||||
for (int distance = 1; distance <= parameters.maxChassisRange.get() + 1; distance++) {
|
||||
BlockPos currentPos = pos.offset(direction, distance);
|
||||
BlockState state = world.getBlockState(currentPos);
|
||||
|
||||
|
@ -199,7 +196,7 @@ public class TranslationConstruct {
|
|||
return false;
|
||||
|
||||
// Too many blocks
|
||||
if (distance == MAX_CHAINED_BLOCKS + 1)
|
||||
if (distance == parameters.maxChassisRange.get() + 1)
|
||||
return false;
|
||||
|
||||
BlockPos blockPos = currentPos.offset(direction, -offset);
|
||||
|
@ -340,11 +337,11 @@ public class TranslationConstruct {
|
|||
|
||||
private static List<BlockInfo> collectChassis(World world, BlockPos pos, Direction direction, int offset2) {
|
||||
List<BlockPos> search = new LinkedList<>();
|
||||
Set<BlockPos> visited = new HashSet<>(MAX_CHAINED_CHASSIS);
|
||||
Set<BlockPos> visited = new HashSet<>();
|
||||
List<BlockInfo> chassis = new LinkedList<>();
|
||||
search.add(pos.offset(direction));
|
||||
while (!search.isEmpty()) {
|
||||
if (chassis.size() > MAX_CHAINED_CHASSIS)
|
||||
if (chassis.size() > parameters.maxChassisForTranslation.get())
|
||||
return null;
|
||||
|
||||
BlockPos current = search.remove(0);
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.CreateConfig;
|
||||
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Part;
|
||||
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Slope;
|
||||
|
@ -23,8 +24,6 @@ import net.minecraft.world.World;
|
|||
|
||||
public class BeltItem extends Item {
|
||||
|
||||
public static final int MAX_PULLEY_DISTANCE = 20;
|
||||
|
||||
public BeltItem(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
@ -164,7 +163,7 @@ public class BeltItem extends Item {
|
|||
return false;
|
||||
if (!world.isAreaLoaded(second, 1))
|
||||
return false;
|
||||
if (!second.withinDistance(first, MAX_PULLEY_DISTANCE))
|
||||
if (!second.withinDistance(first, CreateConfig.parameters.maxBeltLength.get()))
|
||||
return false;
|
||||
|
||||
BlockPos diff = second.subtract(first);
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Random;
|
|||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.CreateConfig;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
@ -69,7 +70,7 @@ public class BeltItemHandler {
|
|||
return;
|
||||
if (!AllBlocks.SHAFT.typeOf(world.getBlockState(selected)))
|
||||
selected = selected.offset(((BlockRayTraceResult) rayTrace).getFace());
|
||||
if (!selected.withinDistance(first, BeltItem.MAX_PULLEY_DISTANCE))
|
||||
if (!selected.withinDistance(first, CreateConfig.parameters.maxBeltLength.get()))
|
||||
return;
|
||||
|
||||
boolean canConnect = BeltItem.validateAxis(world, selected) && BeltItem.canConnect(world, first, selected);
|
||||
|
|
|
@ -5,6 +5,8 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.simibubi.create.CreateConfig;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
@ -22,8 +24,6 @@ public class CocoaLogBlock extends RotatedPillarBlock implements IGrowable {
|
|||
|
||||
public static IntegerProperty AGE = BlockStateProperties.AGE_0_2;
|
||||
|
||||
private static final int GROWTH_CHANCE = 20;
|
||||
|
||||
public CocoaLogBlock() {
|
||||
super(Properties.from(Blocks.JUNGLE_LOG).tickRandomly());
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class CocoaLogBlock extends RotatedPillarBlock implements IGrowable {
|
|||
|
||||
@Override
|
||||
public void grow(World world, Random random, BlockPos pos, BlockState state) {
|
||||
if (random.nextInt(100 / GROWTH_CHANCE) != 0)
|
||||
if (random.nextDouble() > CreateConfig.parameters.cocoaLogGrowthSpeed.get() / 100D)
|
||||
return;
|
||||
|
||||
int age = state.get(AGE);
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Map;
|
|||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.CreateConfig;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -16,8 +17,6 @@ import net.minecraft.world.IWorld;
|
|||
|
||||
public class FrequencyHandler {
|
||||
|
||||
public static final int RANGE = 128;
|
||||
|
||||
static Map<IWorld, Map<Pair<Frequency, Frequency>, List<IHaveWireless>>> connections = new HashMap<>();
|
||||
|
||||
public static class Frequency {
|
||||
|
@ -110,7 +109,7 @@ public class FrequencyHandler {
|
|||
}
|
||||
|
||||
public static boolean withinRange(IHaveWireless from, IHaveWireless to) {
|
||||
return from.getPos().withinDistance(to.getPos(), RANGE);
|
||||
return from.getPos().withinDistance(to.getPos(), CreateConfig.parameters.linkRange.get());
|
||||
}
|
||||
|
||||
public Map<Pair<Frequency, Frequency>, List<IHaveWireless>> networksIn(IWorld world) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create.modules.logistics.block;
|
||||
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.CreateConfig;
|
||||
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -60,7 +61,7 @@ public class ExtractorTileEntity extends SyncedTileEntity implements IExtractor,
|
|||
@Override
|
||||
public void setState(State state) {
|
||||
if (state == State.ON_COOLDOWN)
|
||||
cooldown = EXTRACTOR_COOLDOWN;
|
||||
cooldown = CreateConfig.parameters.extractorDelay.get();
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simibubi.create.modules.logistics.block;
|
||||
|
||||
import com.simibubi.create.CreateConfig;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
|
@ -13,9 +14,6 @@ import net.minecraftforge.items.IItemHandler;
|
|||
// Its like delegation but better!
|
||||
public interface IExtractor extends ITickableTileEntity, IInventoryManipulator {
|
||||
|
||||
public static final int EXTRACTOR_COOLDOWN = 20;
|
||||
public static final int EXTRACTION_COUNT = 16;
|
||||
|
||||
public enum State {
|
||||
WAITING_FOR_INVENTORY, WAITING_FOR_ENTITY, RUNNING, ON_COOLDOWN, LOCKED;
|
||||
}
|
||||
|
@ -113,7 +111,7 @@ public interface IExtractor extends ITickableTileEntity, IInventoryManipulator {
|
|||
IItemHandler inv = getInventory().orElse(null);
|
||||
ItemStack extracting = ItemStack.EMPTY;
|
||||
ItemStack filter = (this instanceof IHaveFilter) ? filter = ((IHaveFilter) this).getFilter() : ItemStack.EMPTY;
|
||||
int extractionCount = filter.isEmpty() ? EXTRACTION_COUNT : filter.getCount();
|
||||
int extractionCount = filter.isEmpty() ? CreateConfig.parameters.extractorAmount.get() : filter.getCount();
|
||||
|
||||
for (int slot = 0; slot < inv.getSlots(); slot++) {
|
||||
ItemStack stack = inv.extractItem(slot, extractionCount - extracting.getCount(), true);
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.modules.logistics.block;
|
|||
import static net.minecraft.state.properties.BlockStateProperties.POWERED;
|
||||
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.CreateConfig;
|
||||
import com.simibubi.create.modules.logistics.IReceiveWireless;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -67,7 +68,7 @@ public class LinkedExtractorTileEntity extends LinkedTileEntity
|
|||
@Override
|
||||
public void setState(State state) {
|
||||
if (state == State.ON_COOLDOWN)
|
||||
cooldown = EXTRACTOR_COOLDOWN;
|
||||
cooldown = CreateConfig.parameters.extractorDelay.get();
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.modules.schematics;
|
||||
|
||||
import static com.simibubi.create.modules.schematics.ServerSchematicLoader.MAX_PACKET_SIZE;
|
||||
import static com.simibubi.create.CreateConfig.parameters;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -66,12 +66,12 @@ public class ClientSchematicLoader {
|
|||
long size = Files.size(path);
|
||||
|
||||
// Too big
|
||||
if (size > ServerSchematicLoader.MAX_SCHEMATIC_FILE_SIZE) {
|
||||
Integer maxSize = parameters.maxTotalSchematicSize.get();
|
||||
if (size > maxSize * 1000) {
|
||||
Minecraft.getInstance().player
|
||||
.sendMessage(new StringTextComponent("Your schematic is too large (" + size / 1024 + " KB)."));
|
||||
Minecraft.getInstance().player
|
||||
.sendMessage(new StringTextComponent("The maximum allowed schematic file size is: "
|
||||
+ ServerSchematicLoader.MAX_SCHEMATIC_FILE_SIZE / 1024 + " KB"));
|
||||
.sendMessage(new StringTextComponent("Your schematic is too large (" + size / 1000 + " KB)."));
|
||||
Minecraft.getInstance().player.sendMessage(
|
||||
new StringTextComponent("The maximum allowed schematic file size is: " + maxSize + " KB"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -85,10 +85,11 @@ public class ClientSchematicLoader {
|
|||
|
||||
private void continueUpload(String schematic) {
|
||||
if (activeUploads.containsKey(schematic)) {
|
||||
byte[] data = new byte[MAX_PACKET_SIZE];
|
||||
Integer maxPacketSize = parameters.maxSchematicPacketSize.get();
|
||||
byte[] data = new byte[maxPacketSize];
|
||||
try {
|
||||
int status = activeUploads.get(schematic).read(data);
|
||||
if (status < MAX_PACKET_SIZE) {
|
||||
if (status < maxPacketSize) {
|
||||
data = Arrays.copyOf(data, status);
|
||||
}
|
||||
|
||||
|
@ -99,7 +100,7 @@ public class ClientSchematicLoader {
|
|||
return;
|
||||
}
|
||||
|
||||
if (status < MAX_PACKET_SIZE)
|
||||
if (status < maxPacketSize)
|
||||
finishUpload(schematic);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.simibubi.create.modules.schematics;
|
||||
|
||||
import static com.simibubi.create.CreateConfig.parameters;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
|
@ -28,12 +30,6 @@ import net.minecraft.util.text.StringTextComponent;
|
|||
|
||||
public class ServerSchematicLoader {
|
||||
|
||||
public static final String PATH = "schematics/uploaded";
|
||||
public static final int IDLE_TIMEOUT = 600;
|
||||
public static final int MAX_PACKET_SIZE = 1024;
|
||||
public static final int MAX_SCHEMATICS_PER_PLAYER = 10;
|
||||
public static final int MAX_SCHEMATIC_FILE_SIZE = 256 * 1024; // 256 kiB
|
||||
|
||||
private Map<String, SchematicUploadEntry> activeUploads;
|
||||
|
||||
public class SchematicUploadEntry {
|
||||
|
@ -54,8 +50,11 @@ public class ServerSchematicLoader {
|
|||
|
||||
public ServerSchematicLoader() {
|
||||
activeUploads = new HashMap<>();
|
||||
FilesHelper.createFolderIfMissing("schematics");
|
||||
FilesHelper.createFolderIfMissing(PATH);
|
||||
FilesHelper.createFolderIfMissing(getSchematicPath());
|
||||
}
|
||||
|
||||
public String getSchematicPath() {
|
||||
return parameters.schematicPath.get();
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
|
@ -64,7 +63,7 @@ public class ServerSchematicLoader {
|
|||
for (String upload : activeUploads.keySet()) {
|
||||
SchematicUploadEntry entry = activeUploads.get(upload);
|
||||
|
||||
if (entry.idleTime++ > IDLE_TIMEOUT) {
|
||||
if (entry.idleTime++ > parameters.schematicIdleTimeout.get()) {
|
||||
Create.logger.warn("Schematic Upload timed out: " + upload);
|
||||
deadEntries.add(upload);
|
||||
}
|
||||
|
@ -81,7 +80,7 @@ public class ServerSchematicLoader {
|
|||
}
|
||||
|
||||
public void handleNewUpload(ServerPlayerEntity player, String schematic, long size, DimensionPos dimPos) {
|
||||
String playerPath = PATH + "/" + player.getName().getFormattedText();
|
||||
String playerPath = getSchematicPath() + "/" + player.getName().getFormattedText();
|
||||
String playerSchematicId = player.getName().getFormattedText() + "/" + schematic;
|
||||
FilesHelper.createFolderIfMissing(playerPath);
|
||||
|
||||
|
@ -91,10 +90,11 @@ public class ServerSchematicLoader {
|
|||
}
|
||||
|
||||
// Too big
|
||||
if (size > MAX_SCHEMATIC_FILE_SIZE) {
|
||||
player.sendMessage(new StringTextComponent("Your schematic is too large (" + size/1024 + " KB)."));
|
||||
player.sendMessage(new StringTextComponent(
|
||||
"The maximum allowed schematic file size is: " + MAX_SCHEMATIC_FILE_SIZE/1024 + " KB"));
|
||||
Integer maxFileSize = parameters.maxTotalSchematicSize.get();
|
||||
if (size > maxFileSize * 1000) {
|
||||
player.sendMessage(new StringTextComponent("Your schematic is too large (" + size / 1000 + " KB)."));
|
||||
player.sendMessage(
|
||||
new StringTextComponent("The maximum allowed schematic file size is: " + maxFileSize + " KB"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -109,11 +109,11 @@ public class ServerSchematicLoader {
|
|||
return;
|
||||
|
||||
// Delete schematic with same name
|
||||
Files.deleteIfExists(Paths.get(PATH, playerSchematicId));
|
||||
Files.deleteIfExists(Paths.get(getSchematicPath(), playerSchematicId));
|
||||
|
||||
// Too many Schematics
|
||||
Stream<Path> list = Files.list(Paths.get(playerPath));
|
||||
if (list.count() >= MAX_SCHEMATICS_PER_PLAYER) {
|
||||
if (list.count() >= parameters.maxSchematics.get()) {
|
||||
Stream<Path> list2 = Files.list(Paths.get(playerPath));
|
||||
Optional<Path> lastFilePath = list2.filter(f -> !Files.isDirectory(f))
|
||||
.min(Comparator.comparingLong(f -> f.toFile().lastModified()));
|
||||
|
@ -125,7 +125,7 @@ public class ServerSchematicLoader {
|
|||
list.close();
|
||||
|
||||
// Open Stream
|
||||
OutputStream writer = Files.newOutputStream(Paths.get(PATH, playerSchematicId),
|
||||
OutputStream writer = Files.newOutputStream(Paths.get(getSchematicPath(), playerSchematicId),
|
||||
StandardOpenOption.CREATE_NEW);
|
||||
activeUploads.put(playerSchematicId, new SchematicUploadEntry(writer, size, dimPos));
|
||||
|
||||
|
@ -147,7 +147,7 @@ public class ServerSchematicLoader {
|
|||
entry.bytesUploaded += data.length;
|
||||
|
||||
// Size Validations
|
||||
if (data.length > MAX_PACKET_SIZE) {
|
||||
if (data.length > parameters.maxSchematicPacketSize.get()) {
|
||||
Create.logger.warn("Oversized Upload Packet received: " + playerSchematicId);
|
||||
cancelUpload(playerSchematicId);
|
||||
return;
|
||||
|
@ -186,7 +186,7 @@ public class ServerSchematicLoader {
|
|||
SchematicUploadEntry entry = activeUploads.remove(playerSchematicId);
|
||||
try {
|
||||
entry.stream.close();
|
||||
Files.deleteIfExists(Paths.get(PATH, playerSchematicId));
|
||||
Files.deleteIfExists(Paths.get(getSchematicPath(), playerSchematicId));
|
||||
Create.logger.warn("Cancelled Schematic Upload: " + playerSchematicId);
|
||||
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -146,8 +146,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
|
|||
if (w instanceof IconButton)
|
||||
if (!((IconButton) w).getToolTip().isEmpty()) {
|
||||
((IconButton) w).setToolTip(((IconButton) w).getToolTip().get(0));
|
||||
((IconButton) w).getToolTip()
|
||||
.add(TextFormatting.DARK_GRAY + "< Hold Shift >");
|
||||
((IconButton) w).getToolTip().add(TextFormatting.DARK_GRAY + "< Hold Shift >");
|
||||
}
|
||||
|
||||
if (hasShiftDown()) {
|
||||
|
@ -292,9 +291,10 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
|
|||
if (mouseX >= fuelX && mouseY >= fuelY && mouseX <= fuelX + ScreenResources.SCHEMATICANNON_FUEL.width
|
||||
&& mouseY <= fuelY + ScreenResources.SCHEMATICANNON_FUEL.height) {
|
||||
container.getTileEntity();
|
||||
int shotsLeft = (int) (te.fuelLevel / SchematicannonTileEntity.FUEL_USAGE_RATE);
|
||||
int shotsLeftWithItems = (int) (shotsLeft + te.inventory.getStackInSlot(4).getCount()
|
||||
* (SchematicannonTileEntity.FUEL_PER_GUNPOWDER / SchematicannonTileEntity.FUEL_USAGE_RATE));
|
||||
double fuelUsageRate = te.getFuelUsageRate();
|
||||
int shotsLeft = (int) (te.fuelLevel / fuelUsageRate);
|
||||
int shotsLeftWithItems = (int) (shotsLeft
|
||||
+ te.inventory.getStackInSlot(4).getCount() * (te.getFuelAddedByGunPowder() / fuelUsageRate));
|
||||
renderTooltip(
|
||||
ImmutableList.of("Gunpowder at " + (int) (te.fuelLevel * 100) + "%",
|
||||
TextFormatting.GRAY + "Shots left: " + TextFormatting.BLUE + shotsLeft,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.simibubi.create.modules.schematics.block;
|
||||
|
||||
import static com.simibubi.create.CreateConfig.parameters;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -53,10 +55,6 @@ import net.minecraftforge.items.ItemStackHandler;
|
|||
public class SchematicannonTileEntity extends SyncedTileEntity implements ITickableTileEntity, INamedContainerProvider {
|
||||
|
||||
public static final int NEIGHBOUR_CHECKING = 100;
|
||||
public static final int PLACEMENT_DELAY = 10;
|
||||
public static final float FUEL_PER_GUNPOWDER = .2f;
|
||||
public static final float FUEL_USAGE_RATE = .0005f;
|
||||
public static final int SKIPS_PER_TICK = 10;
|
||||
public static final int MAX_ANCHOR_DISTANCE = 256;
|
||||
|
||||
public enum State {
|
||||
|
@ -66,8 +64,8 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka
|
|||
// Inventory
|
||||
public SchematicannonInventory inventory;
|
||||
|
||||
// Sync
|
||||
public boolean sendUpdate;
|
||||
// Sync
|
||||
public boolean dontUpdateChecklist;
|
||||
public int neighbourCheckCooldown;
|
||||
|
||||
|
@ -364,7 +362,7 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka
|
|||
refillFuelIfPossible();
|
||||
|
||||
// Update Printer
|
||||
skipsLeft = SKIPS_PER_TICK;
|
||||
skipsLeft = parameters.schematicannonSkips.get();
|
||||
blockSkipped = true;
|
||||
|
||||
while (blockSkipped && skipsLeft-- > 0)
|
||||
|
@ -399,7 +397,7 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka
|
|||
return;
|
||||
}
|
||||
|
||||
if (state == State.PAUSED && !blockNotLoaded && missingBlock == null && fuelLevel > FUEL_USAGE_RATE)
|
||||
if (state == State.PAUSED && !blockNotLoaded && missingBlock == null && fuelLevel > getFuelUsageRate())
|
||||
return;
|
||||
|
||||
// Initialize Printer
|
||||
|
@ -493,12 +491,16 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka
|
|||
else
|
||||
statusMsg = "Clearing Blocks";
|
||||
launchBlock(target, blockState);
|
||||
printerCooldown = PLACEMENT_DELAY;
|
||||
fuelLevel -= FUEL_USAGE_RATE;
|
||||
printerCooldown = parameters.schematicannonDelay.get();
|
||||
fuelLevel -= getFuelUsageRate();
|
||||
sendUpdate = true;
|
||||
missingBlock = null;
|
||||
}
|
||||
|
||||
public double getFuelUsageRate() {
|
||||
return parameters.schematicannonFuelUsage.get() / 100f;
|
||||
}
|
||||
|
||||
protected void initializePrinter(ItemStack blueprint) {
|
||||
if (!blueprint.hasTag()) {
|
||||
state = State.STOPPED;
|
||||
|
@ -689,16 +691,20 @@ public class SchematicannonTileEntity extends SyncedTileEntity implements ITicka
|
|||
}
|
||||
|
||||
protected void refillFuelIfPossible() {
|
||||
if (1 - fuelLevel + 1 / 128f < FUEL_PER_GUNPOWDER)
|
||||
if (1 - fuelLevel + 1 / 128f < getFuelAddedByGunPowder())
|
||||
return;
|
||||
if (inventory.getStackInSlot(4).isEmpty())
|
||||
return;
|
||||
|
||||
inventory.getStackInSlot(4).shrink(1);
|
||||
fuelLevel += FUEL_PER_GUNPOWDER;
|
||||
fuelLevel += getFuelAddedByGunPowder();
|
||||
sendUpdate = true;
|
||||
}
|
||||
|
||||
public double getFuelAddedByGunPowder() {
|
||||
return parameters.schematicannonGunpowderWorth.get() / 100f;
|
||||
}
|
||||
|
||||
protected void tickPaperPrinter() {
|
||||
int BookInput = 2;
|
||||
int BookOutput = 3;
|
||||
|
|
|
@ -32,12 +32,9 @@ public abstract class SchematicToolBase implements ISchematicTool {
|
|||
public boolean renderSelectedFace;
|
||||
public Direction selectedFace;
|
||||
|
||||
public SchematicToolBase() {
|
||||
schematicHandler = CreateClient.schematicHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
schematicHandler = CreateClient.schematicHandler;
|
||||
selectedPos = null;
|
||||
selectedFace = null;
|
||||
schematicSelected = false;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.simibubi.create.modules.symmetry;
|
||||
|
||||
import static com.simibubi.create.CreateConfig.parameters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -186,7 +188,7 @@ public class SymmetryWandItem extends InfoItem {
|
|||
SymmetryMirror symmetry = SymmetryMirror.fromNBT((CompoundNBT) wand.getTag().getCompound($SYMMETRY));
|
||||
|
||||
Vec3d mirrorPos = symmetry.getPosition();
|
||||
if (mirrorPos.distanceTo(new Vec3d(pos)) > 50)
|
||||
if (mirrorPos.distanceTo(new Vec3d(pos)) > parameters.maxSymmetryWandRange.get())
|
||||
return;
|
||||
if (!player.isCreative() && BlockHelper.findAndRemoveInInventory(block, player, 1) == 0)
|
||||
return;
|
||||
|
@ -241,7 +243,7 @@ public class SymmetryWandItem extends InfoItem {
|
|||
SymmetryMirror symmetry = SymmetryMirror.fromNBT((CompoundNBT) wand.getTag().getCompound($SYMMETRY));
|
||||
|
||||
Vec3d mirrorPos = symmetry.getPosition();
|
||||
if (mirrorPos.distanceTo(new Vec3d(pos)) > 50)
|
||||
if (mirrorPos.distanceTo(new Vec3d(pos)) > parameters.maxSymmetryWandRange.get())
|
||||
return;
|
||||
|
||||
symmetry.process(blockSet);
|
||||
|
|
Loading…
Reference in a new issue