Skip to content

Commit b871d35

Browse files
committed
Rework client process, now, FrameTime must not be used !
use refresh(float) into SixNodeElementRender and TransparentNodeElementRender That allow to be compatible with shader mod.
1 parent 232c683 commit b871d35

40 files changed

+601
-510
lines changed

mods/eln/Eln.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269
import java.util.ArrayList;
270270
import java.util.List;
271271

272-
@Mod(modid = "Eln", version = "BETA-1.4.2")
272+
@Mod(modid = "Eln", version = "BETA-1.4.3")
273273
//@Mod(modid = "Eln", name = "Electrical Age", version = "BETA-1.2.0b")
274274
//@NetworkMod(clientSideRequired = true, serverSideRequired = true, channels = { "miaouMod" }, packetHandler = PacketHandler.class)
275275
public class Eln {
@@ -551,7 +551,7 @@ public void preInit(FMLPreInitializationEvent event) {
551551
config.save();
552552
}
553553

554-
public FrameTime frameTime;
554+
555555
public static FMLEventChannel eventChannel;
556556

557557
//FMLCommonHandler.instance().bus().register(this);
@@ -568,7 +568,7 @@ public void load(FMLInitializationEvent event) {
568568

569569
nodeServer = new NodeServer();
570570
clientLiveDataManager = new LiveDataManager();
571-
frameTime = new FrameTime();
571+
572572
packetHandler = new PacketHandler();
573573
// ForgeDummyContainer
574574
instance = this;

mods/eln/autominer/AutoMinerRender.java

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.DataInputStream;
44
import java.io.IOException;
55

6-
76
import org.lwjgl.opengl.GL11;
87

98
import mods.eln.client.FrameTime;
@@ -22,100 +21,90 @@ public class AutoMinerRender extends TransparentNodeElementRender {
2221
float[] buttonsState;
2322
boolean[] ledsAState;
2423
boolean[] ledsPState;
25-
26-
24+
2725
public AutoMinerRender(TransparentNodeEntity tileEntity,
2826
TransparentNodeDescriptor descriptor) {
2927
super(tileEntity, descriptor);
3028
this.descriptor = (AutoMinerDescriptor) descriptor;
31-
29+
3230
buttonsState = new float[this.descriptor.buttonsCount];
33-
for(int idx = 0;idx < this.descriptor.buttonsCount;idx++){
31+
for (int idx = 0; idx < this.descriptor.buttonsCount; idx++) {
3432
buttonsState[idx] = (float) Math.random();
3533
}
36-
34+
3735
ledsAState = new boolean[this.descriptor.ledsACount];
38-
for(int idx = 0;idx < this.descriptor.ledsACount;idx++){
36+
for (int idx = 0; idx < this.descriptor.ledsACount; idx++) {
3937
ledsAState[idx] = Math.random() > 0.5;
4038
}
4139

4240
ledsPState = new boolean[this.descriptor.ledsPCount];
43-
for(int idx = 0;idx < this.descriptor.ledsPCount;idx++){
41+
for (int idx = 0; idx < this.descriptor.ledsPCount; idx++) {
4442
ledsPState[idx] = Math.random() > 0.5;
4543
}
4644
}
4745

48-
49-
5046
@Override
5147
public void draw() {
52-
53-
if(pipeLength != 0) {
48+
49+
if (pipeLength != 0) {
5450
GL11.glPushMatrix();
55-
for(int idx = pipeLength;idx != 0;idx--){
56-
if(idx != 1){
51+
for (int idx = pipeLength; idx != 0; idx--) {
52+
if (idx != 1) {
5753
descriptor.pipe.draw();
5854
}
59-
else{
55+
else {
6056
descriptor.head.draw();
6157
}
6258
GL11.glTranslatef(0, -1f, 0);
6359
}
6460
GL11.glPopMatrix();
65-
/*GL11.glLineWidth(20f);
66-
GL11.glDisable(GL11.GL_TEXTURE_2D);
67-
68-
GL11.glBegin(GL11.GL_LINES);
69-
GL11.glColor4f(1f, 0f, 0f, 1f);
70-
GL11.glVertex3f(0f, -0.5f, 0f);
71-
GL11.glVertex3f(0f, -0.5f - pipeLength, 0f);
72-
GL11.glEnd();
73-
74-
GL11.glEnable(GL11.GL_TEXTURE_2D);*/
61+
7562
}
76-
77-
for(int idx = 0;idx < this.descriptor.buttonsCount;idx++){
63+
64+
for (int idx = 0; idx < this.descriptor.buttonsCount; idx++) {
7865
buttonsState[idx] = idx == job.ordinal() ? 1 : 0;
7966
}
80-
81-
for(int idx = 0;idx < this.descriptor.ledsACount;idx++){
82-
if(Math.random() < 0.2*FrameTime.get())
83-
ledsAState[idx] = ! ledsAState[idx];
67+
68+
front.glRotateXnRef();
69+
descriptor.draw(false, buttonsState, ledsAState, ledsPState);
70+
}
71+
72+
public void refresh(float deltaT) {
73+
for (int idx = 0; idx < this.descriptor.ledsACount; idx++) {
74+
if (Math.random() < 0.2 * deltaT)
75+
ledsAState[idx] = !ledsAState[idx];
8476
}
8577

86-
for(int idx = 0;idx < this.descriptor.ledsPCount;idx++){
87-
if(Math.random() < 0.2*FrameTime.get())
88-
ledsPState[idx] = ! ledsPState[idx];
78+
for (int idx = 0; idx < this.descriptor.ledsPCount; idx++) {
79+
if (Math.random() < 0.2 * deltaT)
80+
ledsPState[idx] = !ledsPState[idx];
8981
}
90-
91-
92-
front.glRotateXnRef();
93-
descriptor.draw(false,buttonsState,ledsAState,ledsPState);
82+
9483
}
9584

9685
TransparentNodeElementInventory inventory = new TransparentNodeElementInventory(AutoMinerContainer.inventorySize, 64, this);
97-
86+
9887
@Override
9988
public GuiScreen newGuiDraw(Direction side, EntityPlayer player) {
10089
return new AutoMinerGuiDraw(player, inventory, this);
10190
}
102-
91+
10392
short pipeLength = 0;
10493
AutoMinerSlowProcess.jobType job;
105-
94+
10695
@Override
10796
public void networkUnserialize(DataInputStream stream) {
10897
super.networkUnserialize(stream);
10998
try {
11099
pipeLength = stream.readShort();
111100
job = AutoMinerSlowProcess.jobType.values()[stream.readByte()];
112-
// Utils.println(job + " " + pipeLength);
101+
// Utils.println(job + " " + pipeLength);
113102

114103
} catch (IOException e) {
115104
e.printStackTrace();
116105
}
117106
}
118-
107+
119108
@Override
120109
public boolean cameraDrawOptimisation() {
121110
return false;

mods/eln/batterycharger/BatteryChargerRender.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ public BatteryChargerRender(SixNodeEntity tileEntity, Direction side,
4848
public void draw() {
4949
super.draw();
5050

51-
alpha += 90 * FrameTime.get();
52-
if(alpha > 360) alpha -=360;
53-
51+
5452
drawEntityItem(b[0], 0.1875, 0.15625, 0.15625, alpha, 0.2f);
5553
drawEntityItem(b[1], 0.1875, 0.15625, -0.15625, alpha, 0.2f);
5654
drawEntityItem(b[2], 0.1875, -0.15625, 0.15625, alpha, 0.2f);
@@ -60,6 +58,14 @@ public void draw() {
6058
descriptor.draw(batteryPresence, charged);
6159
}
6260

61+
62+
@Override
63+
public void refresh(float deltaT) {
64+
alpha += 90 * deltaT;
65+
if(alpha > 360) alpha -=360;
66+
67+
}
68+
6369
float alpha = 0;
6470

6571
public void drawEntityItem(EntityItem entityItem, double x, double y, double z, float roty, float scale) {

mods/eln/client/ClientProxy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void registerRenderers() {
5252
uuidManager = new UuidManager();
5353
soundClientEventListener = new SoundClientEventListener(uuidManager);
5454
// FMLCommonHandler.instance().bus().register();
55-
55+
new FrameTime();
5656
}
5757
public static UuidManager uuidManager;
5858
public static SoundClientEventListener soundClientEventListener;

mods/eln/client/FrameTime.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ public void stop() {
6060
// NodeBlockEntity.nodeAddedList.clear();
6161
}
6262

63-
public static float get() {
63+
public static float get2() {
6464
if(Utils.isGameInPause())
6565
return 0f;
6666
return Math.min(0.1f, instance.deltaT);
6767
}
6868

69-
public static float getNotCaped() {
70-
float value = get();
69+
public static float getNotCaped2() {
70+
float value = get2();
7171
return value;
7272
}
7373

@@ -88,16 +88,18 @@ public void tick(RenderTickEvent event) {
8888
}
8989
oldNanoTime = nanoTime;
9090

91-
Utils.println(NodeBlockEntity.clientList.size());
91+
//Utils.println(NodeBlockEntity.clientList.size());
9292
Iterator<NodeBlockEntity> i = NodeBlockEntity.clientList.iterator();
9393
World w = Minecraft.getMinecraft().theWorld;
94+
95+
float deltaTcaped = getNotCaped2();
9496
while(i.hasNext()){
9597
NodeBlockEntity e = i.next();
9698
if(e.getWorldObj() != w){
9799
i.remove();
98100
continue;
99101
}
100-
//e.clientRefresh(deltaT);
102+
e.clientRefresh(deltaTcaped);
101103
}
102104
//Minecraft.getMinecraft().theWorld.getChunkFromChunkCoords(1, 1).
103105
// Utils.println("delta T : " + deltaT + " " + event);

mods/eln/eggincubator/EggIncubatorRender.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ public EggIncubatorRender(TransparentNodeEntity tileEntity, TransparentNodeDescr
4747

4848
@Override
4949
public void draw() {
50-
alpha += FrameTime.get() * 60;
51-
if(alpha >= 360) alpha -= 360;
5250

5351
GL11.glPushMatrix();
5452
front.glRotateXnRef();
@@ -60,6 +58,13 @@ public void draw() {
6058
cableRenderType = drawCable(front.down(), descriptor.cable.render, eConn, cableRenderType);
6159
}
6260

61+
@Override
62+
public void refresh(float deltaT) {
63+
alpha += deltaT * 60;
64+
if(alpha >= 360) alpha -= 360;
65+
66+
}
67+
6368
float alpha = 0;
6469

6570
@Override

mods/eln/electricalalarm/ElectricalAlarmRender.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,18 @@ public void draw() {
4141
super.draw();
4242

4343
drawSignalPin(front,descriptor.pinDistance);
44-
interpol.setTarget(warm ? descriptor.rotSpeed : 0f);
45-
interpol.stepGraphic();
46-
47-
rotAlpha += interpol.get() * FrameTime.get();
4844

4945
//front.glRotateOnX();
5046
descriptor.draw(warm, rotAlpha);
5147
}
48+
@Override
49+
public void refresh(float deltaT) {
50+
interpol.setTarget(warm ? descriptor.rotSpeed : 0f);
51+
interpol.step(deltaT);
52+
53+
rotAlpha += interpol.get() * deltaT;
54+
55+
}
5256

5357
float rotAlpha = 0;
5458
boolean warm = false;

mods/eln/electricalbreaker/ElectricalBreakerRender.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,18 @@ public ElectricalBreakerRender(SixNodeEntity tileEntity, Direction side, SixNode
4848
@Override
4949
public void draw() {
5050
super.draw();
51-
interpol.setTarget(switchState ? 1f :0f);
52-
interpol.stepGraphic();
5351

5452
front.glRotateOnX();
5553
descriptor.draw(interpol.get(), UtilsClient.distanceFromClientPlayer(tileEntity));
5654
}
5755

56+
@Override
57+
public void refresh(float deltaT) {
58+
interpol.setTarget(switchState ? 1f :0f);
59+
interpol.step(deltaT);
60+
61+
}
62+
5863
@Override
5964
public CableRenderDescriptor getCableRender(LRDU lrdu) {
6065
return cableRender;

mods/eln/electricalfurnace/ElectricalFurnaceRender.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,26 @@ public ElectricalFurnaceRender(TransparentNodeEntity tileEntity, TransparentNode
4747
public void draw() {
4848
front.glRotateXnRef();
4949

50-
processState += processStatePerSecond * FrameTime.getNotCaped();
51-
if(processState > 1f) processState = 1f;
5250

5351
Eln.obj.draw("ElectricFurnace", "furnace");
5452
//ClientProxy.obj.draw("ELFURNACE");
5553

5654
drawEntityItem(entityItemIn, -0.1, -0.20, 0, counter, 0.8f);
55+
56+
}
57+
58+
59+
@Override
60+
public void refresh(float deltaT) {
61+
processState += processStatePerSecond * FrameTime.getNotCaped2();
62+
if(processState > 1f) processState = 1f;
5763
counter += (System.currentTimeMillis() - time) * 0.001 * 360 / 4;
5864
if(counter > 360) counter -= 360;
5965

6066
time = System.currentTimeMillis();
6167
}
6268

69+
6370
float counter = 0;
6471

6572
@Override

0 commit comments

Comments
 (0)