ActuallyAdditions/src/main/java/ellpeck/actuallyadditions/blocks/BlockFluidFlowing.java

99 lines
3 KiB
Java
Raw Normal View History

2015-04-26 20:07:57 +02:00
package ellpeck.actuallyadditions.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2015-06-18 13:14:57 +02:00
import ellpeck.actuallyadditions.util.BlockUtil;
2015-04-26 20:07:57 +02:00
import ellpeck.actuallyadditions.util.INameableItem;
2015-05-20 22:39:43 +02:00
import ellpeck.actuallyadditions.util.ModUtil;
2015-04-26 20:07:57 +02:00
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
2015-06-18 13:14:57 +02:00
import net.minecraft.entity.player.EntityPlayer;
2015-04-26 20:07:57 +02:00
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
2015-05-20 22:39:43 +02:00
import net.minecraft.world.IBlockAccess;
2015-04-26 20:07:57 +02:00
import net.minecraft.world.World;
2015-05-20 22:39:43 +02:00
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
2015-04-26 20:07:57 +02:00
2015-06-18 13:14:57 +02:00
import java.util.List;
2015-05-20 22:39:43 +02:00
public class BlockFluidFlowing extends BlockFluidClassic implements INameableItem{
2015-04-26 20:07:57 +02:00
2015-05-20 22:39:43 +02:00
private String name;
2015-04-26 20:07:57 +02:00
2015-05-20 22:39:43 +02:00
public IIcon stillIcon;
public IIcon flowingIcon;
2015-04-26 20:07:57 +02:00
2015-05-20 22:39:43 +02:00
public BlockFluidFlowing(Fluid fluid, Material material, String unlocalizedName){
super(fluid, material);
this.name = unlocalizedName;
this.setRenderPass(1);
displacements.put(this, false);
2015-04-26 20:07:57 +02:00
}
@Override
2015-05-20 22:39:43 +02:00
public boolean canDisplace(IBlockAccess world, int x, int y, int z){
return !world.getBlock(x, y, z).getMaterial().isLiquid() && super.canDisplace(world, x, y, z);
2015-04-26 20:07:57 +02:00
}
@Override
2015-05-20 22:39:43 +02:00
public boolean displaceIfPossible(World world, int x, int y, int z){
return !world.getBlock(x, y, z).getMaterial().isLiquid() && super.displaceIfPossible(world, x, y, z);
2015-04-26 20:07:57 +02:00
}
@Override
2015-05-20 22:39:43 +02:00
public IIcon getIcon(int side, int meta){
return side <= 1 ? this.stillIcon : this.flowingIcon;
2015-04-26 20:07:57 +02:00
}
@Override
2015-05-20 22:39:43 +02:00
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.stillIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Still");
this.flowingIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Flowing");
this.definedFluid.setIcons(this.stillIcon, this.flowingIcon);
2015-04-26 20:07:57 +02:00
}
@Override
public String getName(){
2015-05-20 22:39:43 +02:00
return this.name;
2015-04-26 20:07:57 +02:00
}
public static class TheItemBlock extends ItemBlock{
private Block theBlock;
public TheItemBlock(Block block){
super(block);
this.theBlock = block;
this.setHasSubtypes(false);
this.setMaxDamage(0);
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.uncommon;
}
@Override
public String getUnlocalizedName(ItemStack stack){
return this.getUnlocalizedName();
}
2015-06-18 13:14:57 +02:00
@Override
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
BlockUtil.addInformation(theBlock, list, 1, "");
}
2015-04-26 20:07:57 +02:00
@Override
public int getMetadata(int damage){
return damage;
}
}
}