Skip to content

Commit

Permalink
Merge pull request #681 from Paul19988/1.7-Community-4.3
Browse files Browse the repository at this point in the history
Cleanup & fixes to fluidtanks
  • Loading branch information
EternalBlueFlame authored Nov 24, 2023
2 parents f4b6536 + b8d0674 commit b8b7988
Show file tree
Hide file tree
Showing 122 changed files with 14,027 additions and 14,306 deletions.
6 changes: 5 additions & 1 deletion src/main/java/train/client/gui/GuiLiquid.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ protected void drawGuiContainerBackgroundLayer(float f, int t, int g) {
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);

int l = (liquid.getAmount() * 50) / liquid.getCapacity();
int l = 0;

if (liquid.getAmount() > 0 && liquid.getCapacity() > 0) {
l = (liquid.getAmount() * 50) / liquid.getCapacity();
}

Fluid theLiquid = FluidRegistry.getFluid(liquid.getLiquidItemID());
// Don't render anything if the cart is empty.
Expand Down
164 changes: 83 additions & 81 deletions src/main/java/train/client/render/CustomModelRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,88 +10,90 @@
import java.util.ArrayList;

public class CustomModelRenderer extends ModelRendererTurbo {
public CustomModelRenderer(ModelBase m, int i, int j, int w, int h) {
super(m, i, j, w, h);
}

@Override
public ModelRendererTurbo addBox(float f, float f1, float f2, int i, int j, int k) {
addBox(f, f1, f2, i, j, k, 0.0f);
return this;
}

public CustomModelRenderer(ModelBase m, int i, int j, int w, int h) {
super(m,i,j,w,h);
}

@Override
public ModelRendererTurbo addBox(float f, float f1, float f2, int i, int j, int k) {
addBox(f, f1, f2, i, j, k, 0.0f);
return this;
}

//for some odd reason the boxes seem inside out normally, so it's likely the values are reversed
@Override
public ModelRendererTurbo addBox(float f, float f1, float f2, int i, int j, int k, float f3) {
faces = new ArrayList<TexturedPolygon>();
float f4 = f + i +f3;
float f5 = f1 + j +f3;
float f6 = f2 + k +f3;
f -= f3;
f1 -= f3;
f2 -= f3;
TexturedVertex TexturedVertex = new TexturedVertex(f, f1, f2, 0.0F, 0.0F);
TexturedVertex TexturedVertex1 = new TexturedVertex(f4, f1, f2, 0.0F, 8F);
TexturedVertex TexturedVertex2 = new TexturedVertex(f4, f5, f2, 8F, 8F);
TexturedVertex TexturedVertex3 = new TexturedVertex(f, f5, f2, 8F, 0.0F);
TexturedVertex TexturedVertex4 = new TexturedVertex(f, f1, f6, 0.0F, 0.0F);
TexturedVertex TexturedVertex5 = new TexturedVertex(f4, f1, f6, 0.0F, 8F);
TexturedVertex TexturedVertex6 = new TexturedVertex(f4, f5, f6, 8F, 8F);
TexturedVertex TexturedVertex7 = new TexturedVertex(f, f5, f6, 8F, 0.0F);
faces.add(generateFaces(new TexturedVertex[] { TexturedVertex5, TexturedVertex1, TexturedVertex2, TexturedVertex6 }, textureOffsetX + k + i, textureOffsetY + k, textureOffsetX + k + i + k, textureOffsetY + k + j, textureWidth, textureHeight));
faces.add(generateFaces(new TexturedVertex[] { TexturedVertex, TexturedVertex4, TexturedVertex7, TexturedVertex3 }, textureOffsetX, textureOffsetY + k, textureOffsetX + k, textureOffsetY + k + j, textureWidth, textureHeight));
faces.add(generateFaces(new TexturedVertex[] { TexturedVertex5, TexturedVertex4, TexturedVertex, TexturedVertex1 }, textureOffsetX + k, textureOffsetY, textureOffsetX + k + i, textureOffsetY + k, textureWidth, textureHeight));
faces.add(generateFaces(new TexturedVertex[] { TexturedVertex2, TexturedVertex3, TexturedVertex7, TexturedVertex6 }, textureOffsetX + k + i, textureOffsetY, textureOffsetX + k + i + i, textureOffsetY + k, textureWidth, textureHeight));
faces.add(generateFaces(new TexturedVertex[] { TexturedVertex1, TexturedVertex, TexturedVertex3, TexturedVertex2 }, textureOffsetX + k, textureOffsetY + k, textureOffsetX + k + i, textureOffsetY + k + j, textureWidth, textureHeight));
faces.add(generateFaces(new TexturedVertex[] { TexturedVertex4, TexturedVertex5, TexturedVertex6, TexturedVertex7 }, textureOffsetX + k + i + k, textureOffsetY + k, textureOffsetX + k + i + k + i, textureOffsetY + k + j, textureWidth, textureHeight));
return this;
}

private static TexturedPolygon generateFaces(TexturedVertex aPositionTransformVertex[], int i, int j, int k, int l, float textureWidth, float textureHeight) {
aPositionTransformVertex[0] = new TexturedVertex(aPositionTransformVertex[0].vector3F, (float) k / textureWidth - 0.0015625F, (float) j / textureHeight + 0.003125F);
aPositionTransformVertex[1] = new TexturedVertex(aPositionTransformVertex[1].vector3F,(float) i / textureWidth + 0.0015625F, (float) j / textureHeight + 0.003125F);
aPositionTransformVertex[2] = new TexturedVertex(aPositionTransformVertex[2].vector3F,(float) i / textureWidth + 0.0015625F, (float) l / textureHeight - 0.003125F);
aPositionTransformVertex[3] = new TexturedVertex(aPositionTransformVertex[3].vector3F,(float) k / textureWidth - 0.0015625F, (float) l / textureHeight - 0.003125F);
return new TexturedPolygon(aPositionTransformVertex);
}

private static final float degreesF = (float)(180D/Math.PI);

//same as super, but old models have inverse Y rotations and I don't even understand the Z rotation
public void render(float worldScale, boolean invertYZ) {

if(!showModel) {
return;
}
if(!compiled) {
compileDisplayList(worldScale);
return;
}
if (rotateAngleX != 0.0F || rotateAngleY != 0.0F || rotateAngleZ != 0.0F) {
GL11.glPushMatrix();
GL11.glTranslatef(rotationPointX * worldScale, rotationPointY * worldScale, rotationPointZ *worldScale);
if (rotateAngleZ != 0.0F) {
GL11.glRotatef(rotateAngleZ * degreesF, 0.0F, 0.0F, 1.0F);
}
if (rotateAngleY != 0.0F) {
GL11.glRotatef(rotateAngleY * degreesF, 0.0F, 1.0F, 0.0F);
}
if (rotateAngleX != 0.0F) {
GL11.glRotatef(rotateAngleX * degreesF, 1.0F, 0.0F, 0.0F);
}
callDisplayList();
GL11.glPopMatrix();
}
else if (rotationPointX != 0.0F || rotationPointY != 0.0F || rotationPointZ != 0.0F) {
GL11.glTranslatef(rotationPointX * worldScale, rotationPointY * worldScale, rotationPointZ * worldScale);
callDisplayList();
GL11.glTranslatef(-rotationPointX * worldScale, -rotationPointY * worldScale, -rotationPointZ * worldScale);
}
else {
callDisplayList();
}
}
// For some odd reason the boxes seem inside out normally, so it's likely the values are reversed
@Override
public ModelRendererTurbo addBox(float f, float f1, float f2, int i, int j, int k, float f3) {
faces = new ArrayList<>();
float f4 = f + i + f3;
float f5 = f1 + j + f3;
float f6 = f2 + k + f3;

f -= f3;
f1 -= f3;
f2 -= f3;

TexturedVertex TexturedVertex = new TexturedVertex(f, f1, f2, 0.0F, 0.0F);
TexturedVertex TexturedVertex1 = new TexturedVertex(f4, f1, f2, 0.0F, 8F);
TexturedVertex TexturedVertex2 = new TexturedVertex(f4, f5, f2, 8F, 8F);
TexturedVertex TexturedVertex3 = new TexturedVertex(f, f5, f2, 8F, 0.0F);
TexturedVertex TexturedVertex4 = new TexturedVertex(f, f1, f6, 0.0F, 0.0F);
TexturedVertex TexturedVertex5 = new TexturedVertex(f4, f1, f6, 0.0F, 8F);
TexturedVertex TexturedVertex6 = new TexturedVertex(f4, f5, f6, 8F, 8F);
TexturedVertex TexturedVertex7 = new TexturedVertex(f, f5, f6, 8F, 0.0F);

faces.add(generateFaces(new TexturedVertex[]{TexturedVertex5, TexturedVertex1, TexturedVertex2, TexturedVertex6}, textureOffsetX + k + i, textureOffsetY + k, textureOffsetX + k + i + k, textureOffsetY + k + j, textureWidth, textureHeight));
faces.add(generateFaces(new TexturedVertex[]{TexturedVertex, TexturedVertex4, TexturedVertex7, TexturedVertex3}, textureOffsetX, textureOffsetY + k, textureOffsetX + k, textureOffsetY + k + j, textureWidth, textureHeight));
faces.add(generateFaces(new TexturedVertex[]{TexturedVertex5, TexturedVertex4, TexturedVertex, TexturedVertex1}, textureOffsetX + k, textureOffsetY, textureOffsetX + k + i, textureOffsetY + k, textureWidth, textureHeight));
faces.add(generateFaces(new TexturedVertex[]{TexturedVertex2, TexturedVertex3, TexturedVertex7, TexturedVertex6}, textureOffsetX + k + i, textureOffsetY, textureOffsetX + k + i + i, textureOffsetY + k, textureWidth, textureHeight));
faces.add(generateFaces(new TexturedVertex[]{TexturedVertex1, TexturedVertex, TexturedVertex3, TexturedVertex2}, textureOffsetX + k, textureOffsetY + k, textureOffsetX + k + i, textureOffsetY + k + j, textureWidth, textureHeight));
faces.add(generateFaces(new TexturedVertex[]{TexturedVertex4, TexturedVertex5, TexturedVertex6, TexturedVertex7}, textureOffsetX + k + i + k, textureOffsetY + k, textureOffsetX + k + i + k + i, textureOffsetY + k + j, textureWidth, textureHeight));
return this;
}

private static TexturedPolygon generateFaces(TexturedVertex aPositionTransformVertex[], int i, int j, int k, int l, float textureWidth, float textureHeight) {
aPositionTransformVertex[0] = new TexturedVertex(aPositionTransformVertex[0].vector3F, (float) k / textureWidth - 0.0015625F, (float) j / textureHeight + 0.003125F);
aPositionTransformVertex[1] = new TexturedVertex(aPositionTransformVertex[1].vector3F, (float) i / textureWidth + 0.0015625F, (float) j / textureHeight + 0.003125F);
aPositionTransformVertex[2] = new TexturedVertex(aPositionTransformVertex[2].vector3F, (float) i / textureWidth + 0.0015625F, (float) l / textureHeight - 0.003125F);
aPositionTransformVertex[3] = new TexturedVertex(aPositionTransformVertex[3].vector3F, (float) k / textureWidth - 0.0015625F, (float) l / textureHeight - 0.003125F);
return new TexturedPolygon(aPositionTransformVertex);
}

private static final float degreesF = (float) (180D / Math.PI);

// Same as super, but old models have inverse Y rotations and I don't even understand the Z rotation
public void render(float worldScale, boolean invertYZ) {
if (!showModel) {
return;
}

if (!compiled) {
compileDisplayList(worldScale);
return;
}

if (rotateAngleX != 0.0F || rotateAngleY != 0.0F || rotateAngleZ != 0.0F) {
GL11.glPushMatrix();
GL11.glTranslatef(rotationPointX * worldScale, rotationPointY * worldScale, rotationPointZ * worldScale);
if (rotateAngleZ != 0.0F) {
GL11.glRotatef(rotateAngleZ * degreesF, 0.0F, 0.0F, 1.0F);
}

if (rotateAngleY != 0.0F) {
GL11.glRotatef(rotateAngleY * degreesF, 0.0F, 1.0F, 0.0F);
}

if (rotateAngleX != 0.0F) {
GL11.glRotatef(rotateAngleX * degreesF, 1.0F, 0.0F, 0.0F);
}

callDisplayList();
GL11.glPopMatrix();
} else if (rotationPointX != 0.0F || rotationPointY != 0.0F || rotationPointZ != 0.0F) {
GL11.glTranslatef(rotationPointX * worldScale, rotationPointY * worldScale, rotationPointZ * worldScale);
callDisplayList();
GL11.glTranslatef(-rotationPointX * worldScale, -rotationPointY * worldScale, -rotationPointZ * worldScale);
} else {
callDisplayList();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import train.common.library.Info;

public class ItemRenderAmericanStopper implements IItemRenderer {
private static final ResourceLocation texture = new ResourceLocation(Info.resourceLocation,Info.modelTexPrefix + "buffer.png");
private static final ResourceLocation texture = new ResourceLocation(Info.resourceLocation, Info.modelTexPrefix + "buffer.png");
private static final ModelAmericanStopper americanStopper = new ModelAmericanStopper(1F);

public ItemRenderAmericanStopper() {
Expand Down
139 changes: 69 additions & 70 deletions src/main/java/train/client/render/ItemRenderBook.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2013 Mrbrutal. All rights reserved.
*
*
* @name Traincraft
* @author Mrbrutal
******************************************************************************/
Expand All @@ -17,68 +17,67 @@
import train.common.library.Info;

public class ItemRenderBook implements IItemRenderer {

ModelTCBook book1;
ModelTCBook book2;

public static boolean open = false;

public ItemRenderBook() {
book1 = new ModelTCBook();
book2 = new ModelTCBook();
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
ModelTCBook book1;
ModelTCBook book2;

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
public static boolean open = false;

@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
switch (type) {
case ENTITY: {
renderBook(0.0F, 1.0F, 0.0F, 0.0F, 0.0f, 0.0f, 0.0f, 1.5F);
break;
}
case EQUIPPED: {
renderBook(0.3F, 0.6F, 0.7F, 70.0F, 0.0f, 1.0f, 0.0f, 1.0F);
break;
}
case EQUIPPED_FIRST_PERSON: {
if(open) {
rotateBook(-0.7F, 1.8F, -0.277F, -45.0F, 0.0f, 1.0f, 0.0f, 1.0f+Minecraft.getMinecraft().currentScreen.height*0.003f);
}
else {
renderBook(0F, 0.8F, 0F, 0.0F, 0.0f, 1.0f, 0.0f, 1.0F);
}
return;
}
case INVENTORY: {
renderBook(0.5F, 0.4F, 0.5F, 180.0F, 0.0f, 1.0f, 0.0f, 1.2F);
break;
}
default:
break;
}
}
public ItemRenderBook() {
book1 = new ModelTCBook();
book2 = new ModelTCBook();
}

private void renderBook(float left, float up, float right, float rotation, float x, float y, float z, float scale) {
Tessellator tesselator = Tessellator.instance;
tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation,Info.modelTexPrefix + "book2.png"));
GL11.glPushMatrix();
GL11.glTranslatef(left, up, right);
GL11.glRotatef(rotation, x, y, z);
GL11.glScalef(scale, scale, scale);
book1.render(20);
GL11.glPopMatrix();
}

private void rotateBook(float left, float up, float right, float rotation, float x, float y, float z, float scale) {
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}

@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
switch (type) {
case ENTITY: {
renderBook(0.0F, 1.0F, 0.0F, 0.0F, 0.0f, 0.0f, 0.0f, 1.5F);
break;
}
case EQUIPPED: {
renderBook(0.3F, 0.6F, 0.7F, 70.0F, 0.0f, 1.0f, 0.0f, 1.0F);
break;
}
case EQUIPPED_FIRST_PERSON: {
if (open) {
rotateBook(-0.7F, 1.8F, -0.277F, -45.0F, 0.0f, 1.0f, 0.0f, 1.0f + Minecraft.getMinecraft().currentScreen.height * 0.003f);
} else {
renderBook(0F, 0.8F, 0F, 0.0F, 0.0f, 1.0f, 0.0f, 1.0F);
}
return;
}
case INVENTORY: {
renderBook(0.5F, 0.4F, 0.5F, 180.0F, 0.0f, 1.0f, 0.0f, 1.2F);
break;
}
default:
break;
}
}

private void renderBook(float left, float up, float right, float rotation, float x, float y, float z, float scale) {
Tessellator tesselator = Tessellator.instance;
tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, Info.modelTexPrefix + "book2.png"));
GL11.glPushMatrix();
GL11.glTranslatef(left, up, right);
GL11.glRotatef(rotation, x, y, z);
GL11.glScalef(scale, scale, scale);
book1.render(20);
GL11.glPopMatrix();
}

private void rotateBook(float left, float up, float right, float rotation, float x, float y, float z, float scale) {
// if(upp) {
// w++;
// }
Expand All @@ -93,16 +92,16 @@ private void rotateBook(float left, float up, float right, float rotation, float
// upp = true;
// down = false;
// }
//System.out.println(w/10);
tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation,Info.modelTexPrefix + "book2.png"));
GL11.glPushMatrix();
GL11.glTranslatef(left, up, right);
GL11.glTranslatef(0.5f, 1.f, -0.5f);
GL11.glRotatef(rotation, x, y, z);
GL11.glRotatef(-25.0f, 1.0f, 0.0f, 0.0f);
GL11.glScalef(scale, scale, scale);
book1.rotate(10/*+(int)((Math.sin(w)*10)-(Math.sin(w))%10)*/);
GL11.glPopMatrix();
}
//System.out.println(w/10);
tmt.Tessellator.bindTexture(new ResourceLocation(Info.resourceLocation, Info.modelTexPrefix + "book2.png"));
GL11.glPushMatrix();
GL11.glTranslatef(left, up, right);
GL11.glTranslatef(0.5f, 1.f, -0.5f);
GL11.glRotatef(rotation, x, y, z);
GL11.glRotatef(-25.0f, 1.0f, 0.0f, 0.0f);
GL11.glScalef(scale, scale, scale);
book1.rotate(10/*+(int)((Math.sin(w)*10)-(Math.sin(w))%10)*/);
GL11.glPopMatrix();
}

}
Loading

0 comments on commit b8b7988

Please sign in to comment.