Guest User

General colored class

a guest
Nov 26th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.35 KB | None | 0 0
  1. package yesodmod.general.fluid;
  2.  
  3. import java.io.IOException;
  4.  
  5. import yesodmod.general.Generic;
  6. import net.minecraft.block.material.Material;
  7. import net.minecraft.client.renderer.texture.IIconRegister;
  8. import net.minecraft.creativetab.CreativeTabs;
  9. import net.minecraft.util.IIcon;
  10. import net.minecraft.world.IBlockAccess;
  11. import net.minecraft.world.World;
  12. import net.minecraftforge.fluids.BlockFluidClassic;
  13. import net.minecraftforge.fluids.Fluid;
  14. import cpw.mods.fml.common.Mod.EventHandler;
  15. import cpw.mods.fml.common.event.FMLPreInitializationEvent;
  16. import cpw.mods.fml.relauncher.Side;
  17. import cpw.mods.fml.relauncher.SideOnly;
  18.  
  19. public class ColoredWaterBlocks extends BlockFluidClassic
  20. {
  21.     @SideOnly(Side.CLIENT)
  22.     public static IIcon blockIcon;
  23.     @SideOnly(Side.CLIENT)
  24.     public static IIcon flowingIcon;
  25.     @SideOnly(Side.CLIENT)
  26.     public static IIcon stillIcon;
  27.     @SideOnly(Side.CLIENT)
  28.     public static String[] blockName = {"bluewater", "redwater"};
  29.     private int texturename;
  30.    
  31.     public ColoredWaterBlocks(Fluid fluid, Material material, int texture)
  32.     {
  33.         super(fluid, material);
  34.         setCreativeTab(CreativeTabs.tabMisc);
  35.         int texturename = texture;
  36.     }
  37.    
  38.     public int getTextureNum() {
  39.         return texturename;
  40.        
  41.     }
  42.        
  43.     @Override
  44.     public IIcon getIcon(int side, int meta) {
  45.             return (side == 0 || side == 1)? stillIcon : flowingIcon;
  46.     }
  47.  
  48.     @SideOnly(Side.CLIENT)
  49.     @Override
  50.     public void registerBlockIcons(IIconRegister iconRegister) {
  51.             this.blockIcon = iconRegister.registerIcon("yesodmod:" + blockName[this.getTextureNum()]);
  52.             this.stillIcon = iconRegister.registerIcon("yesodmod:" + blockName[this.getTextureNum()] + "still");
  53.             this.flowingIcon = iconRegister.registerIcon("yesodmod:" + blockName[this.getTextureNum()] + "flow");
  54.     }
  55.    
  56.    
  57.     @Override
  58.     public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
  59.             if (world.getBlock(x,  y,  z).getMaterial().isLiquid()) return false;
  60.             return super.canDisplace(world, x, y, z);
  61.     }
  62.    
  63.     @Override
  64.     public boolean displaceIfPossible(World world, int x, int y, int z) {
  65.             if (world.getBlock(x,  y,  z).getMaterial().isLiquid()) return false;
  66.             return super.displaceIfPossible(world, x, y, z);
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment