diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/block/base')
-rw-r--r-- | src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java | 18 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java | 158 |
2 files changed, 114 insertions, 62 deletions
diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java index 9c58e1a930..c2b77ebdae 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -60,14 +60,6 @@ public class BlockBaseModular extends BasicBlock{ LanguageRegistry.addName(this, blockMaterial+ " Frame Box"); //Utils.LOG_INFO("Registered Block in Language Registry as: "+blockMaterial+ " Frame Box"); } - else if (this.thisBlockType.equals(BlockTypes.ORE.name().toUpperCase())){ - LanguageRegistry.addName(this, blockMaterial+ " Ore"); - //Utils.LOG_INFO("Registered Block in Language Registry as: "+blockMaterial+ " Frame Box"); - } - else { - LanguageRegistry.addName(this, blockMaterial); - //Utils.LOG_INFO("Registered Block in Language Registry as: "+blockMaterial); - } //setOreDict(unlocalizedName, blockType); if (this.thisBlockType.equals(BlockTypes.STANDARD.name().toUpperCase())){ @@ -80,16 +72,6 @@ public class BlockBaseModular extends BasicBlock{ GT_OreDictUnificator.registerOre("frameGt"+getUnlocalizedName().replace("tile.", "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", ""), ItemUtils.getSimpleStack(this)); //Utils.LOG_INFO("Registered Block in Block Registry as: "+blockMaterial+" Frame Box"); } - else if (this.thisBlockType.equals(BlockTypes.ORE.name().toUpperCase())){ - GameRegistry.registerBlock(this, ItemBlockGtBlock.class, Utils.sanitizeString(blockType.getTexture()+unlocalizedName)); - GT_OreDictUnificator.registerOre("block"+getUnlocalizedName().replace("tile.block", "").replace("tile.", "").replace("of", "").replace("Of", "").replace("Block", "").replace("-", "").replace("_", "").replace(" ", ""), ItemUtils.getSimpleStack(this)); - //Utils.LOG_INFO("Registered Block in Block Registry as: "+blockMaterial+" Frame Box"); - } - else { - GameRegistry.registerBlock(this, ItemBlockGtBlock.class, Utils.sanitizeString(blockType.getTexture()+unlocalizedName)); - GT_OreDictUnificator.registerOre("block"+getUnlocalizedName().replace("tile.block", "").replace("tile.", "").replace("of", "").replace("Of", "").replace("Block", "").replace("-", "").replace("_", "").replace(" ", ""), ItemUtils.getSimpleStack(this)); - //Utils.LOG_INFO("Registered Block in Block Registry as: "+blockMaterial); - } } diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java index cb0961eb66..c0847c798d 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -1,5 +1,9 @@ package gtPlusPlus.core.block.base; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; @@ -7,10 +11,17 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ITexturedTileEntity; import gregtech.api.objects.GT_CopiedBlockTexture; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.client.renderer.CustomOreBlockRenderer; +import gtPlusPlus.core.item.base.itemblock.ItemBlockGtBlock; +import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; @@ -23,79 +34,54 @@ public class BlockBaseOre extends BlockBaseModular implements ITexturedTileEntit @SuppressWarnings("unused") private IIcon overlay; - /*@Override - public boolean renderAsNormalBlock() { - return true; - }*/ - protected Material blockMaterial; protected int blockColour; protected BlockTypes thisBlock; - protected String thisBlockMaterial; - protected final String thisBlockType; public BlockBaseOre(final Material material, final BlockTypes blockType, final int colour) { this(material.getUnlocalizedName(), material.getLocalizedName(), net.minecraft.block.material.Material.iron, blockType, colour, 3); blockMaterial = material; } - public BlockBaseOre(final String unlocalizedName, final String blockMaterial, final BlockTypes blockType, final int colour) { this(unlocalizedName, blockMaterial, net.minecraft.block.material.Material.iron, blockType, colour, 2); } public BlockBaseOre(final String unlocalizedName, final String blockMaterial, final net.minecraft.block.material.Material vanillaMaterial, final BlockTypes blockType, final int colour, final int miningLevel) { super(unlocalizedName, blockMaterial, vanillaMaterial, blockType, colour, miningLevel); + try { + if (blockMaterial == null){ + Logger.DEBUG_MATERIALS("Failed to generate "+unlocalizedName+" due to invalid material variable."); + } + this.blockColour = colour; this.thisBlock = blockType; - this.thisBlockMaterial = blockMaterial; - this.thisBlockType = blockType.name().toUpperCase(); + + if (this == null || this.blockMaterial == null){ + Logger.DEBUG_MATERIALS("Issue during Ore construction, Material or Block is null."); + } + + GameRegistry.registerBlock(this, ItemBlockGtBlock.class, Utils.sanitizeString("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()))); + GT_OreDictUnificator.registerOre("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()), ItemUtils.getSimpleStack(this)); + LanguageRegistry.addName(this, blockMaterial+ " Ore"); + } + catch (Throwable t){ + t.printStackTrace(); + } } /** * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha */ - /*@Override + @Override @SideOnly(Side.CLIENT) - public int getRenderBlockPass() - { + public int getRenderBlockPass(){ return 0; - } */ - - /*@Override - public boolean isOpaqueCube() - { - return true; - }*/ - - /*@Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iIcon) - { - this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + this.thisBlock.getTexture()); - //this.base = iIcon.registerIcon(CORE.MODID + ":" + "blockStone"); - //this.overlay = iIcon.registerIcon(CORE.MODID + ":" + "blockOre_Overlay"); - }*/ - - /*@Override - public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ - if (this.blockColour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return this.blockColour; } @Override - public int getRenderColor(final int aMeta) { - if (this.blockColour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return this.blockColour; - }*/ - - @Override public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { return false; } @@ -131,6 +117,90 @@ public class BlockBaseOre extends BlockBaseModular implements ITexturedTileEntit return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.STONES[0], new short[]{240, 240, 240, 0})}; } + public static class oldOreBlock extends BlockBaseModular{ + @SuppressWarnings("unused") + private IIcon base; + @SuppressWarnings("unused") + private IIcon overlay; + + protected Material blockMaterial; + + protected int blockColour; + protected BlockTypes thisBlock; + protected String thisBlockMaterial; + protected final String thisBlockType; + + public oldOreBlock(final Material material, final BlockTypes blockType, final int colour) { + this(material.getUnlocalizedName(), material.getLocalizedName(), net.minecraft.block.material.Material.iron, blockType, colour, 3); + blockMaterial = material; + } + + public oldOreBlock(final String unlocalizedName, final String blockMaterial, final BlockTypes blockType, final int colour) { + this(unlocalizedName, blockMaterial, net.minecraft.block.material.Material.iron, blockType, colour, 2); + } + + public oldOreBlock(final String unlocalizedName, final String blockMaterial, final net.minecraft.block.material.Material vanillaMaterial, final BlockTypes blockType, final int colour, final int miningLevel) { + super(unlocalizedName, blockMaterial, vanillaMaterial, blockType, colour, miningLevel); + this.blockColour = colour; + this.thisBlock = blockType; + this.thisBlockMaterial = blockMaterial; + this.thisBlockType = blockType.name().toUpperCase(); + this.setBlockTextureName(CORE.MODID+":"+blockType.getTexture()); + } + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha + */ + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass(){ + return 0; + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public int getRenderType() { + return 0; + } + + @Override + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + public IIcon getIcon(int aSide, int aMeta) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) + { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + this.thisBlock.getTexture()); + } + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ + if (this.blockColour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return this.blockColour; + } + + @Override + public int getRenderColor(final int aMeta) { + if (this.blockColour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return this.blockColour; + } + + } } |