Skip to content

Commit

Permalink
fix fluid not rendering in ender tank (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexdoru authored Oct 2, 2024
1 parent 9b254ed commit 9fe5155
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import codechicken.enderstorage.storage.liquid.EnderTankRenderer;
import codechicken.enderstorage.storage.liquid.TankSynchroniser;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.vec.Vector3;

public class ItemEnderStorageRenderer implements IItemRenderer {

Expand All @@ -23,9 +22,18 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Vector3 d = new Vector3();
if (type != ItemRenderType.EQUIPPED_FIRST_PERSON && type != ItemRenderType.EQUIPPED) d.add(-0.5, -0.5, -0.5);

final double x;
final double y;
final double z;
if (type != ItemRenderType.EQUIPPED_FIRST_PERSON && type != ItemRenderType.EQUIPPED) {
x = -0.5;
y = -0.5;
z = -0.5;
} else {
x = 0;
y = 0;
z = 0;
}
int freq = item.getItemDamage() & 0xFFF;
String owner = item.hasTagCompound() ? item.getTagCompound().getString("owner") : "global";
int rotation = 0;
Expand All @@ -34,14 +42,14 @@ public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
final CCRenderState state = CCRenderState.instance();
switch (item.getItemDamage() >> 12) {
case 0:
EnderChestRenderer.renderChest(state, rotation, freq, !owner.equals("global"), d.x, d.y, d.z, 0, 0);
EnderChestRenderer.renderChest(state, rotation, freq, !owner.equals("global"), x, y, z, 0, 0);
break;
case 1:
state.reset();
state.pullLightmap();
state.useNormals = true;
EnderTankRenderer.renderTank(state, rotation, 0, freq, !owner.equals("global"), d.x, d.y, d.z, 0);
EnderTankRenderer.renderLiquid(TankSynchroniser.getClientLiquid(freq, owner), d.x, d.y, d.z);
EnderTankRenderer.renderTank(state, rotation, 0, freq, !owner.equals("global"), x, y, z, 0);
EnderTankRenderer.renderLiquid(TankSynchroniser.getClientLiquid(freq, owner), x, y, z);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class EnderChestRenderer extends TileEntitySpecialRenderer {

private static final ModelEnderChest model = new ModelEnderChest();
static final Vector3 Y = new Vector3(0, 1, 0);
private static final Vector3 Y = new Vector3(0, 1, 0);

public EnderChestRenderer() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,23 @@

public class EnderTankRenderer extends TileEntitySpecialRenderer {

static final CCModel tankModel;
static final CCModel valveModel;
static final CCModel[] buttons;

static final UVTranslation[] UVTranslationButtons = new UVTranslation[16];
static final UVTranslation UVTvalveOwned = new UVTranslation(0, 13 / 64D);
static final UVTranslation UVTvalveNotOwned = new UVTranslation(0, 0);
static final Vector3 Y = new Vector3(0, 1, 0);
static final Vector3 Z = new Vector3(0, 0, 1);
static final Vector3 point = new Vector3(0, 0.4165, 0);

static final Cuboid6 cuboidFLuid = new Cuboid6(0.22, 0.12, 0.22, 0.78, 0.121 + 0.63, 0.78);

static final RenderCustomEndPortal renderEndPortal = new RenderCustomEndPortal(0.1205, 0.24, 0.76, 0.24, 0.76);
private static final CCModel tankModel;
private static final CCModel valveModel;
private static final CCModel[] buttons;

private static final UVTranslation[] UVTranslationButtons = new UVTranslation[16];
private static final UVTranslation UVTvalveOwned = new UVTranslation(0, 13 / 64D);
private static final UVTranslation UVTvalveNotOwned = new UVTranslation(0, 0);
private static final Vector3 Y = new Vector3(0, 1, 0);
private static final Vector3 Z = new Vector3(0, 0, 1);
private static final Vector3 point = new Vector3(0, 0.4165, 0);

private static final RenderCustomEndPortal renderEndPortal = new RenderCustomEndPortal(
0.1205,
0.24,
0.76,
0.24,
0.76);

static {
Map<String, CCModel> models = CCModel
Expand Down Expand Up @@ -161,7 +164,7 @@ public static void renderTank(CCRenderState state, int rotation, float valve, in
public static void renderLiquid(FluidStack liquid, double x, double y, double z) {
RenderUtils.renderFluidCuboid(
liquid,
cuboidFLuid.add(new Vector3(x, y, z)),
new Cuboid6(0.22 + x, 0.12 + y, 0.22 + z, 0.78 + x, 0.121 + 0.63 + y, 0.78 + z),
liquid.amount / ((double) EnderStorage.enderTankSize * FluidUtils.B),
0.75);
}
Expand Down

0 comments on commit 9fe5155

Please sign in to comment.