mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
minecart tests, assemfac stabby bois
This commit is contained in:
parent
bf578c6e99
commit
f08cdb1359
1189
src/main/java/com/hbm/entity/item/EntityMinecartDeobf.java
Normal file
1189
src/main/java/com/hbm/entity/item/EntityMinecartDeobf.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,8 @@ import org.lwjgl.opengl.GL11;
|
|||||||
|
|
||||||
import com.hbm.blocks.BlockDummyable;
|
import com.hbm.blocks.BlockDummyable;
|
||||||
import com.hbm.main.ResourceManager;
|
import com.hbm.main.ResourceManager;
|
||||||
|
import com.hbm.tileentity.machine.TileEntityMachineAssemfac;
|
||||||
|
import com.hbm.tileentity.machine.TileEntityMachineAssemfac.AssemblerArm;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
@ -11,12 +13,14 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
public class RenderAssemfac extends TileEntitySpecialRenderer {
|
public class RenderAssemfac extends TileEntitySpecialRenderer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float interp) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslated(x + 0.5D, y, z + 0.5D);
|
GL11.glTranslated(x + 0.5D, y, z + 0.5D);
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||||
|
|
||||||
|
TileEntityMachineAssemfac fac = (TileEntityMachineAssemfac) tileEntity;
|
||||||
|
|
||||||
switch(tileEntity.getBlockMetadata() - BlockDummyable.offset) {
|
switch(tileEntity.getBlockMetadata() - BlockDummyable.offset) {
|
||||||
case 5: GL11.glRotatef(180, 0F, 1F, 0F); break;
|
case 5: GL11.glRotatef(180, 0F, 1F, 0F); break;
|
||||||
case 2: GL11.glRotatef(270, 0F, 1F, 0F); break;
|
case 2: GL11.glRotatef(270, 0F, 1F, 0F); break;
|
||||||
@ -35,7 +39,46 @@ public class RenderAssemfac extends TileEntitySpecialRenderer {
|
|||||||
double hOff;
|
double hOff;
|
||||||
double sOff;
|
double sOff;
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
for(int i = 0; i < fac.arms.length; i++) {
|
||||||
|
|
||||||
|
AssemblerArm arm = fac.arms[i];
|
||||||
|
double pivotRot = arm.prevAngles[0] + (arm.angles[0] - arm.prevAngles[0]) * interp;
|
||||||
|
double armRot = arm.prevAngles[1] + (arm.angles[1] - arm.prevAngles[1]) * interp;
|
||||||
|
double pistonRot = arm.prevAngles[2] + (arm.angles[2] - arm.prevAngles[2]) * interp;
|
||||||
|
double striker = arm.prevAngles[3] + (arm.angles[3] - arm.prevAngles[3]) * interp;
|
||||||
|
|
||||||
|
int side = i < 3 ? 1 : -1;
|
||||||
|
int index = i + 1;
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
|
hOff = 1.875D;
|
||||||
|
sOff = 2D * side;
|
||||||
|
GL11.glTranslated(sOff, hOff, sOff);
|
||||||
|
GL11.glRotated(pivotRot * side, 1, 0, 0);
|
||||||
|
GL11.glTranslated(-sOff, -hOff, -sOff);
|
||||||
|
ResourceManager.assemfac.renderPart("Pivot" + index);
|
||||||
|
|
||||||
|
hOff = 3.375D;
|
||||||
|
sOff = 2D * side;
|
||||||
|
GL11.glTranslated(sOff, hOff, sOff);
|
||||||
|
GL11.glRotated(armRot * side, 1, 0, 0);
|
||||||
|
GL11.glTranslated(-sOff, -hOff, -sOff);
|
||||||
|
ResourceManager.assemfac.renderPart("Arm" + index);
|
||||||
|
|
||||||
|
hOff = 3.375D;
|
||||||
|
sOff = 0.625D * side;
|
||||||
|
GL11.glTranslated(sOff, hOff, sOff);
|
||||||
|
GL11.glRotated(pistonRot * side, 1, 0, 0);
|
||||||
|
GL11.glTranslated(-sOff, -hOff, -sOff);
|
||||||
|
ResourceManager.assemfac.renderPart("Piston" + index);
|
||||||
|
GL11.glTranslated(0, -striker, 0);
|
||||||
|
ResourceManager.assemfac.renderPart("Striker" + index);
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*GL11.glPushMatrix();
|
||||||
hOff = 1.875D;
|
hOff = 1.875D;
|
||||||
sOff = 2D;
|
sOff = 2D;
|
||||||
GL11.glTranslated(sOff, hOff, sOff);
|
GL11.glTranslated(sOff, hOff, sOff);
|
||||||
@ -101,7 +144,7 @@ public class RenderAssemfac extends TileEntitySpecialRenderer {
|
|||||||
ResourceManager.assemfac.renderPart("Striker4");
|
ResourceManager.assemfac.renderPart("Striker4");
|
||||||
ResourceManager.assemfac.renderPart("Striker5");
|
ResourceManager.assemfac.renderPart("Striker5");
|
||||||
ResourceManager.assemfac.renderPart("Striker6");
|
ResourceManager.assemfac.renderPart("Striker6");
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();*/
|
||||||
|
|
||||||
GL11.glShadeModel(GL11.GL_FLAT);
|
GL11.glShadeModel(GL11.GL_FLAT);
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,19 @@
|
|||||||
package com.hbm.tileentity.machine;
|
package com.hbm.tileentity.machine;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import com.hbm.tileentity.TileEntityMachineBase;
|
import com.hbm.tileentity.TileEntityMachineBase;
|
||||||
|
|
||||||
public class TileEntityMachineAssemfac extends TileEntityMachineBase {
|
public class TileEntityMachineAssemfac extends TileEntityMachineBase {
|
||||||
|
|
||||||
|
public AssemblerArm[] arms;
|
||||||
|
|
||||||
public TileEntityMachineAssemfac() {
|
public TileEntityMachineAssemfac() {
|
||||||
super(10 * 8 + 4 + 1); //8 assembler groups with 10 slots, 4 upgrade slots, 1 battery slot
|
super(10 * 8 + 4 + 1); //8 assembler groups with 10 slots, 4 upgrade slots, 1 battery slot
|
||||||
|
arms = new AssemblerArm[6];
|
||||||
|
for(int i = 0; i < arms.length; i++) {
|
||||||
|
arms[i] = new AssemblerArm(i % 3 == 1 ? 1 : 0); //the second of every group of three becomes a welder
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -16,5 +24,156 @@ public class TileEntityMachineAssemfac extends TileEntityMachineBase {
|
|||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
|
if(worldObj.isRemote) {
|
||||||
|
for(AssemblerArm arm : arms) {
|
||||||
|
arm.updateArm();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AssemblerArm {
|
||||||
|
public double[] angles = new double[4];
|
||||||
|
public double[] prevAngles = new double[4];
|
||||||
|
public double[] targetAngles = new double[4];
|
||||||
|
public double[] speed = new double[4];
|
||||||
|
|
||||||
|
Random rand = new Random();
|
||||||
|
|
||||||
|
int actionMode;
|
||||||
|
ArmActionState state;
|
||||||
|
int actionDelay = 0;
|
||||||
|
|
||||||
|
public AssemblerArm(int actionMode) {
|
||||||
|
this.actionMode = actionMode;
|
||||||
|
|
||||||
|
if(this.actionMode == 0) {
|
||||||
|
speed[0] = 15; //Pivot
|
||||||
|
speed[1] = 15; //Arm
|
||||||
|
speed[2] = 15; //Piston
|
||||||
|
speed[3] = 0.5; //Striker
|
||||||
|
} else if(this.actionMode == 1) {
|
||||||
|
speed[0] = 3; //Pivot
|
||||||
|
speed[1] = 3; //Arm
|
||||||
|
speed[2] = 1; //Piston
|
||||||
|
speed[3] = 0.125; //Striker
|
||||||
|
}
|
||||||
|
|
||||||
|
state = ArmActionState.ASSUME_POSITION;
|
||||||
|
chooseNewArmPoistion();
|
||||||
|
actionDelay = rand.nextInt(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateArm() {
|
||||||
|
updateInterp();
|
||||||
|
|
||||||
|
if(actionDelay > 0) {
|
||||||
|
actionDelay--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(state) {
|
||||||
|
//Move. If done moving, set a delay and progress to EXTEND
|
||||||
|
case ASSUME_POSITION:
|
||||||
|
if(move()) {
|
||||||
|
if(this.actionMode == 0) {
|
||||||
|
actionDelay = 2;
|
||||||
|
} else if(this.actionMode == 1) {
|
||||||
|
actionDelay = 10;
|
||||||
|
}
|
||||||
|
state = ArmActionState.EXTEND_STRIKER;
|
||||||
|
targetAngles[3] = 1D;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EXTEND_STRIKER:
|
||||||
|
if(move()) {
|
||||||
|
if(this.actionMode == 0) {
|
||||||
|
state = ArmActionState.RETRACT_STRIKER;
|
||||||
|
targetAngles[3] = 0D;
|
||||||
|
} else if(this.actionMode == 1) {
|
||||||
|
state = ArmActionState.WELD;
|
||||||
|
targetAngles[2] -= 20;
|
||||||
|
actionDelay = 5 + rand.nextInt(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WELD:
|
||||||
|
if(move()) {
|
||||||
|
state = ArmActionState.RETRACT_STRIKER;
|
||||||
|
targetAngles[3] = 0D;
|
||||||
|
actionDelay = 10 + rand.nextInt(5);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RETRACT_STRIKER:
|
||||||
|
if(move()) {
|
||||||
|
if(this.actionMode == 0) {
|
||||||
|
actionDelay = 2 + rand.nextInt(5);
|
||||||
|
} else if(this.actionMode == 1) {
|
||||||
|
actionDelay = 5 + rand.nextInt(3);
|
||||||
|
}
|
||||||
|
chooseNewArmPoistion();
|
||||||
|
state = ArmActionState.ASSUME_POSITION;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void chooseNewArmPoistion() {
|
||||||
|
|
||||||
|
if(this.actionMode == 0) {
|
||||||
|
targetAngles[0] = -rand.nextInt(50); //Pivot
|
||||||
|
targetAngles[1] = -targetAngles[0]; //Arm
|
||||||
|
targetAngles[2] = rand.nextInt(30) - 15; //Piston
|
||||||
|
} else if(this.actionMode == 1) {
|
||||||
|
targetAngles[0] = rand.nextInt(10); //Pivot
|
||||||
|
targetAngles[1] = -targetAngles[0]; //Arm
|
||||||
|
targetAngles[2] = 20; //Piston
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateInterp() {
|
||||||
|
for(int i = 0; i < angles.length; i++) {
|
||||||
|
prevAngles[i] = angles[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return True when it has finished moving
|
||||||
|
*/
|
||||||
|
private boolean move() {
|
||||||
|
boolean didMove = false;
|
||||||
|
|
||||||
|
for(int i = 0; i < angles.length; i++) {
|
||||||
|
if(angles[i] == targetAngles[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
didMove = true;
|
||||||
|
|
||||||
|
double angle = angles[i];
|
||||||
|
double target = targetAngles[i];
|
||||||
|
double turn = speed[i];
|
||||||
|
double delta = Math.abs(angle - target);
|
||||||
|
|
||||||
|
if(delta <= turn) {
|
||||||
|
angles[i] = targetAngles[i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(angle < target) {
|
||||||
|
angles[i] += turn;
|
||||||
|
} else {
|
||||||
|
angles[i] -= turn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return !didMove;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum ArmActionState {
|
||||||
|
ASSUME_POSITION,
|
||||||
|
EXTEND_STRIKER,
|
||||||
|
WELD,
|
||||||
|
RETRACT_STRIKER
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/main/resources/assets/hbm/textures/items/hyb_base.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/hyb_base.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 258 B |
BIN
src/main/resources/assets/hbm/textures/items/hyb_base_alt.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/hyb_base_alt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 401 B |
Loading…
x
Reference in New Issue
Block a user