Skip to content

Commit

Permalink
Fluids in GUIs now render again
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMCBrothers-Manager committed Dec 30, 2019
1 parent 44e6870 commit 7112d1f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@

### 1.15.1-3.0.1
- Fluids in guis render again

### 1.15.1-3.0.0
- Initial 1.15.1 release
- Many rendering issues are present

### 1.14.4-2.2.7
- Fixed upgrading machine does not consume item
- Useless Ingots are now valid beacon payment

### 1.14.4-2.2.6
- Added compatibility for [Mystical Agriculture](https://www.curseforge.com/minecraft/mc-mods/mystical-agriculture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.fluid.Fluid;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.PlayerContainer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fluids.FluidAttributes;
Expand Down Expand Up @@ -98,12 +99,10 @@ protected void drawTiledSprite(final int xPosition, final int yPosition, final i

private static TextureAtlasSprite getStillFluidSprite(FluidStack fluidStack) {
Minecraft minecraft = Minecraft.getInstance();
// AtlasTexture textureMapBlocks = minecraft.getTextureMap();
AtlasTexture textureMapBlocks = new AtlasTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
Fluid fluid = fluidStack.getFluid();
FluidAttributes attributes = fluid.getAttributes();
ResourceLocation fluidStill = attributes.getStillTexture(fluidStack);
return textureMapBlocks.getSprite(fluidStill);
return minecraft.func_228015_a_(PlayerContainer.field_226615_c_).apply(fluidStill);
}

private static void setGLColorFromInt(int color) {
Expand All @@ -116,22 +115,22 @@ private static void setGLColorFromInt(int color) {
}

private static void drawTextureWithMasking(double xCoord, double yCoord, TextureAtlasSprite textureSprite, int maskTop, int maskRight, double zLevel) {
// double uMin = textureSprite.getMinU();
// double uMax = textureSprite.getMaxU();
// double vMin = textureSprite.getMinV();
// double vMax = textureSprite.getMaxV();
// uMax = uMax - (maskRight / 16.0 * (uMax - uMin));
// vMax = vMax - (maskTop / 16.0 * (vMax - vMin));
//
// Tessellator tessellator = Tessellator.getInstance();
// BufferBuilder bufferBuilder = tessellator.getBuffer();
// bufferBuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
// bufferBuilder.func_225582_a_(xCoord, yCoord + 16, zLevel).tex(uMin, vMax).endVertex();
// bufferBuilder.func_225582_a_(xCoord + 16 - maskRight, yCoord + 16, zLevel).tex(uMax, vMax).endVertex();
// bufferBuilder.func_225582_a_(xCoord + 16 - maskRight, yCoord + maskTop, zLevel).tex(uMax, vMin).endVertex();
// bufferBuilder.func_225582_a_(xCoord, yCoord + maskTop, zLevel).tex(uMin, vMin).endVertex();
//
// tessellator.draw();
double uMin = textureSprite.getMinU();
double uMax = textureSprite.getMaxU();
double vMin = textureSprite.getMinV();
double vMax = textureSprite.getMaxV();
uMax = uMax - (maskRight / 16.0 * (uMax - uMin));
vMax = vMax - (maskTop / 16.0 * (vMax - vMin));

Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
bufferBuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferBuilder.func_225582_a_(xCoord, yCoord + 16, zLevel).func_225583_a_((float) uMin, (float) vMax).endVertex();
bufferBuilder.func_225582_a_(xCoord + 16 - maskRight, yCoord + 16, zLevel).func_225583_a_((float) uMax, (float) vMax).endVertex();
bufferBuilder.func_225582_a_(xCoord + 16 - maskRight, yCoord + maskTop, zLevel).func_225583_a_((float) uMax, (float) vMin).endVertex();
bufferBuilder.func_225582_a_(xCoord, yCoord + maskTop, zLevel).func_225583_a_((float) uMin, (float) vMin).endVertex();

tessellator.draw();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextC
String toTranslate = this.getTranslationKey() + ".desc";
if (I18n.hasKey(toTranslate)) {
ITextComponent desc = new TranslationTextComponent("tooltip.uselessmod.press_shift");
int state = GLFW.glfwGetKey(Minecraft.getInstance().mainWindow.getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT);
int state = GLFW.glfwGetKey(Minecraft.getInstance().func_228018_at_().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT);
if (state == GLFW.GLFW_PRESS)
desc = new TranslationTextComponent(toTranslate);
tooltip.add(desc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextC
super.addInformation(stack, worldIn, tooltip, flagIn);
assert worldIn != null;
if(stack.hasTag() && stack.getTag().contains("BlockEntityTag", Constants.NBT.TAG_COMPOUND) && stack.getChildTag("BlockEntityTag").contains("Lights", Constants.NBT.TAG_LONG_ARRAY)) {
if(GLFW.glfwGetKey(Minecraft.getInstance().mainWindow.getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) == GLFW.GLFW_PRESS) {
if(GLFW.glfwGetKey(Minecraft.getInstance().func_228018_at_().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) == GLFW.GLFW_PRESS) {
for(long l : stack.getChildTag("BlockEntityTag").getLongArray("Lights")) {
BlockPos pos = BlockPos.fromLong(l);
BlockState state = worldIn.getBlockState(pos);
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#Make some things public
public-f net.minecraft.item.AxeItem field_203176_a # BLOCK_STRIPPING_MAP
public net.minecraft.client.Minecraft field_195558_d # mainWindow
public-f net.minecraft.item.AxeItem field_203176_a # BLOCK_STRIPPING_MAP
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
{
"condition": "minecraft:block_state_property",
"block": "minecraft:large_useless_fern",
"block": "uselessmod:large_useless_fern",
"properties": {
"half": "lower"
}
Expand Down

0 comments on commit 7112d1f

Please sign in to comment.