Skip to content

Commit

Permalink
Rework client process, now, FrameTime must not be used !
Browse files Browse the repository at this point in the history
use refresh(float) into SixNodeElementRender and TransparentNodeElementRender
That allow to be compatible with shader mod.
  • Loading branch information
Dolu1990 committed Jun 16, 2014
1 parent 232c683 commit b871d35
Show file tree
Hide file tree
Showing 40 changed files with 601 additions and 510 deletions.
6 changes: 3 additions & 3 deletions mods/eln/Eln.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
import java.util.ArrayList;
import java.util.List;

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

public FrameTime frameTime;

public static FMLEventChannel eventChannel;

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

nodeServer = new NodeServer();
clientLiveDataManager = new LiveDataManager();
frameTime = new FrameTime();

packetHandler = new PacketHandler();
// ForgeDummyContainer
instance = this;
Expand Down
75 changes: 32 additions & 43 deletions mods/eln/autominer/AutoMinerRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.DataInputStream;
import java.io.IOException;


import org.lwjgl.opengl.GL11;

import mods.eln.client.FrameTime;
Expand All @@ -22,100 +21,90 @@ public class AutoMinerRender extends TransparentNodeElementRender {
float[] buttonsState;
boolean[] ledsAState;
boolean[] ledsPState;



public AutoMinerRender(TransparentNodeEntity tileEntity,
TransparentNodeDescriptor descriptor) {
super(tileEntity, descriptor);
this.descriptor = (AutoMinerDescriptor) descriptor;

buttonsState = new float[this.descriptor.buttonsCount];
for(int idx = 0;idx < this.descriptor.buttonsCount;idx++){
for (int idx = 0; idx < this.descriptor.buttonsCount; idx++) {
buttonsState[idx] = (float) Math.random();
}

ledsAState = new boolean[this.descriptor.ledsACount];
for(int idx = 0;idx < this.descriptor.ledsACount;idx++){
for (int idx = 0; idx < this.descriptor.ledsACount; idx++) {
ledsAState[idx] = Math.random() > 0.5;
}

ledsPState = new boolean[this.descriptor.ledsPCount];
for(int idx = 0;idx < this.descriptor.ledsPCount;idx++){
for (int idx = 0; idx < this.descriptor.ledsPCount; idx++) {
ledsPState[idx] = Math.random() > 0.5;
}
}



@Override
public void draw() {
if(pipeLength != 0) {

if (pipeLength != 0) {
GL11.glPushMatrix();
for(int idx = pipeLength;idx != 0;idx--){
if(idx != 1){
for (int idx = pipeLength; idx != 0; idx--) {
if (idx != 1) {
descriptor.pipe.draw();
}
else{
else {
descriptor.head.draw();
}
GL11.glTranslatef(0, -1f, 0);
}
GL11.glPopMatrix();
/*GL11.glLineWidth(20f);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBegin(GL11.GL_LINES);
GL11.glColor4f(1f, 0f, 0f, 1f);
GL11.glVertex3f(0f, -0.5f, 0f);
GL11.glVertex3f(0f, -0.5f - pipeLength, 0f);
GL11.glEnd();
GL11.glEnable(GL11.GL_TEXTURE_2D);*/

}
for(int idx = 0;idx < this.descriptor.buttonsCount;idx++){

for (int idx = 0; idx < this.descriptor.buttonsCount; idx++) {
buttonsState[idx] = idx == job.ordinal() ? 1 : 0;
}

for(int idx = 0;idx < this.descriptor.ledsACount;idx++){
if(Math.random() < 0.2*FrameTime.get())
ledsAState[idx] = ! ledsAState[idx];

front.glRotateXnRef();
descriptor.draw(false, buttonsState, ledsAState, ledsPState);
}

public void refresh(float deltaT) {
for (int idx = 0; idx < this.descriptor.ledsACount; idx++) {
if (Math.random() < 0.2 * deltaT)
ledsAState[idx] = !ledsAState[idx];
}

for(int idx = 0;idx < this.descriptor.ledsPCount;idx++){
if(Math.random() < 0.2*FrameTime.get())
ledsPState[idx] = ! ledsPState[idx];
for (int idx = 0; idx < this.descriptor.ledsPCount; idx++) {
if (Math.random() < 0.2 * deltaT)
ledsPState[idx] = !ledsPState[idx];
}


front.glRotateXnRef();
descriptor.draw(false,buttonsState,ledsAState,ledsPState);

}

TransparentNodeElementInventory inventory = new TransparentNodeElementInventory(AutoMinerContainer.inventorySize, 64, this);

@Override
public GuiScreen newGuiDraw(Direction side, EntityPlayer player) {
return new AutoMinerGuiDraw(player, inventory, this);
}

short pipeLength = 0;
AutoMinerSlowProcess.jobType job;

@Override
public void networkUnserialize(DataInputStream stream) {
super.networkUnserialize(stream);
try {
pipeLength = stream.readShort();
job = AutoMinerSlowProcess.jobType.values()[stream.readByte()];
// Utils.println(job + " " + pipeLength);
// Utils.println(job + " " + pipeLength);

} catch (IOException e) {
e.printStackTrace();
}
}

@Override
public boolean cameraDrawOptimisation() {
return false;
Expand Down
12 changes: 9 additions & 3 deletions mods/eln/batterycharger/BatteryChargerRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public BatteryChargerRender(SixNodeEntity tileEntity, Direction side,
public void draw() {
super.draw();

alpha += 90 * FrameTime.get();
if(alpha > 360) alpha -=360;


drawEntityItem(b[0], 0.1875, 0.15625, 0.15625, alpha, 0.2f);
drawEntityItem(b[1], 0.1875, 0.15625, -0.15625, alpha, 0.2f);
drawEntityItem(b[2], 0.1875, -0.15625, 0.15625, alpha, 0.2f);
Expand All @@ -60,6 +58,14 @@ public void draw() {
descriptor.draw(batteryPresence, charged);
}


@Override
public void refresh(float deltaT) {
alpha += 90 * deltaT;
if(alpha > 360) alpha -=360;

}

float alpha = 0;

public void drawEntityItem(EntityItem entityItem, double x, double y, double z, float roty, float scale) {
Expand Down
2 changes: 1 addition & 1 deletion mods/eln/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void registerRenderers() {
uuidManager = new UuidManager();
soundClientEventListener = new SoundClientEventListener(uuidManager);
// FMLCommonHandler.instance().bus().register();

new FrameTime();
}
public static UuidManager uuidManager;
public static SoundClientEventListener soundClientEventListener;
Expand Down
12 changes: 7 additions & 5 deletions mods/eln/client/FrameTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public void stop() {
// NodeBlockEntity.nodeAddedList.clear();
}

public static float get() {
public static float get2() {
if(Utils.isGameInPause())
return 0f;
return Math.min(0.1f, instance.deltaT);
}

public static float getNotCaped() {
float value = get();
public static float getNotCaped2() {
float value = get2();
return value;
}

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

Utils.println(NodeBlockEntity.clientList.size());
//Utils.println(NodeBlockEntity.clientList.size());
Iterator<NodeBlockEntity> i = NodeBlockEntity.clientList.iterator();
World w = Minecraft.getMinecraft().theWorld;

float deltaTcaped = getNotCaped2();
while(i.hasNext()){
NodeBlockEntity e = i.next();
if(e.getWorldObj() != w){
i.remove();
continue;
}
//e.clientRefresh(deltaT);
e.clientRefresh(deltaTcaped);
}
//Minecraft.getMinecraft().theWorld.getChunkFromChunkCoords(1, 1).
// Utils.println("delta T : " + deltaT + " " + event);
Expand Down
9 changes: 7 additions & 2 deletions mods/eln/eggincubator/EggIncubatorRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public EggIncubatorRender(TransparentNodeEntity tileEntity, TransparentNodeDescr

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

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

@Override
public void refresh(float deltaT) {
alpha += deltaT * 60;
if(alpha >= 360) alpha -= 360;

}

float alpha = 0;

@Override
Expand Down
12 changes: 8 additions & 4 deletions mods/eln/electricalalarm/ElectricalAlarmRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ public void draw() {
super.draw();

drawSignalPin(front,descriptor.pinDistance);
interpol.setTarget(warm ? descriptor.rotSpeed : 0f);
interpol.stepGraphic();

rotAlpha += interpol.get() * FrameTime.get();

//front.glRotateOnX();
descriptor.draw(warm, rotAlpha);
}
@Override
public void refresh(float deltaT) {
interpol.setTarget(warm ? descriptor.rotSpeed : 0f);
interpol.step(deltaT);

rotAlpha += interpol.get() * deltaT;

}

float rotAlpha = 0;
boolean warm = false;
Expand Down
9 changes: 7 additions & 2 deletions mods/eln/electricalbreaker/ElectricalBreakerRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@ public ElectricalBreakerRender(SixNodeEntity tileEntity, Direction side, SixNode
@Override
public void draw() {
super.draw();
interpol.setTarget(switchState ? 1f :0f);
interpol.stepGraphic();

front.glRotateOnX();
descriptor.draw(interpol.get(), UtilsClient.distanceFromClientPlayer(tileEntity));
}

@Override
public void refresh(float deltaT) {
interpol.setTarget(switchState ? 1f :0f);
interpol.step(deltaT);

}

@Override
public CableRenderDescriptor getCableRender(LRDU lrdu) {
return cableRender;
Expand Down
11 changes: 9 additions & 2 deletions mods/eln/electricalfurnace/ElectricalFurnaceRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,26 @@ public ElectricalFurnaceRender(TransparentNodeEntity tileEntity, TransparentNode
public void draw() {
front.glRotateXnRef();

processState += processStatePerSecond * FrameTime.getNotCaped();
if(processState > 1f) processState = 1f;

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

drawEntityItem(entityItemIn, -0.1, -0.20, 0, counter, 0.8f);

}


@Override
public void refresh(float deltaT) {
processState += processStatePerSecond * FrameTime.getNotCaped2();
if(processState > 1f) processState = 1f;
counter += (System.currentTimeMillis() - time) * 0.001 * 360 / 4;
if(counter > 360) counter -= 360;

time = System.currentTimeMillis();
}


float counter = 0;

@Override
Expand Down
Loading

0 comments on commit b871d35

Please sign in to comment.