Skip to content

Commit 93fc723

Browse files
committed
changed connection rendering to use baked models instead of TESR, should improve FPS
fixed wires not outputting to RF-only outputs, closes BluSunrize#1081 fixed connections on HV relays
1 parent 4e54dd3 commit 93fc723

34 files changed

+688
-1592
lines changed

gradlew

100644100755
File mode changed.

src/main/java/blusunrize/immersiveengineering/api/ApiUtils.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package blusunrize.immersiveengineering.api;
22

3+
import static blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection.vertices;
4+
35
import java.util.ArrayList;
46
import java.util.Comparator;
57
import java.util.Iterator;
@@ -237,7 +239,7 @@ public static Vec3[] getConnectionCatenary(Connection connection, Vec3 start, Ve
237239
boolean vertical = connection.end.getX()==connection.start.getX() && connection.end.getZ()==connection.start.getZ();
238240

239241
if(vertical)
240-
return new Vec3[]{new Vec3(end.xCoord, end.yCoord, end.zCoord)};
242+
return new Vec3[]{new Vec3(start.xCoord, start.yCoord, start.zCoord), new Vec3(end.xCoord, end.yCoord, end.zCoord)};
241243

242244
double dx = (end.xCoord)-(start.xCoord);
243245
double dy = (end.yCoord)-(start.yCoord);
@@ -257,12 +259,12 @@ public static Vec3[] getConnectionCatenary(Connection connection, Vec3 start, Ve
257259
double p = (0+dw-a*Math.log((k+dy)/(k-dy)))*0.5;
258260
double q = (dy+0-k*Math.cosh(l)/Math.sinh(l))*0.5;
259261

260-
int vertices = 16;
261262
Vec3[] vex = new Vec3[vertices];
262263

263-
for(int i=0; i<vertices; i++)
264+
vex[0] = new Vec3(start.xCoord, start.yCoord, start.zCoord);
265+
for(int i=1; i<vertices; i++)
264266
{
265-
float n1 = (i+1)/(float)vertices;
267+
float n1 = i/(float)vertices;
266268
double x1 = 0 + dx * n1;
267269
double z1 = 0 + dz * n1;
268270
double y1 = a * Math.cosh((( Math.sqrt(x1*x1+z1*z1) )-p)/a)+q;

src/main/java/blusunrize/immersiveengineering/api/IEProperties.java

+33
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import java.util.Collection;
44
import java.util.HashMap;
5+
import java.util.Set;
56

67
import com.google.common.collect.ImmutableSet;
78

9+
import blusunrize.immersiveengineering.api.energy.wires.WireType;
810
import net.minecraft.block.properties.PropertyDirection;
911
import net.minecraft.block.properties.PropertyEnum;
1012
import net.minecraft.block.properties.PropertyHelper;
@@ -20,6 +22,8 @@ public class IEProperties
2022

2123
public static final PropertyBoolInverted MULTIBLOCKSLAVE = PropertyBoolInverted.create("*multiblockslave");//Name starts with an asterisk to ensure priority when overriding models
2224
public static final PropertyBoolInverted DYNAMICRENDER = PropertyBoolInverted.create("+dynamicrender");//Name starts with a plus to ensure priority over anything but the multiblockslave property
25+
public static final PropertySet CONNECTIONS = new PropertySet("conns");
26+
2327
public static final PropertyEnum[] SIDECONFIG = {
2428
PropertyEnum.create("sideconfig_down", IEEnums.SideConfig.class),
2529
PropertyEnum.create("sideconfig_up", IEEnums.SideConfig.class),
@@ -47,6 +51,7 @@ public class IEProperties
4751

4852
public static final PropertyBoolInverted[] CONVEYORWALLS = {PropertyBoolInverted.create("conveyorwall_left"), PropertyBoolInverted.create("conveyorwall_right")};
4953
public static final PropertyInteger CONVEYORUPDOWN = PropertyInteger.create("conveyorupdown", 0,2);
54+
// public static final Property
5055

5156
public static final IUnlistedProperty<HashMap> OBJ_TEXTURE_REMAP = new IUnlistedProperty<HashMap>()
5257
{
@@ -90,4 +95,32 @@ public String getName(Boolean value)
9095
return value.toString();
9196
}
9297
}
98+
@SuppressWarnings("rawtypes")
99+
public static class PropertySet implements IUnlistedProperty<Set> {
100+
String name;
101+
public PropertySet(String n) {
102+
name = n;
103+
}
104+
@Override
105+
public String getName() {
106+
return name;
107+
}
108+
109+
@Override
110+
public boolean isValid(Set value) {
111+
if (value==null)
112+
return false;
113+
return true;
114+
}
115+
116+
@Override
117+
public Class<Set> getType() {
118+
return Set.class;
119+
}
120+
121+
@Override
122+
public String valueToString(Set value) {
123+
return value.toString();
124+
}
125+
}
93126
}

src/main/java/blusunrize/immersiveengineering/api/energy/wires/ImmersiveNetHandler.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ public static class Connection implements Comparable<Connection>
424424
public WireType cableType;
425425
public int length;
426426
public Vec3[] catenaryVertices;
427-
427+
public static final int vertices = 17;
428+
428429
public Connection(BlockPos start, BlockPos end, WireType cableType, int length)
429430
{
430431
this.start=start;

src/main/java/blusunrize/immersiveengineering/api/energy/wires/TileEntityImmersiveConnectable.java

+38
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
package blusunrize.immersiveengineering.api.energy.wires;
22

33

4+
import java.util.ArrayList;
5+
import java.util.HashSet;
6+
import java.util.Iterator;
7+
import java.util.List;
48
import java.util.Set;
59

10+
import com.google.common.collect.ImmutableSet;
11+
612
import blusunrize.immersiveengineering.api.ApiUtils;
713
import blusunrize.immersiveengineering.api.TargetingInfo;
814
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
@@ -16,6 +22,7 @@
1622
import net.minecraft.network.Packet;
1723
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
1824
import net.minecraft.util.BlockPos;
25+
import net.minecraft.util.Vec3;
1926

2027
public abstract class TileEntityImmersiveConnectable extends TileEntityIEBase implements IImmersiveConnectable
2128
{
@@ -239,4 +246,35 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket)
239246
IELogger.error("TileEntityImmersiveConenctable encountered MASSIVE error writing NBT. You shoudl probably report this.");
240247
}
241248
}
249+
public Set<Connection> genConnBlockstate() {
250+
Set<Connection> conns = ImmersiveNetHandler.INSTANCE.getConnections(worldObj, pos);
251+
if (conns==null)
252+
return ImmutableSet.of();
253+
Set<Connection> ret = new HashSet<Connection>() {
254+
@Override
255+
public boolean equals(Object o) {
256+
if (o==this)
257+
return true;
258+
if (!(o instanceof HashSet))
259+
return false;
260+
HashSet<Connection> other = (HashSet<Connection>) o;
261+
if (other.size()!=this.size())
262+
return false;
263+
for (Connection c:this)
264+
if (!other.contains(c))
265+
return false;
266+
return true;
267+
}
268+
};
269+
for (Connection c:conns)
270+
{
271+
//generate subvertices
272+
if (c.end.compareTo(pos)>=0)
273+
continue;
274+
c.getSubVertices(worldObj);
275+
ret.add(c);
276+
}
277+
278+
return ret;
279+
}
242280
}

src/main/java/blusunrize/immersiveengineering/client/ClientProxy.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.text.DecimalFormat;
44
import java.util.ArrayList;
5+
import java.util.Collection;
56
import java.util.Collections;
67
import java.util.Comparator;
78
import java.util.HashMap;
@@ -19,6 +20,7 @@
1920
import blusunrize.immersiveengineering.ImmersiveEngineering;
2021
import blusunrize.immersiveengineering.api.ApiUtils;
2122
import blusunrize.immersiveengineering.api.IEApi;
23+
import blusunrize.immersiveengineering.api.IEProperties;
2224
import blusunrize.immersiveengineering.api.Lib;
2325
import blusunrize.immersiveengineering.api.ManualHelper;
2426
import blusunrize.immersiveengineering.api.ManualPageMultiblock;
@@ -43,6 +45,7 @@
4345
import blusunrize.immersiveengineering.client.gui.GuiToolbox;
4446
import blusunrize.immersiveengineering.client.models.ModelShaderMinecart;
4547
import blusunrize.immersiveengineering.client.models.obj.IEOBJLoader;
48+
import blusunrize.immersiveengineering.client.models.smart.ConnLoader;
4649
import blusunrize.immersiveengineering.client.render.EntityRenderChemthrowerShot;
4750
import blusunrize.immersiveengineering.client.render.EntityRenderGrapplingHook;
4851
import blusunrize.immersiveengineering.client.render.EntityRenderIEExplosive;
@@ -152,6 +155,7 @@
152155
import net.minecraft.client.renderer.ItemMeshDefinition;
153156
import net.minecraft.client.renderer.RenderHelper;
154157
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
158+
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
155159
import net.minecraft.client.renderer.entity.ArmorStandRenderer;
156160
import net.minecraft.client.renderer.entity.Render;
157161
import net.minecraft.client.renderer.entity.RenderBiped;
@@ -348,6 +352,7 @@ public Render createRenderFor(RenderManager manager){
348352
public Render createRenderFor(RenderManager manager){
349353
return new EntityRenderIEExplosive(manager);
350354
}});
355+
ModelLoaderRegistry.registerLoader(new ConnLoader());
351356
}
352357

353358
@Override
@@ -376,7 +381,7 @@ public void init()
376381
// RenderingRegistry.registerBlockHandler(new BlockRenderMetalDevices2());
377382
// RenderingRegistry.registerBlockHandler(new BlockRenderMetalDecoration());
378383
// RenderingRegistry.registerBlockHandler(new BlockRenderMetalMultiblocks());
379-
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityImmersiveConnectable.class, new TileRenderImmersiveConnectable());
384+
// ClientRegistry.bindTileEntitySpecialRenderer(TileEntityImmersiveConnectable.class, new TileRenderImmersiveConnectable());
380385
// ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConnectorLV.class, new TileRenderConnectorLV());
381386
// ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConnectorMV.class, new TileRenderConnectorMV());
382387
// ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTransformer.class, new TileRenderTransformer());

0 commit comments

Comments
 (0)