mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-10-26 14:24:40 +00:00
Added support for changing conduit size via the config file.
This commit is contained in:
1 parent
28a4693cab
commit
86f2ff3fd3
6 files changed
+87
-38
No files matched your search
@@ -83,7 +83,7 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
// Renderers
|
||||
|
||||
ConduitBundleRenderer cbr = new ConduitBundleRenderer();
|
||||
ConduitBundleRenderer cbr = new ConduitBundleRenderer((float)Config.conduitScale);
|
||||
BlockConduitBundle.rendererId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(cbr);
|
||||
|
||||
@@ -119,7 +119,7 @@ public class ClientProxy extends CommonProxy {
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemConduitFacade.itemID, new FacadeRenderer());
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileConduitBundle.class, cbr);
|
||||
conduitRenderers.add(RedstoneSwitchRenderer.instance);
|
||||
conduitRenderers.add(RedstoneSwitchRenderer.createInstance((float)Config.conduitScale));
|
||||
conduitRenderers.add(new LiquidConduitRenderer());
|
||||
|
||||
EnderIoRenderer eior = new EnderIoRenderer();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package crazypants.enderio;
|
||||
|
||||
import crazypants.vecmath.VecmathUtil;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
|
||||
public final class Config {
|
||||
@@ -7,13 +8,22 @@ public final class Config {
|
||||
static int BID = 700;
|
||||
static int IID = 8524;
|
||||
|
||||
|
||||
public static final double DEFAULT_CONDUIT_SCALE = 0.2;
|
||||
|
||||
public static boolean useAlternateBinderRecipe;
|
||||
|
||||
public static double conduitScale = DEFAULT_CONDUIT_SCALE;
|
||||
|
||||
public static void load(Configuration config) {
|
||||
for (ModObject e : ModObject.values()) {
|
||||
e.load(config);
|
||||
}
|
||||
useAlternateBinderRecipe = config.get("Settings", "useAlternateBinderRecipe", false).getBoolean(false);
|
||||
conduitScale = config.get("Settings", "conduitScale", DEFAULT_CONDUIT_SCALE,
|
||||
"Valid values are between 0-1, smallest conduits at 0, largest at 1.\n" +
|
||||
"In SMP, all clients must be using the same value as the server.").getDouble(DEFAULT_CONDUIT_SCALE);
|
||||
conduitScale = VecmathUtil.clamp(conduitScale, 0, 1);
|
||||
}
|
||||
|
||||
private Config() {
|
||||
|
||||
@@ -21,6 +21,7 @@ import crazypants.enderio.conduit.BlockConduitBundle;
|
||||
import crazypants.enderio.conduit.ConduitRecipes;
|
||||
import crazypants.enderio.conduit.facade.BlockConduitFacade;
|
||||
import crazypants.enderio.conduit.facade.ItemConduitFacade;
|
||||
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
|
||||
import crazypants.enderio.conduit.liquid.ItemLiquidConduit;
|
||||
import crazypants.enderio.conduit.power.ItemPowerConduit;
|
||||
import crazypants.enderio.conduit.redstone.ItemRedstoneConduit;
|
||||
@@ -114,6 +115,8 @@ public class EnderIO {
|
||||
cfg.save();
|
||||
}
|
||||
}
|
||||
|
||||
ConduitGeometryUtil.setupBounds((float)Config.conduitScale);
|
||||
|
||||
itemIndustrialBinder = ItemIndustrialBinder.create();
|
||||
itemBasicCapacitor = ItemCapacitor.create();
|
||||
|
||||
@@ -14,20 +14,40 @@ public class ConduitGeometryUtil {
|
||||
|
||||
public static final ConduitGeometryUtil instance = new ConduitGeometryUtil();
|
||||
|
||||
public static final float STUB_WIDTH = 0.2f;
|
||||
public static final float STUB_HEIGHT = 0.2f;
|
||||
public static float STUB_WIDTH = 0.2f;
|
||||
public static float STUB_HEIGHT = 0.2f;
|
||||
|
||||
public static float WIDTH;
|
||||
public static float HEIGHT;
|
||||
|
||||
public static final float WIDTH = 0.075f;
|
||||
public static final float HEIGHT = 0.075f;
|
||||
|
||||
public static final float HWIDTH = WIDTH / 2;
|
||||
public static final float HHEIGHT = HEIGHT / 2;
|
||||
public static float HWIDTH;
|
||||
public static float HHEIGHT;
|
||||
|
||||
// All values are for a single conduit core
|
||||
public static final Vector3d CORE_MIN = new Vector3d(0.5f - HWIDTH, 0.5 - HHEIGHT, 0.5 - HWIDTH);
|
||||
public static final Vector3d CORE_MAX = new Vector3d(CORE_MIN.x + WIDTH, CORE_MIN.y + HEIGHT, CORE_MIN.z + WIDTH);
|
||||
public static final BoundingBox CORE_BOUNDS = new BoundingBox(CORE_MIN, CORE_MAX);
|
||||
public static Vector3d CORE_MIN;
|
||||
public static Vector3d CORE_MAX;
|
||||
public static BoundingBox CORE_BOUNDS;
|
||||
|
||||
static {
|
||||
setupBounds(0.5f);
|
||||
}
|
||||
|
||||
|
||||
public static void setupBounds(float scale) {
|
||||
float size = 0.075f + (0.175f * scale);
|
||||
|
||||
WIDTH = size;
|
||||
HEIGHT = size;
|
||||
HWIDTH = WIDTH / 2;
|
||||
HHEIGHT = HEIGHT / 2;
|
||||
|
||||
CORE_MIN = new Vector3d(0.5f - HWIDTH, 0.5 - HHEIGHT, 0.5 - HWIDTH);
|
||||
CORE_MAX = new Vector3d(CORE_MIN.x + WIDTH, CORE_MIN.y + HEIGHT, CORE_MIN.z + WIDTH);
|
||||
CORE_BOUNDS = new BoundingBox(CORE_MIN, CORE_MAX);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Map<GeometryKey, BoundingBox> boundsCache = new HashMap<GeometryKey, BoundingBox>();
|
||||
|
||||
private EnumMap<ConduitConnectorType, BoundingBox> connectorBounds = new EnumMap<ConduitConnectorType, BoundingBox>(ConduitConnectorType.class);
|
||||
|
||||
@@ -18,17 +18,19 @@ import crazypants.vecmath.Vector3d;
|
||||
|
||||
public class RedstoneSwitchRenderer extends DefaultConduitRenderer {
|
||||
|
||||
public static RedstoneSwitchRenderer instance = new RedstoneSwitchRenderer();
|
||||
|
||||
|
||||
|
||||
|
||||
private static final float SIZE = 0.2f;
|
||||
private static final float HW = SIZE / 3;
|
||||
private static final float HH = SIZE / 2;
|
||||
private static final float DEPTH = 0.05f;
|
||||
private static final float HD = DEPTH / 2;
|
||||
|
||||
private static final float DIST = 0.25f;
|
||||
|
||||
private static final float CON_HW = 0.015f;
|
||||
|
||||
static RedstoneSwitchRenderer instance;
|
||||
|
||||
public static RedstoneSwitchRenderer createInstance(float conduitScale) {
|
||||
instance = new RedstoneSwitchRenderer(conduitScale);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final VertexTransform[] xForms;
|
||||
private final BoundingBox switchBounds;
|
||||
@@ -36,11 +38,21 @@ public class RedstoneSwitchRenderer extends DefaultConduitRenderer {
|
||||
|
||||
private final BoundingBox[] aabb;
|
||||
|
||||
private RedstoneSwitchRenderer() {
|
||||
BoundingBox bb = new BoundingBox(0.5 - HW, 0.5 - HH, 0.5 - HD, 0.5 + HW, 0.5 + HH, 0.5 + HD);
|
||||
switchBounds = bb.translate(0, 0, DIST);
|
||||
private RedstoneSwitchRenderer(float conduitScale) {
|
||||
|
||||
float size = Math.max(0.2f, conduitScale * 0.5f);
|
||||
float halfWidth = size / 3;
|
||||
float halfHeight = size / 2;
|
||||
|
||||
//float DEPTH = 0.05f;
|
||||
float halfDepth = 0.025f;
|
||||
float distance = Math.max(0.25f, conduitScale * 0.3f);
|
||||
|
||||
connectorBounds = new BoundingBox(0.5 - CON_HW, 0.5 - CON_HW, 0.5 - CON_HW, 0.5 + CON_HW, 0.5 + CON_HW, 0.5 + DIST);
|
||||
BoundingBox bb = new BoundingBox(0.5 - halfWidth, 0.5 - halfHeight, 0.5 - halfDepth, 0.5 + halfWidth, 0.5 + halfHeight, 0.5 + halfDepth);
|
||||
switchBounds = bb.translate(0, 0, distance);
|
||||
|
||||
float connectorHalfWidth = (float)Math.max(0.015, conduitScale * 0.05);
|
||||
connectorBounds = new BoundingBox(0.5 - connectorHalfWidth, 0.5 - connectorHalfWidth, 0.5 - connectorHalfWidth, 0.5 + connectorHalfWidth, 0.5 + connectorHalfWidth, 0.5 + distance);
|
||||
|
||||
Vector3d axis = new Vector3d(0, 1, 0);
|
||||
Vector3d p = new Vector3d(0.5, 0.5, 0.5);
|
||||
|
||||
@@ -35,14 +35,18 @@ import crazypants.render.RenderUtil;
|
||||
|
||||
public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
private static final float CONNECTOR_DEPTH = 0.05f;
|
||||
private static final float CONNECTOR_WIDTH = 0.3f;
|
||||
|
||||
|
||||
private Map<ForgeDirection, BoundingBox[]> connectorBounds = new HashMap<ForgeDirection, BoundingBox[]>();
|
||||
|
||||
public ConduitBundleRenderer() {
|
||||
public ConduitBundleRenderer(float conduitScale) {
|
||||
|
||||
float connectorDepth = 0.05f;
|
||||
//float connectorWidth = 0.3f;
|
||||
float connectorWidth = 0.25f + (conduitScale * 0.5f);
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
connectorBounds.put(dir, createConnector(dir));
|
||||
connectorBounds.put(dir, createConnector(dir, connectorDepth, connectorWidth));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,21 +126,21 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
}
|
||||
}
|
||||
|
||||
private static BoundingBox[] createConnector(ForgeDirection dir) {
|
||||
private BoundingBox[] createConnector(ForgeDirection dir, float connectorDepth, float connectorWidth) {
|
||||
|
||||
BoundingBox[] res = new BoundingBox[2];
|
||||
|
||||
float cMin = 0.5f - CONNECTOR_WIDTH / 2;
|
||||
float cMax = 0.5f + CONNECTOR_WIDTH / 2;
|
||||
float dMin = 1 - CONNECTOR_DEPTH / 2;
|
||||
float cMin = 0.5f - connectorWidth / 2;
|
||||
float cMax = 0.5f + connectorWidth / 2;
|
||||
float dMin = 1 - connectorDepth / 2;
|
||||
float dMax = 1;
|
||||
|
||||
res[0] = createConnectorComponent(dir, cMin, cMax, dMin, dMax);
|
||||
|
||||
cMin = 0.5f - CONNECTOR_WIDTH / 3;
|
||||
cMax = 0.5f + CONNECTOR_WIDTH / 3;
|
||||
dMin = 1 - CONNECTOR_DEPTH;
|
||||
dMax = 1 - CONNECTOR_DEPTH / 2;
|
||||
cMin = 0.5f - connectorWidth / 3;
|
||||
cMax = 0.5f + connectorWidth / 3;
|
||||
dMin = 1 - connectorDepth;
|
||||
dMax = 1 - connectorDepth / 2;
|
||||
|
||||
res[1] = createConnectorComponent(dir, cMin, cMax, dMin, dMax);
|
||||
|
||||
|
||||
Reference in new issue
Block a user