diff options
| author | NotAPenguin <michiel.vandeginste@gmail.com> | 2024-09-02 23:17:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-02 23:17:17 +0200 |
| commit | 1b820de08a05070909a267e17f033fcf58ac8710 (patch) | |
| tree | 02831a025986a06b20f87e5bcc69d1e0c639a342 /src/main/java/bartworks/client/renderer | |
| parent | afd3fd92b6a6ab9ab0d0dc3214e6bc8ff7a86c9b (diff) | |
| download | GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.gz GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.bz2 GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.zip | |
The Great Renaming (#3014)
* move kekztech to a single root dir
* move detrav to a single root dir
* move gtnh-lanthanides to a single root dir
* move tectech and delete some gross reflection in gt++
* remove more reflection inside gt5u
* delete more reflection in gt++
* fix imports
* move bartworks and bwcrossmod
* fix proxies
* move galactigreg and ggfab
* move gtneioreplugin
* try to fix gt++ bee loader
* apply the rename rules to BW
* apply rename rules to bwcrossmod
* apply rename rules to detrav scanner mod
* apply rename rules to galacticgreg
* apply rename rules to ggfab
* apply rename rules to goodgenerator
* apply rename rules to gtnh-lanthanides
* apply rename rules to gt++
* apply rename rules to kekztech
* apply rename rules to kubatech
* apply rename rules to tectech
* apply rename rules to gt
apply the rename rules to gt
* fix tt import
* fix mui hopefully
* fix coremod except intergalactic
* rename assline recipe class
* fix a class name i stumbled on
* rename StructureUtility to GTStructureUtility to prevent conflict with structurelib
* temporary rename of GTTooltipDataCache to old name
* fix gt client/server proxy names
Diffstat (limited to 'src/main/java/bartworks/client/renderer')
6 files changed, 908 insertions, 0 deletions
diff --git a/src/main/java/bartworks/client/renderer/BWBlockOreRenderer.java b/src/main/java/bartworks/client/renderer/BWBlockOreRenderer.java new file mode 100644 index 0000000000..781ead228e --- /dev/null +++ b/src/main/java/bartworks/client/renderer/BWBlockOreRenderer.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package bartworks.client.renderer; + +import static gregtech.common.render.GTRendererBlock.renderNegativeXFacing; +import static gregtech.common.render.GTRendererBlock.renderNegativeYFacing; +import static gregtech.common.render.GTRendererBlock.renderNegativeZFacing; +import static gregtech.common.render.GTRendererBlock.renderPositiveXFacing; +import static gregtech.common.render.GTRendererBlock.renderPositiveYFacing; +import static gregtech.common.render.GTRendererBlock.renderPositiveZFacing; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +import org.lwjgl.opengl.GL11; + +import com.gtnewhorizons.angelica.api.ThreadSafeISBRH; + +import bartworks.system.material.BWMetaGeneratedBlocks; +import bartworks.system.material.TileEntityMetaGeneratedBlock; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import gregtech.GTMod; + +@ThreadSafeISBRH(perThread = true) +public class BWBlockOreRenderer implements ISimpleBlockRenderingHandler { + + public static BWBlockOreRenderer INSTANCE; + public static int renderID; + public static final float blockMin = 0.0F; + public static final float blockMax = 1.0F; + + public static void register() { + renderID = RenderingRegistry.getNextAvailableRenderId(); + INSTANCE = new BWBlockOreRenderer(); + RenderingRegistry.registerBlockHandler(INSTANCE); + } + + @Override + public void renderInventoryBlock(Block aBlock, int aMeta, int modelId, RenderBlocks aRenderer) { + TileEntityMetaGeneratedBlock tTileEntity = ((BWMetaGeneratedBlocks) aBlock).getProperTileEntityForRendering(); + tTileEntity.mMetaData = (short) aMeta; + aRenderer.enableAO = false; + aRenderer.useInventoryTint = true; + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + renderNegativeYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.DOWN), + true); + renderPositiveYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.UP), + true); + renderNegativeZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.NORTH), + true); + renderPositiveZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.SOUTH), + true); + renderNegativeXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.WEST), + true); + renderPositiveXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.EAST), + true); + aRenderer.setRenderBoundsFromBlock(aBlock); + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + aRenderer.useInventoryTint = false; + } + + // spotless:off + @Override + public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int modelId, RenderBlocks aRenderer) { + BWMetaGeneratedBlocks tBlock = (BWMetaGeneratedBlocks) aBlock; + if(tBlock == null) return false; + + TileEntityMetaGeneratedBlock fakeTileEntity = tBlock.getProperTileEntityForRendering(); // meh + if(fakeTileEntity == null) return false; + + TileEntityMetaGeneratedBlock actualTileEntity = (TileEntityMetaGeneratedBlock) aWorld.getTileEntity(aX, aY, aZ); + if(actualTileEntity == null) return false; + + fakeTileEntity.mMetaData = actualTileEntity.mMetaData; + aRenderer.useInventoryTint = false; + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); + aRenderer.enableAO = Minecraft.isAmbientOcclusionEnabled() && GTMod.gregtechproxy.mRenderTileAmbientOcclusion; + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.DOWN), true); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.UP), true); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.NORTH), true); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.SOUTH), true); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.WEST), true); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.EAST), true); + return true; + } + // spotless:on + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return renderID; + } +} diff --git a/src/main/java/bartworks/client/renderer/BWItemRenderer.java b/src/main/java/bartworks/client/renderer/BWItemRenderer.java new file mode 100644 index 0000000000..590ffd163c --- /dev/null +++ b/src/main/java/bartworks/client/renderer/BWItemRenderer.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package bartworks.client.renderer; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; + +import org.lwjgl.opengl.GL11; + +import bartworks.system.material.CircuitGeneration.BWMetaItems; +import bartworks.system.material.CircuitGeneration.CircuitImprintLoader; +import bartworks.util.BWUtil; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GTUtility; +import gregtech.common.render.GTRenderUtil; + +@SideOnly(Side.CLIENT) +public class BWItemRenderer implements IItemRenderer { + + public BWItemRenderer() { + for (BWMetaItems.BW_GT_MetaGen_Item_Hook tItem : BWMetaItems.BW_GT_MetaGen_Item_Hook.sInstances) { + MinecraftForgeClient.registerItemRenderer(tItem, this); + } + } + + @Override + public boolean handleRenderType(ItemStack aStack, IItemRenderer.ItemRenderType aType) { + if (!GTUtility.isStackInvalid(aStack) && aStack.getItemDamage() >= 0) { + return aType == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON + || aType == IItemRenderer.ItemRenderType.INVENTORY + || aType == IItemRenderer.ItemRenderType.EQUIPPED + || aType == IItemRenderer.ItemRenderType.ENTITY; + } + return false; + } + + @Override + public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType aType, ItemStack aStack, + IItemRenderer.ItemRendererHelper aHelper) { + if (GTUtility.isStackInvalid(aStack)) { + return false; + } + return aType == IItemRenderer.ItemRenderType.ENTITY; + } + + @Override + public void renderItem(IItemRenderer.ItemRenderType type, ItemStack aStack, Object... data) { + if (!GTUtility.isStackInvalid(aStack)) { + short aMetaData = (short) aStack.getItemDamage(); + if (aMetaData >= 0) { + BWMetaItems.BW_GT_MetaGen_Item_Hook aItem = (BWMetaItems.BW_GT_MetaGen_Item_Hook) aStack.getItem(); + GL11.glEnable(3042); + if (type == IItemRenderer.ItemRenderType.ENTITY) { + if (RenderItem.renderInFrame) { + GL11.glScalef(0.85F, 0.85F, 0.85F); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + } + GL11.glTranslated(-0.5D, -0.42D, 0.0D); + } + + GL11.glColor3f(1.0F, 1.0F, 1.0F); + IIcon tIcon = (IIcon) BWUtil.get2DCoordFrom1DArray(aMetaData, 0, 2, aItem.mIconList); + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(770, 771); + if (IItemRenderer.ItemRenderType.INVENTORY.equals(type)) { + if (aMetaData < CircuitImprintLoader.reverseIDs) + GTRenderUtil.renderItemIcon(tIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + else { + for (int i = 0; i < 4; i++) { + GTRenderUtil.renderItemIcon( + tIcon, + 0.0D + i * 2D, + 0.0D + i * 2D, + 10.0D + i * 2D, + 10.0D + i * 2D, + 0.001D, + 0.0F, + 0.0F, + -1.0F); + } + } + } else if (aMetaData < CircuitImprintLoader.reverseIDs) ItemRenderer.renderItemIn2D( + Tessellator.instance, + tIcon.getMaxU(), + tIcon.getMinV(), + tIcon.getMinU(), + tIcon.getMaxV(), + tIcon.getIconWidth(), + tIcon.getIconHeight(), + 0.0625F); + + IIcon tOverlay = (IIcon) BWUtil.get2DCoordFrom1DArray(aMetaData, 1, 2, aItem.mIconList); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + if (tOverlay != null) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(770, 771); + if (IItemRenderer.ItemRenderType.INVENTORY.equals(type)) { + GTRenderUtil.renderItemIcon(tOverlay, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + } else { + ItemRenderer.renderItemIn2D( + Tessellator.instance, + tOverlay.getMaxU(), + tOverlay.getMinV(), + tOverlay.getMinU(), + tOverlay.getMaxV(), + tOverlay.getIconWidth(), + tOverlay.getIconHeight(), + 0.0625F); + } + } + } + + GL11.glDisable(3042); + } + } +} diff --git a/src/main/java/bartworks/client/renderer/BWVanillaTexture.java b/src/main/java/bartworks/client/renderer/BWVanillaTexture.java new file mode 100644 index 0000000000..5b5e119f5b --- /dev/null +++ b/src/main/java/bartworks/client/renderer/BWVanillaTexture.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package bartworks.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.interfaces.IIconContainer; + +@SideOnly(Side.CLIENT) +public class BWVanillaTexture implements IIconContainer { + + IIcon packed; + + public BWVanillaTexture(Block block, ForgeDirection side) { + this.packed = block.getBlockTextureFromSide(side.flag); + } + + public BWVanillaTexture(Block block, int side) { + this.packed = block.getBlockTextureFromSide(side); + } + + public BWVanillaTexture(IIcon packed) { + this.packed = packed; + } + + @Override + public IIcon getIcon() { + return this.packed; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public ResourceLocation getTextureFile() { + return new ResourceLocation(this.packed.getIconName()); + } +} diff --git a/src/main/java/bartworks/client/renderer/EICPistonVisualizer.java b/src/main/java/bartworks/client/renderer/EICPistonVisualizer.java new file mode 100644 index 0000000000..f56a12d718 --- /dev/null +++ b/src/main/java/bartworks/client/renderer/EICPistonVisualizer.java @@ -0,0 +1,112 @@ +package bartworks.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import org.apache.commons.lang3.tuple.Pair; +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; + +@SideOnly(Side.CLIENT) +public class EICPistonVisualizer extends EntityFX { + + public EICPistonVisualizer(World world, int x, int y, int z, int age) { + super(world, x, y, z); + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.particleMaxAge = age; + } + + @Override + public void onUpdate() { + if (this.particleAge++ >= this.particleMaxAge) this.setDead(); + } + + @Override + public void renderParticle(Tessellator p_70539_1_, float p_70539_2_, float p_70539_3_, float p_70539_4_, + float p_70539_5_, float p_70539_6_, float p_70539_7_) { + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDepthMask(false); + + RenderBlocks.getInstance().blockAccess = this.worldObj; + RenderBlocks.getInstance() + .setRenderFromInside(false); + + // Look at nearby block for correct tiered block to use + Pair<Block, Integer> tieredBlock; + if (this.worldObj != null) { + int nX = (int) this.posX; + int nY = (int) this.posY + 1; + int nZ = (int) this.posZ; + Block neighborBlock = this.worldObj.getBlock(nX, nY, nZ); + int neighborMeta = this.worldObj.getBlockMetadata(nX, nY, nZ); + tieredBlock = Pair.of(neighborBlock, neighborMeta); + } else { + tieredBlock = Pair.of(GregTechAPI.sBlockMetal5, 2); + } + + IIcon icon = tieredBlock.getKey() + .getIcon(0, tieredBlock.getValue()); + + double x = this.posX + 1; + double z = this.posZ; + + double f11 = x - interpPosX; + double f12 = this.posY - interpPosY; + double f13 = z - interpPosZ; + tessellator.setTranslation(f11 - x, f12 - this.posY, f13 - z); + RenderBlocks.getInstance() + .renderBlockUsingTexture(tieredBlock.getKey(), (int) x, (int) this.posY, (int) z, icon); + + x = this.posX - 1; + z = this.posZ; + + f11 = x - interpPosX; + f13 = z - interpPosZ; + tessellator.setTranslation(f11 - x, f12 - this.posY, f13 - z); + RenderBlocks.getInstance() + .renderBlockUsingTexture(tieredBlock.getKey(), (int) x, (int) this.posY, (int) z, icon); + + x = this.posX; + z = this.posZ + 1; + + f11 = x - interpPosX; + f13 = z - interpPosZ; + tessellator.setTranslation(f11 - x, f12 - this.posY, f13 - z); + RenderBlocks.getInstance() + .renderBlockUsingTexture(tieredBlock.getKey(), (int) x, (int) this.posY, (int) z, icon); + + x = this.posX; + z = this.posZ - 1; + + f11 = x - interpPosX; + f13 = z - interpPosZ; + tessellator.setTranslation(f11 - x, f12 - this.posY, f13 - z); + RenderBlocks.getInstance() + .renderBlockUsingTexture(tieredBlock.getKey(), (int) x, (int) this.posY, (int) z, icon); + + tessellator.setTranslation(0d, 0d, 0d); + + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDepthMask(true); + } + + @Override + public int getFXLayer() { + return 1; + } + + @Override + public boolean shouldRenderInPass(int pass) { + return pass == 2; + } +} diff --git a/src/main/java/bartworks/client/renderer/RendererGlassBlock.java b/src/main/java/bartworks/client/renderer/RendererGlassBlock.java new file mode 100644 index 0000000000..1af553ff59 --- /dev/null +++ b/src/main/java/bartworks/client/renderer/RendererGlassBlock.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package bartworks.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import com.gtnewhorizons.angelica.api.ThreadSafeISBRH; + +import bartworks.common.blocks.BWBlocksGlass; +import bartworks.common.blocks.BWBlocksGlass2; +import bartworks.common.loaders.ItemRegistry; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +@ThreadSafeISBRH(perThread = false) +public class RendererGlassBlock implements ISimpleBlockRenderingHandler { + + public static int renderID; + public static RendererGlassBlock INSTANCE; + + public static void register() { + renderID = RenderingRegistry.getNextAvailableRenderId(); + INSTANCE = new RendererGlassBlock(); + RenderingRegistry.registerBlockHandler(INSTANCE); + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + Tessellator tessellator = Tessellator.instance; + block.setBlockBoundsForItemRender(); + renderer.setRenderBoundsFromBlock(block); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 0, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 1, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 2, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 3, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 4, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 5, metadata)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + // spotless:off + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + boolean flag = false; + if (block instanceof BWBlocksGlass) { + flag |= renderer.renderStandardBlock(ItemRegistry.bw_fake_glasses, x, y, z); + flag |= renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, + ((BWBlocksGlass) block).getColor(world.getBlockMetadata(x, y, z))[0] / 255f, + ((BWBlocksGlass) block).getColor(world.getBlockMetadata(x, y, z))[1] / 255f, + ((BWBlocksGlass) block).getColor(world.getBlockMetadata(x, y, z))[2] / 255f); + } + if (block instanceof BWBlocksGlass2) { + flag |= renderer.renderStandardBlock(ItemRegistry.bw_fake_glasses2, x, y, z); + flag |= renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, + ((BWBlocksGlass2) block).getColor(world.getBlockMetadata(x, y, z))[0] / 255f, + ((BWBlocksGlass2) block).getColor(world.getBlockMetadata(x, y, z))[1] / 255f, + ((BWBlocksGlass2) block).getColor(world.getBlockMetadata(x, y, z))[2] / 255f); + } + return flag; + } + // spotless:on + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return RendererGlassBlock.renderID; + } +} diff --git a/src/main/java/bartworks/client/renderer/RendererSwitchingColorFluid.java b/src/main/java/bartworks/client/renderer/RendererSwitchingColorFluid.java new file mode 100644 index 0000000000..ba565cc2aa --- /dev/null +++ b/src/main/java/bartworks/client/renderer/RendererSwitchingColorFluid.java @@ -0,0 +1,333 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package bartworks.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraftforge.fluids.IFluidBlock; + +import com.gtnewhorizons.angelica.api.ThreadSafeISBRH; + +import bartworks.common.blocks.BlockBioFluid; +import bartworks.common.loaders.FluidLoader; +import bartworks.common.tileentities.multis.MTEBioVat; +import bartworks.util.Coords; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +@ThreadSafeISBRH(perThread = false) +public class RendererSwitchingColorFluid implements ISimpleBlockRenderingHandler { + + private static final float LIGHT_Y_NEG = 0.5f; + private static final float LIGHT_Y_POS = 1f; + private static final float LIGHT_XZ_NEG = 0.8f; + private static final float LIGHT_XZ_POS = 0.6f; + private static final float THREE_QUARTERS_FILLED = 0.875f; + private static final double RENDER_OFFSET = 0.0010000000474974513; + + public static RendererSwitchingColorFluid instance; + + public static void register() { + instance = new RendererSwitchingColorFluid(); + } + + private float getFluidHeightAverage(float[] flow) { + float total = 0.0f; + int count = 0; + float end = 0.0f; + for (float aFlow : flow) { + if (aFlow >= RendererSwitchingColorFluid.THREE_QUARTERS_FILLED + && end != RendererSwitchingColorFluid.LIGHT_Y_POS) { + end = aFlow; + } + if (aFlow >= 0.0f) { + total += aFlow; + ++count; + } + } + if (end == 0.0f && count != 0) { + end = total / count; + } + return end; + } + + private float getFluidHeightForRender(IBlockAccess world, int x, int y, int z, BlockFluidBase block) { + + if (world.getBlock(x, y, z) == block) { + Block vOrigin = world.getBlock(x, y + 1, z); + if (vOrigin.getMaterial() + .isLiquid() || vOrigin instanceof IFluidBlock) { + return RendererSwitchingColorFluid.LIGHT_Y_POS; + } + if (world.getBlockMetadata(x, y, z) == block.getMaxRenderHeightMeta()) { + return RendererSwitchingColorFluid.THREE_QUARTERS_FILLED; + } + } + return !world.getBlock(x, y, z) + .getMaterial() + .isSolid() && world.getBlock(x, y + 1, z) == block ? RendererSwitchingColorFluid.LIGHT_Y_POS + : block.getQuantaPercentage(world, x, y, z) * RendererSwitchingColorFluid.THREE_QUARTERS_FILLED; + } + + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {} + + @SideOnly(Side.CLIENT) + public boolean renderWorldBlock(IBlockAccess iBlockAccess, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + if (!(block instanceof BlockBioFluid)) return false; + Tessellator tessellator = Tessellator.instance; + Coords blockat = new Coords( + x, + y, + z, + iBlockAccess.getTileEntity(x, y, z) + .getWorldObj().provider.dimensionId); + Integer rgb = MTEBioVat.staticColorMap.get(blockat); + + int r, g, b; + + if (rgb != null) { + r = rgb >> 16 & 0xFF; + g = rgb >> 8 & 0xFF; + b = rgb & 0xFF; + } else { + r = 0; + g = 0; + b = 255; + } + float red = r / 255f, green = g / 255f, blue = b / 255f; + + BlockFluidBase blockFluidBase = (BlockFluidBase) block; + boolean renderTop = iBlockAccess.getBlock(x, y + 1, z) != blockFluidBase; + boolean renderBottom = block.shouldSideBeRendered(iBlockAccess, x, y - 1, z, 0) + && iBlockAccess.getBlock(x, y - 1, z) != blockFluidBase; + boolean[] renderSides = { block.shouldSideBeRendered(iBlockAccess, x, y, z - 1, 2), + block.shouldSideBeRendered(iBlockAccess, x, y, z + 1, 3), + block.shouldSideBeRendered(iBlockAccess, x - 1, y, z, 4), + block.shouldSideBeRendered(iBlockAccess, x + 1, y, z, 5) }; + if (!renderTop && !renderBottom && !renderSides[0] && !renderSides[1] && !renderSides[2] && !renderSides[3]) { + return false; + } + boolean rendered = false; + float fluidHeightForRender = this.getFluidHeightForRender(iBlockAccess, x, y, z, blockFluidBase); + double heightNW, heightSW, heightSE, heightNE; + + if (fluidHeightForRender != RendererSwitchingColorFluid.LIGHT_Y_POS) { + float fluidHeightForRender1 = this.getFluidHeightForRender(iBlockAccess, x - 1, y, z - 1, blockFluidBase); + float fluidHeightForRender2 = this.getFluidHeightForRender(iBlockAccess, x - 1, y, z, blockFluidBase); + float fluidHeightForRender3 = this.getFluidHeightForRender(iBlockAccess, x - 1, y, z + 1, blockFluidBase); + float fluidHeightForRender4 = this.getFluidHeightForRender(iBlockAccess, x, y, z - 1, blockFluidBase); + float fluidHeightForRender5 = this.getFluidHeightForRender(iBlockAccess, x, y, z + 1, blockFluidBase); + float fluidHeightForRender6 = this.getFluidHeightForRender(iBlockAccess, x + 1, y, z - 1, blockFluidBase); + float fluidHeightForRender7 = this.getFluidHeightForRender(iBlockAccess, x + 1, y, z, blockFluidBase); + float fluidHeightForRender8 = this.getFluidHeightForRender(iBlockAccess, x + 1, y, z + 1, blockFluidBase); + heightNW = this.getFluidHeightAverage( + new float[] { fluidHeightForRender1, fluidHeightForRender2, fluidHeightForRender4, + fluidHeightForRender }); + heightSW = this.getFluidHeightAverage( + new float[] { fluidHeightForRender2, fluidHeightForRender3, fluidHeightForRender5, + fluidHeightForRender }); + heightSE = this.getFluidHeightAverage( + new float[] { fluidHeightForRender5, fluidHeightForRender7, fluidHeightForRender8, + fluidHeightForRender }); + heightNE = this.getFluidHeightAverage( + new float[] { fluidHeightForRender4, fluidHeightForRender6, fluidHeightForRender7, + fluidHeightForRender }); + } else { + heightNW = fluidHeightForRender; + heightSW = fluidHeightForRender; + heightSE = fluidHeightForRender; + heightNE = fluidHeightForRender; + } + + if (renderer.renderAllFaces || renderTop) { + rendered = true; + IIcon iconStill = this.getNullCheckedIiconOrFallbackTexture(); + float flowDir = (float) BlockFluidBase.getFlowDirection(iBlockAccess, x, y, z); + + heightNW -= RendererSwitchingColorFluid.RENDER_OFFSET; + heightSW -= RendererSwitchingColorFluid.RENDER_OFFSET; + heightSE -= RendererSwitchingColorFluid.RENDER_OFFSET; + heightNE -= RendererSwitchingColorFluid.RENDER_OFFSET; + + double dInterpolatedU, dInterpolatedV, dInterpolatedU2, dInterpolatedV2, dInterpolatedU3, dInterpolatedV3, + dInterpolatedU4, dInterpolatedV4; + + if (flowDir < -999.0f) { + dInterpolatedU = iconStill.getInterpolatedU(0.0); + |
