mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-10-26 14:24:40 +00:00
Fixed server crash when using conduit switch.
This commit is contained in:
1 parent
8b48129ab0
commit
fcc1051561
4 files changed
+73
-50
No files matched your search
@@ -119,7 +119,7 @@ public class ClientProxy extends CommonProxy {
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemConduitFacade.itemID, new FacadeRenderer());
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileConduitBundle.class, cbr);
|
||||
conduitRenderers.add(RedstoneSwitchRenderer.createInstance((float)Config.conduitScale));
|
||||
conduitRenderers.add(RedstoneSwitchRenderer.getInstance());
|
||||
conduitRenderers.add(new LiquidConduitRenderer());
|
||||
|
||||
EnderIoRenderer eior = new EnderIoRenderer();
|
||||
|
||||
@@ -97,7 +97,7 @@ public class RedstoneSwitch extends RedstoneConduit {
|
||||
Vector3d trans = ConduitGeometryUtil.instance.getTranslation(ForgeDirection.UNKNOWN, o);
|
||||
|
||||
List<CollidableComponent> result = super.getCollidableComponents();
|
||||
BoundingBox[] aabb = RedstoneSwitchRenderer.instance.getAABB();
|
||||
BoundingBox[] aabb = RedstoneSwitchBounds.getInstance().getAABB();
|
||||
|
||||
for (BoundingBox bb : aabb) {
|
||||
result.add(new CollidableComponent(IRedstoneConduit.class, bb.translate(trans), ForgeDirection.UNKNOWN, SWITCH_TAG));
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package crazypants.enderio.conduit.redstone;
|
||||
|
||||
import crazypants.enderio.Config;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.VertexRotation;
|
||||
import crazypants.render.VertexTransform;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
public class RedstoneSwitchBounds {
|
||||
|
||||
private static RedstoneSwitchBounds instance;
|
||||
|
||||
public static final RedstoneSwitchBounds getInstance() {
|
||||
if(instance == null) {
|
||||
instance = new RedstoneSwitchBounds();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
final VertexTransform[] xForms;
|
||||
final BoundingBox switchBounds;
|
||||
final BoundingBox connectorBounds;
|
||||
|
||||
private final BoundingBox[] aabb;
|
||||
|
||||
RedstoneSwitchBounds() {
|
||||
|
||||
float conduitScale = (float) Config.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);
|
||||
|
||||
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);
|
||||
xForms = new VertexTransform[4];
|
||||
double angle = Math.toRadians(45);
|
||||
for (int i = 0; i < xForms.length; i++) {
|
||||
xForms[i] = new VertexRotation(angle, axis, p);
|
||||
angle += Math.toRadians(90);
|
||||
}
|
||||
|
||||
aabb = new BoundingBox[xForms.length];
|
||||
for (int i = 0; i < xForms.length; i++) {
|
||||
aabb[i] = switchBounds.transform(xForms[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public BoundingBox[] getAABB() {
|
||||
return aabb;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,64 +17,23 @@ import crazypants.render.VertexTransform;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
public class RedstoneSwitchRenderer extends DefaultConduitRenderer {
|
||||
|
||||
|
||||
private static final RedstoneSwitchRenderer instance = new RedstoneSwitchRenderer();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static RedstoneSwitchRenderer instance;
|
||||
|
||||
public static RedstoneSwitchRenderer createInstance(float conduitScale) {
|
||||
instance = new RedstoneSwitchRenderer(conduitScale);
|
||||
public static RedstoneSwitchRenderer getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final VertexTransform[] xForms;
|
||||
private final BoundingBox switchBounds;
|
||||
private final BoundingBox connectorBounds;
|
||||
|
||||
private final BoundingBox[] aabb;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
xForms = new VertexTransform[4];
|
||||
double angle = Math.toRadians(45);
|
||||
for (int i = 0; i < xForms.length; i++) {
|
||||
// TODO
|
||||
// xForms[i] = new Rotation(angle, axis, p);
|
||||
xForms[i] = new VertexRotation(angle, axis, p);
|
||||
angle += Math.toRadians(90);
|
||||
}
|
||||
|
||||
aabb = new BoundingBox[xForms.length];
|
||||
for (int i = 0; i < xForms.length; i++) {
|
||||
aabb[i] = switchBounds.transform(xForms[i]);
|
||||
}
|
||||
|
||||
private RedstoneSwitchRenderer() {
|
||||
xForms = RedstoneSwitchBounds.getInstance().xForms;
|
||||
switchBounds = RedstoneSwitchBounds.getInstance().switchBounds;
|
||||
connectorBounds = RedstoneSwitchBounds.getInstance().connectorBounds;
|
||||
}
|
||||
|
||||
public BoundingBox[] getAABB() {
|
||||
return aabb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRendererForConduit(IConduit conduit) {
|
||||
@@ -119,4 +78,5 @@ public class RedstoneSwitchRenderer extends DefaultConduitRenderer {
|
||||
return !RedstoneSwitch.SWITCH_TAG.equals(component.data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user