mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-02-24 15:00:48 +00:00
jar foreground actors
This commit is contained in:
parent
091d6f3d2c
commit
916cab1fbd
@ -29,14 +29,13 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
//krass
|
//krass
|
||||||
public class GuiWorldInAJar extends GuiScreen {
|
public class GuiWorldInAJar extends GuiScreen {
|
||||||
|
|
||||||
WorldInAJar world;
|
|
||||||
RenderBlocks renderer;
|
RenderBlocks renderer;
|
||||||
|
|
||||||
JarScript testScript;
|
JarScript testScript;
|
||||||
|
|
||||||
public GuiWorldInAJar() {
|
public GuiWorldInAJar() {
|
||||||
super();
|
super();
|
||||||
world = new WorldInAJar(15, 15, 15);
|
WorldInAJar world = new WorldInAJar(15, 15, 15);
|
||||||
renderer = new RenderBlocks(world);
|
renderer = new RenderBlocks(world);
|
||||||
renderer.enableAO = true;
|
renderer.enableAO = true;
|
||||||
|
|
||||||
@ -122,7 +121,13 @@ public class GuiWorldInAJar extends GuiScreen {
|
|||||||
brickScene.add(new ActionUpdateActor(0, "speed", 2F));
|
brickScene.add(new ActionUpdateActor(0, "speed", 2F));
|
||||||
brickScene.add(new ActionUpdateActor(0, "hasCog", false));
|
brickScene.add(new ActionUpdateActor(0, "hasCog", false));
|
||||||
brickScene.add(new ActionWait(20));
|
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));
|
brickScene.add(new ActionWait(100));
|
||||||
|
|
||||||
this.testScript.addScene(startingScene).addScene(brickScene);
|
this.testScript.addScene(startingScene).addScene(brickScene);
|
||||||
@ -145,29 +150,16 @@ public class GuiWorldInAJar extends GuiScreen {
|
|||||||
private void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
private void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
double scale = -10;
|
setupRotation();
|
||||||
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);
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||||
Tessellator.instance.startDrawingQuads();
|
Tessellator.instance.startDrawingQuads();
|
||||||
|
|
||||||
for(int x = 0; x < world.sizeX; x++) {
|
for(int x = 0; x < testScript.world.sizeX; x++) {
|
||||||
for(int y = 0; y < world.sizeY; y++) {
|
for(int y = 0; y < testScript.world.sizeY; y++) {
|
||||||
for(int z = 0; z < world.sizeZ; z++) {
|
for(int z = 0; z < testScript.world.sizeZ; z++) {
|
||||||
renderer.renderBlockByRenderType(world.getBlock(x, y, z), x, y, z);
|
renderer.renderBlockByRenderType(testScript.world.getBlock(x, y, z), x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,30 +168,41 @@ public class GuiWorldInAJar extends GuiScreen {
|
|||||||
GL11.glShadeModel(GL11.GL_FLAT);
|
GL11.glShadeModel(GL11.GL_FLAT);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
RenderHelper.enableStandardItemLighting();
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
|
setupRotation();
|
||||||
GL11.glTranslated(width / 2, height / 2 + 70, 100);
|
RenderHelper.enableStandardItemLighting();
|
||||||
GL11.glScaled(scale, scale, scale);
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
|
||||||
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);
|
|
||||||
|
|
||||||
for(Entry<Integer, ISpecialActor> actor : this.testScript.actors.entrySet()) {
|
for(Entry<Integer, ISpecialActor> actor : this.testScript.actors.entrySet()) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
actor.getValue().draw(this.testScript.ticksElapsed, this.testScript.interp);
|
actor.getValue().drawBackgroundComponent(this.testScript.ticksElapsed, this.testScript.interp);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
@Override
|
||||||
public boolean doesGuiPauseGame() {
|
public boolean doesGuiPauseGame() {
|
||||||
return false;
|
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 com.hbm.wiaj.JarScene;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
public class ActorTileEntity extends ActorBase {
|
||||||
|
|
||||||
public class ActorTileEntity implements ISpecialActor {
|
|
||||||
|
|
||||||
ITileActorRenderer renderer;
|
ITileActorRenderer renderer;
|
||||||
NBTTagCompound data = new NBTTagCompound();
|
|
||||||
|
|
||||||
public ActorTileEntity(ITileActorRenderer renderer) {
|
public ActorTileEntity(ITileActorRenderer renderer) {
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
renderer.renderActor(ticks, interp, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,18 +22,4 @@ public class ActorTileEntity implements ISpecialActor {
|
|||||||
public void updateActor(JarScene scene) {
|
public void updateActor(JarScene scene) {
|
||||||
renderer.updateActor(scene.script.ticksElapsed, data);
|
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 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);
|
public void updateActor(JarScene scene);
|
||||||
|
/** Sets the data object to the passed NBT */
|
||||||
public void setActorData(NBTTagCompound data);
|
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);
|
public void setDataPoint(String tag, Object o);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user