Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'disastermoo/sluicedev'
# Conflicts: # src/main/resources/assets
- Loading branch information
Showing
19 changed files
with
909 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
src/main/java/net/dries007/tfc/client/render/TESRSluice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Work under Copyright. Licensed under the EUPL. | ||
* See the project README.md and LICENSE.txt for more information. | ||
*/ | ||
|
||
package net.dries007.tfc.client.render; | ||
|
||
import org.lwjgl.opengl.GL11; | ||
import net.minecraft.client.renderer.BufferBuilder; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.client.renderer.Tessellator; | ||
import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||
import net.minecraft.client.renderer.texture.TextureMap; | ||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; | ||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraftforge.fluids.Fluid; | ||
|
||
import net.dries007.tfc.client.FluidSpriteCache; | ||
import net.dries007.tfc.objects.te.TESluice; | ||
|
||
public class TESRSluice extends TileEntitySpecialRenderer<TESluice> | ||
{ | ||
@Override | ||
public void render(TESluice te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) | ||
{ | ||
Fluid flowing = te.getFlowingFluid(); | ||
if (flowing == null) return; | ||
|
||
GlStateManager.pushMatrix(); | ||
GlStateManager.translate(x, y, z); | ||
|
||
EnumFacing facing = te.getBlockFacing(); | ||
//noinspection ConstantConditions | ||
switch (facing) | ||
{ | ||
case WEST: | ||
GlStateManager.translate(0, 0, 1); | ||
GlStateManager.rotate(90F, 0, 1, 0); | ||
break; | ||
case SOUTH: | ||
GlStateManager.translate(1, 0, 1); | ||
GlStateManager.rotate(180F, 0, 1, 0); | ||
break; | ||
case EAST: | ||
GlStateManager.translate(1, 0, 0); | ||
GlStateManager.rotate(270F, 0, 1, 0); | ||
break; | ||
default: | ||
} | ||
|
||
|
||
TextureAtlasSprite sprite = FluidSpriteCache.getFlowingSprite(flowing); | ||
|
||
GlStateManager.enableAlpha(); | ||
GlStateManager.enableBlend(); | ||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); | ||
|
||
int color = flowing.getColor(); | ||
|
||
float r = ((color >> 16) & 0xFF) / 255F; | ||
float g = ((color >> 8) & 0xFF) / 255F; | ||
float b = (color & 0xFF) / 255F; | ||
float a = ((color >> 24) & 0xFF) / 255F; | ||
|
||
GlStateManager.color(r, g, b, a); | ||
|
||
rendererDispatcher.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); | ||
|
||
BufferBuilder buffer = Tessellator.getInstance().getBuffer(); | ||
|
||
//Top | ||
buffer.begin(GL11.GL_POLYGON, DefaultVertexFormats.POSITION_TEX_NORMAL); | ||
|
||
buffer.pos(0.05D, 1.033D, 0).tex(sprite.getMinU(), sprite.getMinV()).normal(0, 0, 1).endVertex(); | ||
buffer.pos(0.05D, -0.15D, 2.45D).tex(sprite.getMinU(), sprite.getMaxV()).normal(0, 0, 1).endVertex(); | ||
buffer.pos(0.95D, -0.15D, 2.45D).tex(sprite.getMaxU(), sprite.getMaxV()).normal(0, 0, 1).endVertex(); | ||
buffer.pos(0.95D, 1.033D, 0).tex(sprite.getMaxU(), sprite.getMinV()).normal(0, 0, 1).endVertex(); | ||
|
||
Tessellator.getInstance().draw(); | ||
|
||
//Bottom | ||
buffer.begin(GL11.GL_POLYGON, DefaultVertexFormats.POSITION_TEX_NORMAL); | ||
|
||
buffer.pos(0.05D, 0.833D, 0).tex(sprite.getMinU(), sprite.getMinV()).normal(0, 0, 1).endVertex(); | ||
buffer.pos(0.05D, -0.3D, 2.45D).tex(sprite.getMinU(), sprite.getMaxV()).normal(0, 0, 1).endVertex(); | ||
buffer.pos(0.95D, -0.3D, 2.45D).tex(sprite.getMaxU(), sprite.getMaxV()).normal(0, 0, 1).endVertex(); | ||
buffer.pos(0.95D, 0.833D, 0).tex(sprite.getMaxU(), sprite.getMinV()).normal(0, 0, 1).endVertex(); | ||
|
||
Tessellator.getInstance().draw(); | ||
|
||
//Left | ||
buffer.begin(GL11.GL_POLYGON, DefaultVertexFormats.POSITION_TEX_NORMAL); | ||
|
||
buffer.pos(0.05D, -0.15D, 2.45D).tex(sprite.getMinU(), sprite.getMaxV()).normal(0, 0, 1).endVertex(); | ||
buffer.pos(0.05D, 1.033D, 0).tex(sprite.getMinU(), sprite.getMinV()).normal(0, 0, 1).endVertex(); | ||
buffer.pos(0.05D, 0.833D, 0).tex(sprite.getMaxU(), sprite.getMinV()).normal(0, 0, 1).endVertex(); | ||
buffer.pos(0.05D, -0.3D, 2.45D).tex(sprite.getMaxU(), sprite.getMaxV()).normal(0, 0, 1).endVertex(); | ||
|
||
Tessellator.getInstance().draw(); | ||
|
||
//Right | ||
buffer.begin(GL11.GL_POLYGON, DefaultVertexFormats.POSITION_TEX_NORMAL); | ||
|
||
buffer.pos(0.95D, 1.033D, 0).tex(sprite.getMinU(), sprite.getMinV()).normal(0, 0, 1).endVertex(); | ||
buffer.pos(0.95D, -0.15D, 2.45D).tex(sprite.getMinU(), sprite.getMaxV()).normal(0, 0, 1).endVertex(); | ||
buffer.pos(0.95D, -0.3D, 2.45D).tex(sprite.getMaxU(), sprite.getMaxV()).normal(0, 0, 1).endVertex(); | ||
buffer.pos(0.95D, 0.833D, 0).tex(sprite.getMaxU(), sprite.getMinV()).normal(0, 0, 1).endVertex(); | ||
|
||
Tessellator.getInstance().draw(); | ||
|
||
GlStateManager.popMatrix(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.