diff options
author | kekzdealer <kekzdealer@gmail.com> | 2020-06-07 21:07:14 +0200 |
---|---|---|
committer | kekzdealer <kekzdealer@gmail.com> | 2020-06-07 21:07:14 +0200 |
commit | 8a002687160784898ec9c67a378ec2055f38327e (patch) | |
tree | 0e5c8f16046e4ec9dc9396d0b0d6d29c1c4b1c9b /src | |
parent | c26c2895e7188c0d4cdeae0af104075efcc404f0 (diff) | |
download | GT5-Unofficial-8a002687160784898ec9c67a378ec2055f38327e.tar.gz GT5-Unofficial-8a002687160784898ec9c67a378ec2055f38327e.tar.bz2 GT5-Unofficial-8a002687160784898ec9c67a378ec2055f38327e.zip |
just pushing to repo
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/client/renderer/HatchRenderer.java | 31 | ||||
-rw-r--r-- | src/main/java/common/blocks/Block_TFFTMultiHatch.java | 101 | ||||
-rw-r--r-- | src/main/java/common/tileentities/TE_TFFTMultiHatch.java | 15 |
3 files changed, 110 insertions, 37 deletions
diff --git a/src/main/java/client/renderer/HatchRenderer.java b/src/main/java/client/renderer/HatchRenderer.java index 0a764b3118..b2670af76b 100644 --- a/src/main/java/client/renderer/HatchRenderer.java +++ b/src/main/java/client/renderer/HatchRenderer.java @@ -1,14 +1,11 @@ package client.renderer; -import common.tileentities.TE_ItemProxyCable; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; -import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; public class HatchRenderer implements ISimpleBlockRenderingHandler { @@ -60,7 +57,35 @@ public class HatchRenderer implements ISimpleBlockRenderingHandler { @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + final Tessellator t = Tessellator.instance; + // Set colour + int mb = block.getMixedBrightnessForBlock(world, x, y, z); + t.setBrightness(mb); + + block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + renderer.setRenderBoundsFromBlock(block); + + if (block.shouldSideBeRendered(world, x, y - 1, z, 6)) { + renderer.renderFaceYNeg(block, x, y, z, block.getIcon(world, x, y, z, 0)); + } + if (block.shouldSideBeRendered(world, x, y + 1, z, 6)) { + t.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, x, y, z, block.getIcon(world, x, y, z, 1)); + } + + if (block.shouldSideBeRendered(world, x, y, z - 1, 6)) { + renderer.renderFaceZNeg(block, x, y, z, block.getIcon(world, x, y, z, 2)); + } + if (block.shouldSideBeRendered(world, x, y, z + 1, 6)) { + renderer.renderFaceZPos(block, x, y, z, block.getIcon(world, x, y, z, 3)); + } + if (block.shouldSideBeRendered(world, x - 1, y, z, 6)) { + renderer.renderFaceXNeg(block, x, y, z, block.getIcon(world, x, y, z, 4)); + } + if (block.shouldSideBeRendered(world, x + 1, y, z, 6)) { + renderer.renderFaceXPos(block, x, y, z, block.getIcon(world, x, y, z, 5)); + } return false; } diff --git a/src/main/java/common/blocks/Block_TFFTMultiHatch.java b/src/main/java/common/blocks/Block_TFFTMultiHatch.java index eda34c8ce3..d2780c8c4b 100644 --- a/src/main/java/common/blocks/Block_TFFTMultiHatch.java +++ b/src/main/java/common/blocks/Block_TFFTMultiHatch.java @@ -1,8 +1,6 @@ package common.blocks; -import client.renderer.ConduitRenderer; import client.renderer.HatchRenderer; -import common.Blocks; import common.itemBlocks.IB_TFFTMultiHatch; import common.tileentities.TE_TFFTMultiHatch; import cpw.mods.fml.common.registry.GameRegistry; @@ -11,7 +9,6 @@ import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; -import kekztech.KekzCore; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -22,9 +19,11 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.common.tiles.TileJarFillable; import java.util.List; @@ -80,12 +79,49 @@ public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { @Override public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { - if(side != 3) { - return casing; + final TileEntity te = blockAccess.getTileEntity(x, y, z); + if(te instanceof TE_TFFTMultiHatch) { + final TE_TFFTMultiHatch hatchTE = (TE_TFFTMultiHatch) te; + if(hatchTE.hasFacingOnSide((byte) side)) { + final int meta = blockAccess.getBlockMetadata(x, y, z); + if(hatchTE.isOutputting()) { + return overlayOn[meta]; + } else { + return overlayOff[meta]; + } + } else { + return casing; + } } else { - return overlayOff[blockAccess.getBlockMetadata(x, y, z)]; + return casing; } } + // ========= Leagris stuff + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return true; + } + + @Override + public int getLightOpacity(IBlockAccess world, int x, int y, int z) { + return 255; + } + + @Override + public int getLightValue() { + return 0; + } + + @Override + public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) { + return false; + } + + //============== Leagris over + @Override + public boolean renderAsNormalBlock() { + return false; + } @Override @SideOnly(Side.CLIENT) @@ -109,8 +145,8 @@ public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - // Code block taken from GregTech's BaseMetaTileEntity.class + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + // Code block taken from GregTech's api.metatileentity.BaseMetaTileEntity.class if (GT_Utility.isStackInList(player.getHeldItem(), GregTech_API.sScrewdriverList)) { if (GT_ModHandler.damageOrDechargeItem(player.getHeldItem(), 1, 200, player)) { final TileEntity te = world.getTileEntity(x, y, z); @@ -123,30 +159,49 @@ public class Block_TFFTMultiHatch extends BaseGTUpdateableBlock { } } return true; + } else if (GT_Utility.isStackInList(player.getHeldItem(), GregTech_API.sWrenchList)) { + if (GT_ModHandler.damageOrDechargeItem(player.getHeldItem(), 1, 200, player)) { + final TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof TE_TFFTMultiHatch) { + ((TE_TFFTMultiHatch) te).setFacingToSide((byte) side); + GT_Utility.sendSoundToPlayers(world, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, x, y, z); + } + } + return true; } return false; } - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase ent, ItemStack stack) { + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase placer, ItemStack stack) { + final int yaw = MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + final int pitch = MathHelper.floor_double((double)(placer.rotationPitch * 4.0F / 360.0F) + 0.5D) & 3; final TileEntity te = world.getTileEntity(x, y, z); if (te instanceof TE_TFFTMultiHatch) { - final TE_TFFTMultiHatch hatchTE = (TE_TFFTMultiHatch) te; - for(int i = 0; i < 6; i++) { - final ForgeDirection d = ForgeDirection.getOrientation(i); - final Block n = world.getBlock(x + d.offsetX, y + d.offsetY, z + d.offsetZ); - KekzCore.LOGGER.info("Block on side " + i + " is " + n.getUnlocalizedName()); - // Always implement your tiered blocks as sub-blocks so you don't have to do this - if(n.equals(Blocks.tfftStorageField1) - || n.equals(Blocks.tfftStorageField2) - || n.equals(Blocks.tfftStorageField3) - || n.equals(Blocks.tfftStorageField4) - || n.equals(Blocks.tfftStorageField5)) { - KekzCore.LOGGER.info("Found Storage Field at side: " + i); - hatchTE.setFacingOnSide((byte) ForgeDirection.OPPOSITES[i], true); + if(pitch == 0 || pitch == 2) { + if (yaw == 0) { + ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 2); + } + + if (yaw == 1) { + ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 5); + } + + if (yaw == 2) { + ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 3); + } + + if (yaw == 3) { + ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 4); + } + } else { + if(pitch == 1) { + ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 1); + } else { + ((TE_TFFTMultiHatch)te).setFacingToSide((byte) 0); } } } + } } diff --git a/src/main/java/common/tileentities/TE_TFFTMultiHatch.java b/src/main/java/common/tileentities/TE_TFFTMultiHatch.java index 8336f841a6..161cad3110 100644 --- a/src/main/java/common/tileentities/TE_TFFTMultiHatch.java +++ b/src/main/java/common/tileentities/TE_TFFTMultiHatch.java @@ -29,9 +29,8 @@ public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler { return (facings & key) == key; } - public void setFacingOnSide(byte side, boolean b) { - final byte key = (byte) Math.pow(0x2, side); - facings = (byte) (b ? facings | key : facings ^ key); + public void setFacingToSide(byte side) { + facings = (byte) Math.pow(0x2, side); } public void setMultiFluidHandler(MultiFluidHandler mfh) { @@ -191,22 +190,16 @@ public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler { @Override public void writeToNBT(NBTTagCompound nbt) { - nbt = (nbt == null) ? new NBTTagCompound() : nbt; - + super.writeToNBT(nbt); nbt.setBoolean("autoOutput", autoOutput); nbt.setByte("facings", facings); - - super.writeToNBT(nbt); } @Override public void readFromNBT(NBTTagCompound nbt) { - nbt = (nbt == null) ? new NBTTagCompound() : nbt; - + super.readFromNBT(nbt); autoOutput = nbt.getBoolean("autoOutput"); facings = nbt.getByte("facings"); - - super.readFromNBT(nbt); } |