mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
jar foreground actors
This commit is contained in:
parent
091d6f3d2c
commit
916cab1fbd
@ -29,14 +29,13 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
//krass
|
||||
public class GuiWorldInAJar extends GuiScreen {
|
||||
|
||||
WorldInAJar world;
|
||||
RenderBlocks renderer;
|
||||
|
||||
JarScript testScript;
|
||||
|
||||
public GuiWorldInAJar() {
|
||||
super();
|
||||
world = new WorldInAJar(15, 15, 15);
|
||||
WorldInAJar world = new WorldInAJar(15, 15, 15);
|
||||
renderer = new RenderBlocks(world);
|
||||
renderer.enableAO = true;
|
||||
|
||||
@ -122,7 +121,13 @@ public class GuiWorldInAJar extends GuiScreen {
|
||||
brickScene.add(new ActionUpdateActor(0, "speed", 2F));
|
||||
brickScene.add(new ActionUpdateActor(0, "hasCog", false));
|
||||
brickScene.add(new ActionWait(20));
|
||||
brickScene.add(new ActionRotate(360, 0, 20));
|
||||
brickScene.add(new ActionUpdateActor(0, "rotation", 4));
|
||||
brickScene.add(new ActionWait(10));
|
||||
brickScene.add(new ActionUpdateActor(0, "rotation", 3));
|
||||
brickScene.add(new ActionWait(10));
|
||||
brickScene.add(new ActionUpdateActor(0, "rotation", 5));
|
||||
brickScene.add(new ActionWait(10));
|
||||
brickScene.add(new ActionUpdateActor(0, "rotation", 2));
|
||||
brickScene.add(new ActionWait(100));
|
||||
|
||||
this.testScript.addScene(startingScene).addScene(brickScene);
|
||||
@ -145,29 +150,16 @@ public class GuiWorldInAJar extends GuiScreen {
|
||||
private void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
double scale = -10;
|
||||
GL11.glTranslated(width / 2, height / 2 + 70, 100);
|
||||
GL11.glScaled(scale, scale, scale);
|
||||
GL11.glScaled(1, 1, 0.01); //incredible flattening power
|
||||
|
||||
double pitch = testScript.lastRotationPitch + (testScript.rotationPitch - testScript.lastRotationPitch) * testScript.interp;
|
||||
double yaw = testScript.lastRotationYaw + (testScript.rotationYaw - testScript.lastRotationYaw) * testScript.interp;
|
||||
GL11.glRotated(pitch, 1, 0, 0);
|
||||
GL11.glRotated(yaw, 0, 1, 0);
|
||||
|
||||
GL11.glTranslated(-7, 0 , -7);
|
||||
|
||||
GL11.glTranslated(world.sizeX / 2D, 0 , world.sizeZ / 2D);
|
||||
GL11.glTranslated(world.sizeX / -2D, 0 , world.sizeZ / -2D);
|
||||
setupRotation();
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
|
||||
for(int x = 0; x < world.sizeX; x++) {
|
||||
for(int y = 0; y < world.sizeY; y++) {
|
||||
for(int z = 0; z < world.sizeZ; z++) {
|
||||
renderer.renderBlockByRenderType(world.getBlock(x, y, z), x, y, z);
|
||||
for(int x = 0; x < testScript.world.sizeX; x++) {
|
||||
for(int y = 0; y < testScript.world.sizeY; y++) {
|
||||
for(int z = 0; z < testScript.world.sizeZ; z++) {
|
||||
renderer.renderBlockByRenderType(testScript.world.getBlock(x, y, z), x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,31 +167,42 @@ public class GuiWorldInAJar extends GuiScreen {
|
||||
Tessellator.instance.draw();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
|
||||
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glTranslated(width / 2, height / 2 + 70, 100);
|
||||
GL11.glScaled(scale, scale, scale);
|
||||
GL11.glScaled(1, 1, 0.01);
|
||||
GL11.glRotated(pitch, 1, 0, 0);
|
||||
GL11.glRotated(yaw, 0, 1, 0);
|
||||
GL11.glTranslated(-7, 0 , -7);
|
||||
GL11.glTranslated(world.sizeX / 2D, 0 , world.sizeZ / 2D);
|
||||
GL11.glTranslated(world.sizeX / -2D, 0 , world.sizeZ / -2D);
|
||||
setupRotation();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
|
||||
|
||||
for(Entry<Integer, ISpecialActor> actor : this.testScript.actors.entrySet()) {
|
||||
GL11.glPushMatrix();
|
||||
actor.getValue().draw(this.testScript.ticksElapsed, this.testScript.interp);
|
||||
actor.getValue().drawBackgroundComponent(this.testScript.ticksElapsed, this.testScript.interp);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void setupRotation() {
|
||||
|
||||
double scale = -50;
|
||||
|
||||
GL11.glTranslated(width / 2, height / 2 + 70, 400);
|
||||
GL11.glScaled(scale, scale, scale);
|
||||
GL11.glScaled(1, 1, 0.5); //incredible flattening power
|
||||
|
||||
double pitch = testScript.lastRotationPitch + (testScript.rotationPitch - testScript.lastRotationPitch) * testScript.interp;
|
||||
double yaw = testScript.lastRotationYaw + (testScript.rotationYaw - testScript.lastRotationYaw) * testScript.interp;
|
||||
|
||||
GL11.glRotated(pitch, 1, 0, 0);
|
||||
GL11.glRotated(yaw, 0, 1, 0);
|
||||
GL11.glTranslated(-7, 0 , -7);
|
||||
GL11.glTranslated(testScript.world.sizeX / 2D, 0 , testScript.world.sizeZ / 2D);
|
||||
GL11.glTranslated(testScript.world.sizeX / -2D, 0 , testScript.world.sizeZ / -2D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
|
||||
28
src/main/java/com/hbm/wiaj/actors/ActorBase.java
Normal file
28
src/main/java/com/hbm/wiaj/actors/ActorBase.java
Normal file
@ -0,0 +1,28 @@
|
||||
package com.hbm.wiaj.actors;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Very basic actor base class that holds NBT, not very useful on its own
|
||||
* @author hbm
|
||||
*/
|
||||
public abstract class ActorBase implements ISpecialActor {
|
||||
|
||||
protected NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
@Override
|
||||
public void setActorData(NBTTagCompound data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataPoint(String tag, Object o) {
|
||||
if(o instanceof String) this.data.setString(tag, (String) o);
|
||||
if(o instanceof Integer) this.data.setInteger(tag, (Integer) o);
|
||||
if(o instanceof Float) this.data.setFloat(tag, (Float) o);
|
||||
if(o instanceof Double) this.data.setDouble(tag, (Double) o);
|
||||
if(o instanceof Boolean) this.data.setBoolean(tag, (Boolean) o);
|
||||
if(o instanceof Byte) this.data.setByte(tag, (Byte) o);
|
||||
if(o instanceof Short) this.data.setShort(tag, (Short) o);
|
||||
}
|
||||
}
|
||||
@ -2,19 +2,19 @@ package com.hbm.wiaj.actors;
|
||||
|
||||
import com.hbm.wiaj.JarScene;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ActorTileEntity implements ISpecialActor {
|
||||
public class ActorTileEntity extends ActorBase {
|
||||
|
||||
ITileActorRenderer renderer;
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
public ActorTileEntity(ITileActorRenderer renderer) {
|
||||
this.renderer = renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int ticks, float interp) {
|
||||
public void drawForegroundComponent(int ticks, float interp) { }
|
||||
|
||||
@Override
|
||||
public void drawBackgroundComponent(int ticks, float interp) {
|
||||
renderer.renderActor(ticks, interp, data);
|
||||
}
|
||||
|
||||
@ -22,18 +22,4 @@ public class ActorTileEntity implements ISpecialActor {
|
||||
public void updateActor(JarScene scene) {
|
||||
renderer.updateActor(scene.script.ticksElapsed, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActorData(NBTTagCompound data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataPoint(String tag, Object o) {
|
||||
if(o instanceof String) this.data.setString(tag, (String) o);
|
||||
if(o instanceof Integer) this.data.setInteger(tag, (Integer) o);
|
||||
if(o instanceof Float) this.data.setFloat(tag, (Float) o);
|
||||
if(o instanceof Double) this.data.setDouble(tag, (Double) o);
|
||||
if(o instanceof Boolean) this.data.setBoolean(tag, (Boolean) o);
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,8 +11,14 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
*/
|
||||
public interface ISpecialActor {
|
||||
|
||||
public void draw(int ticks, float interp);
|
||||
/** Draws things in the foreground like text boxes */
|
||||
public void drawForegroundComponent(int ticks, float interp);
|
||||
/** Draws things in the background, fotted to the world renderer like TESRs */
|
||||
public void drawBackgroundComponent(int ticks, float interp);
|
||||
/** Update ticks to emulate serverside ticking */
|
||||
public void updateActor(JarScene scene);
|
||||
/** Sets the data object to the passed NBT */
|
||||
public void setActorData(NBTTagCompound data);
|
||||
/** Auto-detects the passed object's type and sets the specified NBT tag */
|
||||
public void setDataPoint(String tag, Object o);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user