1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
package gtPlusPlus.core.fluids;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
public class BlockFluidBase extends BlockFluidClassic {
@SideOnly(Side.CLIENT)
protected static IIcon stillIcon;
@SideOnly(Side.CLIENT)
protected static IIcon flowingIcon;
protected final short[] mRGB;
public BlockFluidBase(Fluid fluid, short[] aRGB) {
this(fluid, Material.water, aRGB);
}
public BlockFluidBase(Fluid fluid, Material material, short[] aRGB) {
super(fluid, material);
mRGB = aRGB;
this.setHardness(100.0F);
this.setLightOpacity(3);
this.disableStats();
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity ent) {
if (!(ent instanceof EntityLivingBase)) {
return;
}
/*EntityLivingBase player = (EntityLivingBase) ent;
int pot = world.rand.nextInt(Potion.potionTypes.length);
Potion.potionTypes[pot].performEffect(player, 40);*/
}
@Override
public IIcon getIcon(int side, int meta) {
return (side == 0 || side == 1) ? stillIcon : flowingIcon;
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
if (stillIcon == null) {
stillIcon = register.registerIcon(CORE.MODID+ ":" + "fluids/fluid.fluid.autogenerated.still");
}
if (flowingIcon == null) {
flowingIcon = register.registerIcon(CORE.MODID+ ":" + "fluids/fluid.fluid.autogenerated.flowing");
}
}
@Override
public int getBlockColor() {
if (mRGB != null && mRGB.length >= 3) {
return Utils.rgbtoHexValue(mRGB[0], mRGB[1], mRGB[2]);
}
return super.getBlockColor();
}
@Override
public int getRenderColor(int aMeta) {
if (mRGB != null && mRGB.length >= 3) {
return Utils.rgbtoHexValue(mRGB[0], mRGB[1], mRGB[2]);
}
return super.getRenderColor(aMeta);
}
@Override
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) {
// TODO Auto-generated method stub
return super.recolourBlock(world, x, y, z, side, colour);
}
@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid()) {
return false;
}
return super.canDisplace(world, x, y, z);
}
@Override
public boolean displaceIfPossible(World world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid()) {
return false;
}
return super.displaceIfPossible(world, x, y, z);
}
}
|