From f30d9f3ad55ae18cec5e86cc6a7b0124847b9a1f Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sun, 26 Nov 2017 19:09:55 +1000 Subject: % Made the Xp Converter more colourful. --- .../core/block/general/BlockTankXpConverter.java | 104 ++++++++++++++++++++- 1 file changed, 100 insertions(+), 4 deletions(-) (limited to 'src/Java/gtPlusPlus/core/block') diff --git a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java index e4270061cb..c2afdfd21f 100644 --- a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java +++ b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -1,5 +1,9 @@ package gtPlusPlus.core.block.general; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; @@ -9,6 +13,8 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.TileEntityXpConverter; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.array.Triplet; import gtPlusPlus.core.util.enchanting.EnchantingUtils; import gtPlusPlus.core.util.player.PlayerUtils; import net.minecraft.block.BlockContainer; @@ -32,6 +38,10 @@ public class BlockTankXpConverter extends BlockContainer { @SideOnly(Side.CLIENT) private IIcon textureFront; + private int mRainbowTick = 0; + private int mRainbowTickMax = 0; + private final Map> mRainbowMap = new HashMap>(); + @SuppressWarnings("deprecation") public BlockTankXpConverter() { super(Material.iron); @@ -39,6 +49,10 @@ public class BlockTankXpConverter extends BlockContainer { this.setCreativeTab(AddToCreativeTab.tabMachines); GameRegistry.registerBlock(this, ItemBlockEntityBase.class, "blockTankXpConverter"); LanguageRegistry.addName(this, "Xp Converter"); + this.generateRainbowMap(); + if (!this.getTickRandomly()){ + this.setTickRandomly(true); + } } /** @@ -55,10 +69,10 @@ public class BlockTankXpConverter extends BlockContainer { @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(final IIconRegister p_149651_1_) { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); } /** @@ -142,4 +156,86 @@ public class BlockTankXpConverter extends BlockContainer { return false; } + private final boolean generateRainbowMap(){ + int id = 0; + this.mRainbowMap.put(id++, new Triplet( 0, 255, 0)); + this.mRainbowMap.put(id++, new Triplet( 51, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(102, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(153, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(204, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 204, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 153, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 102, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 51, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 51)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 102)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 153)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 204)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 255)); + this.mRainbowMap.put(id++, new Triplet(204, 0, 255)); + this.mRainbowMap.put(id++, new Triplet(153, 0, 255)); + this.mRainbowMap.put(id++, new Triplet(102, 0, 255)); + this.mRainbowMap.put(id++, new Triplet( 51, 0, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 0, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 51, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 102, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 153, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 204, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 255, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 255, 204)); + this.mRainbowMap.put(id++, new Triplet( 0, 255, 153)); + this.mRainbowMap.put(id++, new Triplet( 0, 255, 102)); + this.mRainbowMap.put(id++, new Triplet( 0, 255, 51)); + this.mRainbowTickMax = this.mRainbowMap.size(); + return true; + } + + @Override + public int getBlockColor() { + return Utils.rgbtoHexValue(0, 0, 0); + } + + @Override + public int colorMultiplier(final IBlockAccess p_149720_1_, final int p_149720_2_, final int p_149720_3_, final int p_149720_4_) { + + if ((this.mRainbowTick < 0) || (this.mRainbowTick > this.mRainbowTickMax)){ + this.mRainbowTick = 0; + } + //Utils.LOG_INFO("x: "+this.mRainbowTick); + if (this.mRainbowTick <= this.mRainbowTickMax){ + Triplet mT = this.mRainbowMap.get(this.mRainbowTick); + try { + return Utils.rgbtoHexValue(mT.getValue_1(), mT.getValue_1(), mT.getValue_1()); + } catch (final Throwable t){ + try { + mT = this.mRainbowMap.get(this.mRainbowTick-1); + return Utils.rgbtoHexValue(mT.getValue_1(), mT.getValue_1(), mT.getValue_1()); + } catch (final Throwable t1){ + return Utils.rgbtoHexValue(0, 0, 0); + } + } + } + + return Utils.rgbtoHexValue(0, 0, 0); + } + + @Override + public void updateTick(final World world, final int x, final int y, final int z, final Random rand) { + //this.mRainbowTick++; + super.updateTick(world, x, y, z, rand); + } + + @Override + public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) { + this.mRainbowTick++; + super.randomDisplayTick(world, x, y, z, rand); + } + + @Override + public int tickRate(final World p_149738_1_) { + return 20; + } + } -- cgit