diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
commit | 221c2f0fe81430e7dd4087e5f5845bd7c62ec56d (patch) | |
tree | d6e0faaef01b9d517828557e1be82500d476f95e /src/Java/gtPlusPlus/core/block/base | |
parent | 5872c0947ce7bc788b03fa2fb690b8815d3d0a04 (diff) | |
download | GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.gz GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.bz2 GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.zip |
% Refactored the entire project to stop using MiscUtils everywhere possible, now it's gtPlusPlus.
Diffstat (limited to 'src/Java/gtPlusPlus/core/block/base')
5 files changed, 301 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java b/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java new file mode 100644 index 0000000000..b7ac24a71b --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java @@ -0,0 +1,31 @@ +package gtPlusPlus.core.block.base; + +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public class AdvancedBlock extends Block { + + protected AdvancedBlock(String unlocalizedName, Material material, CreativeTabs x, float blockHardness, float blockResistance, float blockLightLevel, + String blockHarvestTool, int blockHarvestLevel, SoundType BlockSound) { + super(material); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(x); + this.setHardness(blockHardness); //block Hardness + this.setResistance(blockResistance); + this.setLightLevel(blockLightLevel); + this.setHarvestLevel(blockHarvestTool, blockHarvestLevel); + this.setStepSound(BlockSound); + } + + @Override + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + return false; + } + +} diff --git a/src/Java/gtPlusPlus/core/block/base/BasicBlock.java b/src/Java/gtPlusPlus/core/block/base/BasicBlock.java new file mode 100644 index 0000000000..cd879167ba --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/BasicBlock.java @@ -0,0 +1,52 @@ +package gtPlusPlus.core.block.base; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; + +public class BasicBlock extends Block { + + public BasicBlock(String unlocalizedName, Material material) { + super(material); + this.setBlockName(Utils.sanitizeString(unlocalizedName)); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(2.0F); + this.setResistance(6.0F); + this.setLightLevel(0.0F); + this.setHarvestLevel("pickaxe", 2); + this.setStepSound(soundTypeMetal); + } + + + public static enum BlockTypes { + STANDARD("blockBlock", "pickaxe", soundTypeStone), + FRAME("blockFrameGt", "wrench", soundTypeMetal); + + private String TEXTURE_NAME; + private String HARVEST_TOOL; + private SoundType soundOfBlock; + private BlockTypes (String textureName, String harvestTool, SoundType blockSound) + { + this.TEXTURE_NAME = textureName; + this.HARVEST_TOOL = harvestTool; + this.soundOfBlock = blockSound; + } + + public String getTexture() { + return TEXTURE_NAME; + } + + public String getHarvestTool(){ + return HARVEST_TOOL; + } + + public SoundType getBlockSoundType(){ + return soundOfBlock; + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java new file mode 100644 index 0000000000..9654caac00 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -0,0 +1,154 @@ +package gtPlusPlus.core.block.base; + +import gtPlusPlus.core.item.base.itemblock.ItemBlockGtBlock; +import gtPlusPlus.core.item.base.itemblock.ItemBlockGtFrameBox; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.world.IBlockAccess; +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; + +public class BlockBaseModular extends BasicBlock{ + + protected int blockColour; + protected BlockTypes thisBlock; + protected String thisBlockMaterial; + protected final String thisBlockType; + + public BlockBaseModular(String unlocalizedName, String blockMaterial, BlockTypes blockType, int colour) { + super(blockType.getTexture()+unlocalizedName, Material.iron); + this.setHarvestLevel(blockType.getHarvestTool(), 2); + this.setBlockTextureName(CORE.MODID+":"+blockType.getTexture()); + this.blockColour = colour; + this.thisBlock = blockType; + this.thisBlockMaterial = blockMaterial; + this.thisBlockType = blockType.name().toUpperCase(); + this.setBlockName(GetProperName()); + + if (!CORE.DEBUG){ + //Utils.LOG_INFO("=============Block Info Dump============="); + //Utils.LOG_INFO("thisBlock.name().toLowerCase() - "+thisBlock.name().toLowerCase()); + //Utils.LOG_INFO("This Blocks Type - "+thisBlockType); + //Utils.LOG_INFO("BlockTypes.STANDARD.name().toLowerCase() - "+BlockTypes.STANDARD.name().toLowerCase()); + //Utils.LOG_INFO("BlockTypes.FRAME.name().toLowerCase() - "+BlockTypes.FRAME.name().toLowerCase()); + //Utils.LOG_INFO("blockMaterial - "+blockMaterial); + //Utils.LOG_INFO("=========================================="); + } + + if (thisBlockType == BlockTypes.STANDARD.name().toUpperCase()){ + LanguageRegistry.addName(this, "Block of "+blockMaterial); + //Utils.LOG_INFO("Registered Block in Language Registry as: "+"Block of "+blockMaterial); + } + else if (thisBlockType == BlockTypes.FRAME.name().toUpperCase()){ + LanguageRegistry.addName(this, blockMaterial+ " Frame Box"); + //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 (thisBlockType == BlockTypes.STANDARD.name().toUpperCase()){ + GameRegistry.registerBlock(this, ItemBlockGtBlock.class, Utils.sanitizeString(blockType.getTexture()+unlocalizedName)); + //Utils.LOG_INFO("Registered Block in Block Registry as: "+"Block of "+blockMaterial); + } + else if (thisBlockType == BlockTypes.FRAME.name().toUpperCase()){ + GameRegistry.registerBlock(this, ItemBlockGtFrameBox.class, Utils.sanitizeString(blockType.getTexture()+unlocalizedName)); + //Utils.LOG_INFO("Registered Block in Block Registry as: "+blockMaterial+" Frame Box"); + } + else { + GameRegistry.registerBlock(this, ItemBlockGtBlock.class, Utils.sanitizeString(blockType.getTexture()+unlocalizedName)); + //Utils.LOG_INFO("Registered Block in Block Registry as: "+blockMaterial); + } + + + } + + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + if (thisBlock == BlockTypes.FRAME){ + return 1; + } + return 0; + } + + /*@Override + public String getLocalizedName() { + String tempIngot; + if (thisBlock == BlockTypes.STANDARD){ + tempIngot = "Block of "+thisBlockMaterial; + } + else if (thisBlock == BlockTypes.FRAME){ + tempIngot = thisBlockMaterial + " Frame Box"; + } + else { + + tempIngot = getUnlocalizedName().replace("tile.blockGt", "ingot"); + } + return tempIngot; + }*/ + + public String GetProperName() { + String tempIngot; + if (thisBlock == BlockTypes.STANDARD){ + tempIngot = "Block of "+thisBlockMaterial; + } + else if (thisBlock == BlockTypes.FRAME){ + tempIngot = thisBlockMaterial + " Frame Box"; + } + else { + + tempIngot = getUnlocalizedName().replace("tile.blockGt", "ingot"); + } + return tempIngot; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iIcon) + { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + thisBlock.getTexture()); + } + + @Override + public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4){ + + if (this.blockColour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } + + @Override + public int getRenderColor(int aMeta) { + if (this.blockColour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } + + @Override + public int getBlockColor() { + return this.blockColour; + } + +} diff --git a/src/Java/gtPlusPlus/core/block/base/MetaBlock.java b/src/Java/gtPlusPlus/core/block/base/MetaBlock.java new file mode 100644 index 0000000000..4009c36726 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/MetaBlock.java @@ -0,0 +1,28 @@ +package gtPlusPlus.core.block.base; + +import java.util.List; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class MetaBlock extends MultiTextureBlock { + + protected MetaBlock(String unlocalizedName, Material material, SoundType soundType) { + super(unlocalizedName, material, soundType); + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 6; i ++) { + list.add(new ItemStack(item, 1, i)); + } + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java b/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java new file mode 100644 index 0000000000..4f022bae6d --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/base/MultiTextureBlock.java @@ -0,0 +1,36 @@ +package gtPlusPlus.core.block.base; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +public class MultiTextureBlock extends Block { + + public IIcon[] icons = new IIcon[6]; + + protected MultiTextureBlock(String unlocalizedName, Material material, SoundType blockSound) + { + super(material); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(2.0F); + this.setResistance(6.0F); + this.setStepSound(blockSound); + } + + @Override + public void registerBlockIcons(IIconRegister reg) { + for (int i = 0; i < 6; i ++) { + this.icons[i] = reg.registerIcon(this.textureName + "_" + i); + } + } + + @Override + public IIcon getIcon(int side, int meta) { + return this.icons[side]; + } +}
\ No newline at end of file |