From 7f1791abbf072633f17ce95ae9831ab41f2dc7ed Mon Sep 17 00:00:00 2001 From: Dragon2488 Date: Tue, 13 Sep 2016 17:15:07 +0700 Subject: [PATCH] Lightning fix, black blocks on break attempt fix --- .../gregtech/api/items/GT_Generic_Block.java | 60 +++++++++---------- .../api/objects/GT_RenderedTexture.java | 4 +- .../gregtech/common/blocks/GT_Block_Ores.java | 14 +++++ .../common/blocks/GT_Block_Storage.java | 10 ---- 4 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/main/java/gregtech/api/items/GT_Generic_Block.java b/src/main/java/gregtech/api/items/GT_Generic_Block.java index 43068763..17c36843 100644 --- a/src/main/java/gregtech/api/items/GT_Generic_Block.java +++ b/src/main/java/gregtech/api/items/GT_Generic_Block.java @@ -1,37 +1,26 @@ package gregtech.api.items; -import gregtech.common.blocks.GT_Block_Ores; +import gregtech.api.util.GT_LanguageManager; import gregtech.common.blocks.UnlistedBlockPosProperty; -import gregtech.common.render.IIconRegister; -import gregtech.common.render.newblocks.IBlockIconProvider; -import net.minecraft.block.BlockGlass; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.ChunkCache; -import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.property.ExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IUnlistedProperty; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.common.registry.GameRegistry; -import gregtech.api.util.GT_LanguageManager; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.item.ItemBlock; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import static gregtech.api.enums.GT_Values.W; @@ -47,6 +36,13 @@ public abstract class GT_Generic_Block extends Block { setUnlocalizedName(mUnlocalizedName = aName); GameRegistry.registerBlock(this, aItemClass, getUnlocalizedName()); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + W + ".name", "Any Sub Block of this one"); + setLightLevel(2); + translucent = true; + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; } @Override @@ -70,29 +66,27 @@ public abstract class GT_Generic_Block extends Block { } @Override - @SuppressWarnings("deprecation") public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { return getExtendedState(state, worldIn, pos); } - @Override - public boolean getUseNeighborBrightness(IBlockState state) { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public int getPackedLightmapCoords(IBlockState state, IBlockAccess source, BlockPos pos) { - World world = FMLClientHandler.instance().getWorldClient(); - int i = world.getLightFromNeighborsFor(EnumSkyBlock.SKY, pos); - int j = world.getLightFromNeighborsFor(EnumSkyBlock.BLOCK, pos); - if(i < 2) i = 8; - return i << 20 | j << 4; - } - @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(this, 1, state.getValue(METADATA)); } + @Override + public BlockRenderLayer getBlockLayer() { + return BlockRenderLayer.CUTOUT; + } + + @Override + public EnumBlockRenderType getRenderType(IBlockState state) { + StackTraceElement[] trace = Thread.currentThread().getStackTrace(); + if(trace[3].getMethodName().equals("renderBlockDamage")) { + return EnumBlockRenderType.INVISIBLE; + //TODO FIX ME PLEASE + } + return EnumBlockRenderType.MODEL; + } } \ No newline at end of file diff --git a/src/main/java/gregtech/api/objects/GT_RenderedTexture.java b/src/main/java/gregtech/api/objects/GT_RenderedTexture.java index 70ff2df9..ac7bfc9a 100644 --- a/src/main/java/gregtech/api/objects/GT_RenderedTexture.java +++ b/src/main/java/gregtech/api/objects/GT_RenderedTexture.java @@ -65,10 +65,10 @@ public class GT_RenderedTexture implements ITexture { TextureAtlasSprite sprite = mIconContainer.getIcon(); TextureAtlasSprite overlay = mIconContainer.getOverlayIcon(); if(sprite != null) { - quads.add(RenderUtil.renderSide(DefaultVertexFormats.BLOCK, sprite, side, tintOff, 0.0F, mRGBa, blockPos == null)); + quads.add(RenderUtil.renderSide(DefaultVertexFormats.BLOCK, sprite, side, -1, 0.001F, mRGBa, blockPos == null)); } if(overlay != null) { - quads.add(RenderUtil.renderSide(DefaultVertexFormats.BLOCK, overlay, side, tintOff + 1000, 0.001F, mRGBa, blockPos == null)); + quads.add(RenderUtil.renderSide(DefaultVertexFormats.BLOCK, overlay, side, -1, 0.001F, mRGBa, blockPos == null)); } return quads; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java index 3c64f061..67c35b3e 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java @@ -10,13 +10,27 @@ import gregtech.api.objects.GT_RenderedTexture; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.world.World; public class GT_Block_Ores extends GT_Block_Ores_Abstract { public GT_Block_Ores() { super("gt.blockores", false, Material.ROCK); } + @Override + public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { + GT_TileEntity_Ores tileEntity_ores = (GT_TileEntity_Ores) world.getTileEntity(pos); + if(tileEntity_ores != null && tileEntity_ores.mMetaData != 0) { + return new ItemStack(this, 1, tileEntity_ores.mMetaData); + } + return null; + } + @Override public String getUnlocalizedName() { return "gt.blockores"; diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Storage.java b/src/main/java/gregtech/common/blocks/GT_Block_Storage.java index 3b4c6984..a4d85e9d 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Storage.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Storage.java @@ -60,16 +60,6 @@ public class GT_Block_Storage extends GT_Generic_Block { return GT_LanguageManager.getTranslation(this.mUnlocalizedName + ".name"); } - @Override - public boolean isNormalCube(IBlockState state) { - return true; - } - - @Override - public boolean isVisuallyOpaque() { - return true; - } - @Override public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { return Lists.newArrayList(new ItemStack(this, 1, state.getValue(METADATA)));