Fixed errrors in Fluids package. TODO: Make BlockLiquid implement IFluidBlock and REMOVE FluidContainerRegsitry. Everything *should* be able to use IFluidContainer directly.
This commit is contained in:
parent
ee82341312
commit
206a21d563
|
@ -0,0 +1,11 @@
|
|||
--- ../src-base/minecraft/net/minecraft/block/BlockStaticLiquid.java
|
||||
+++ ../src-work/minecraft/net/minecraft/block/BlockStaticLiquid.java
|
||||
@@ -52,7 +52,7 @@
|
||||
{
|
||||
blockpos = blockpos.add(rand.nextInt(3) - 1, 1, rand.nextInt(3) - 1);
|
||||
|
||||
- if (blockpos.getY() >= 0 && blockpos.getY() < 256 && !worldIn.isBlockLoaded(blockpos))
|
||||
+ if (blockpos.getY() >= 0 && blockpos.getY() < worldIn.getHeight() && !worldIn.isBlockLoaded(blockpos))
|
||||
{
|
||||
return;
|
||||
}
|
|
@ -36,7 +36,7 @@
|
|||
+ if (itemstack.getItem().hasContainerItem(itemstack))
|
||||
{
|
||||
- ItemStack itemstack1 = new ItemStack(itemstack.getItem().getContainerItem());
|
||||
+ ItemStack itemstack1 = new ItemStack(itemstack.getItem().getContainerItem(itemstack));
|
||||
+ ItemStack itemstack1 = itemstack.getItem().getContainerItem(itemstack);
|
||||
|
||||
if (itemstack.stackSize <= 0)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
--- ../src-base/minecraft/net/minecraft/util/ActionResult.java
|
||||
+++ ../src-work/minecraft/net/minecraft/util/ActionResult.java
|
||||
@@ -20,4 +20,10 @@
|
||||
{
|
||||
return this.field_188400_b;
|
||||
}
|
||||
+
|
||||
+ //Just a generic helper function to make typecasing easier...
|
||||
+ public static <T> ActionResult<T> newResult(EnumActionResult result, T value)
|
||||
+ {
|
||||
+ return new ActionResult<T>(result, value);
|
||||
+ }
|
||||
}
|
|
@ -7,16 +7,15 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
|
@ -34,8 +33,6 @@ import com.google.common.collect.Maps;
|
|||
*
|
||||
* It is highly recommended that you extend this class or one of the Forge-provided child classes.
|
||||
*
|
||||
* @author King Lemming, OvermindDL1
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||
|
@ -110,7 +107,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
protected float quantaPerBlockFloat = 8F;
|
||||
protected int density = 1;
|
||||
protected int densityDir = -1;
|
||||
protected int temperature = 295;
|
||||
protected int temperature = 295;
|
||||
|
||||
protected int tickRate = 20;
|
||||
protected BlockRenderLayer renderLayer = BlockRenderLayer.TRANSLUCENT;
|
||||
|
@ -128,7 +125,6 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
public BlockFluidBase(Fluid fluid, Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.setTickRandomly(true);
|
||||
this.disableStats();
|
||||
|
||||
|
@ -146,7 +142,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState()
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new ExtendedBlockState(this, new IProperty[] { LEVEL }, FLUID_RENDER_PROPS);
|
||||
}
|
||||
|
@ -154,7 +150,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return ((Integer)state.getValue(LEVEL)).intValue();
|
||||
return state.getValue(LEVEL);
|
||||
}
|
||||
public BlockFluidBase setQuantaPerBlock(int quantaPerBlock)
|
||||
{
|
||||
|
@ -204,19 +200,19 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
{
|
||||
if (world.isAirBlock(pos)) return true;
|
||||
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
if (block == this)
|
||||
if (state.getBlock() == this)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (displacements.containsKey(block))
|
||||
if (displacements.containsKey(state.getBlock()))
|
||||
{
|
||||
return displacements.get(block);
|
||||
return displacements.get(state.getBlock());
|
||||
}
|
||||
|
||||
Material material = block.getMaterial();
|
||||
Material material = state.func_185904_a();
|
||||
if (material.blocksMovement() || material == Material.portal)
|
||||
{
|
||||
return false;
|
||||
|
@ -225,16 +221,16 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
int density = getDensity(world, pos);
|
||||
if (density == Integer.MAX_VALUE)
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.density > density)
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,7 +261,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
return false;
|
||||
}
|
||||
|
||||
Material material = block.getMaterial();
|
||||
Material material = state.func_185904_a();
|
||||
if (material.blocksMovement() || material == Material.portal)
|
||||
{
|
||||
return false;
|
||||
|
@ -274,17 +270,17 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
int density = getDensity(world, pos);
|
||||
if (density == Integer.MAX_VALUE)
|
||||
{
|
||||
block.dropBlockAsItem(world, pos, state, 0);
|
||||
return true;
|
||||
block.dropBlockAsItem(world, pos, state, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.density > density)
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,10 +336,10 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
}
|
||||
|
||||
@Override
|
||||
public Vec3 modifyAcceleration(World world, BlockPos pos, Entity entity, Vec3 vec)
|
||||
public Vec3d modifyAcceleration(World world, BlockPos pos, Entity entity, Vec3d vec)
|
||||
{
|
||||
if (densityDir > 0) return vec;
|
||||
Vec3 vec_flow = this.getFlowVector(world, pos);
|
||||
Vec3d vec_flow = this.getFlowVector(world, pos);
|
||||
return vec.addVector(
|
||||
vec_flow.xCoord * (quantaPerBlock * 4),
|
||||
vec_flow.yCoord * (quantaPerBlock * 4),
|
||||
|
@ -351,24 +347,24 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, BlockPos pos)
|
||||
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
if (maxScaledLight == 0)
|
||||
{
|
||||
return super.getLightValue(world, pos);
|
||||
return super.getLightValue(state, world, pos);
|
||||
}
|
||||
int data = ((Integer)world.getBlockState(pos).getValue(LEVEL)).intValue();
|
||||
int data = state.getValue(LEVEL);
|
||||
return (int) (data / quantaPerBlockFloat * maxScaledLight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube()
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -384,7 +380,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
*/
|
||||
|
||||
@Override
|
||||
public int getMixedBrightnessForBlock(IBlockAccess world, BlockPos pos)
|
||||
public int func_185484_c(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
int lightThis = world.getCombinedLight(pos, 0);
|
||||
int lightUp = world.getCombinedLight(pos.up(), 0);
|
||||
|
@ -404,10 +400,10 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered(IBlockAccess world, BlockPos pos, EnumFacing side)
|
||||
public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
if (block.getMaterial() == this.blockMaterial)
|
||||
IBlockState neighbor = world.getBlockState(pos.offset(side));
|
||||
if (neighbor.func_185904_a() == state.func_185904_a())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -419,7 +415,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
{
|
||||
return true;
|
||||
}
|
||||
return super.shouldSideBeRendered(world, pos, side);
|
||||
return super.shouldSideBeRendered(state, world, pos, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -490,12 +486,12 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
|
||||
public static double getFlowDirection(IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
if (!block.getMaterial().isLiquid())
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (!state.func_185904_a().isLiquid())
|
||||
{
|
||||
return -1000.0;
|
||||
}
|
||||
Vec3 vec = ((BlockFluidBase) block).getFlowVector(world, pos);
|
||||
Vec3d vec = ((BlockFluidBase)state.getBlock()).getFlowVector(world, pos);
|
||||
return vec.xCoord == 0.0D && vec.zCoord == 0.0D ? -1000.0D : Math.atan2(vec.zCoord, vec.xCoord) - Math.PI / 2D;
|
||||
}
|
||||
|
||||
|
@ -558,7 +554,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
IBlockState up = world.getBlockState(pos.down(densityDir));
|
||||
if (here.getBlock() == this)
|
||||
{
|
||||
if (up.getBlock().getMaterial().isLiquid() || up.getBlock() instanceof IFluidBlock)
|
||||
if (up.func_185904_a().isLiquid() || up.getBlock() instanceof IFluidBlock)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -568,12 +564,12 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
return 0.875F;
|
||||
}
|
||||
}
|
||||
return !here.getBlock().getMaterial().isSolid() && up.getBlock() == this ? 1 : this.getQuantaPercentage(world, pos) * 0.875F;
|
||||
return !here.func_185904_a().isSolid() && up.getBlock() == this ? 1 : this.getQuantaPercentage(world, pos) * 0.875F;
|
||||
}
|
||||
|
||||
public Vec3 getFlowVector(IBlockAccess world, BlockPos pos)
|
||||
public Vec3d getFlowVector(IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
Vec3 vec = new Vec3(0.0D, 0.0D, 0.0D);
|
||||
Vec3d vec = new Vec3d(0.0D, 0.0D, 0.0D);
|
||||
int decay = quantaPerBlock - getQuantaValue(world, pos);
|
||||
|
||||
for (int side = 0; side < 4; ++side)
|
||||
|
@ -593,7 +589,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
int otherDecay = quantaPerBlock - getQuantaValue(world, pos2);
|
||||
if (otherDecay >= quantaPerBlock)
|
||||
{
|
||||
if (!world.getBlockState(pos2).getBlock().getMaterial().blocksMovement())
|
||||
if (!world.getBlockState(pos2).func_185904_a().blocksMovement())
|
||||
{
|
||||
otherDecay = quantaPerBlock - getQuantaValue(world, pos2.down());
|
||||
if (otherDecay >= 0)
|
||||
|
@ -646,4 +642,4 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
|||
if (remaining > 1) remaining = 1.0f;
|
||||
return remaining * (density > 0 ? 1 : -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.minecraftforge.fluids;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -15,8 +14,6 @@ import net.minecraft.world.World;
|
|||
*
|
||||
* It is highly recommended that you use/extend this class for "classic" fluid blocks.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class BlockFluidClassic extends BlockFluidBase
|
||||
{
|
||||
|
@ -56,14 +53,14 @@ public class BlockFluidClassic extends BlockFluidBase
|
|||
return -1;
|
||||
}
|
||||
|
||||
int quantaRemaining = quantaPerBlock - ((Integer)state.getValue(LEVEL)).intValue();
|
||||
int quantaRemaining = quantaPerBlock - state.getValue(LEVEL);
|
||||
return quantaRemaining;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideCheck(IBlockState state, boolean fullHit)
|
||||
{
|
||||
return fullHit && ((Integer)state.getValue(LEVEL)).intValue() == 0;
|
||||
return fullHit && state.getValue(LEVEL) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,20 +70,20 @@ public class BlockFluidClassic extends BlockFluidBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, BlockPos pos)
|
||||
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
if (maxScaledLight == 0)
|
||||
{
|
||||
return super.getLightValue(world, pos);
|
||||
return super.getLightValue(state, world, pos);
|
||||
}
|
||||
int data = quantaPerBlock - ((Integer)world.getBlockState(pos).getValue(LEVEL)).intValue() - 1;
|
||||
int data = quantaPerBlock - state.getValue(LEVEL) - 1;
|
||||
return (int) (data / quantaPerBlockFloat * maxScaledLight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
|
||||
{
|
||||
int quantaRemaining = quantaPerBlock - ((Integer)state.getValue(LEVEL)).intValue();
|
||||
int quantaRemaining = quantaPerBlock - state.getValue(LEVEL);
|
||||
int expQuanta = -101;
|
||||
|
||||
// check adjacent block levels if non-source
|
||||
|
@ -171,7 +168,8 @@ public class BlockFluidClassic extends BlockFluidBase
|
|||
|
||||
public boolean isSourceBlock(IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
return world.getBlockState(pos).getBlock() == this && ((Integer)world.getBlockState(pos).getValue(LEVEL)).intValue() == 0;
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
return state.getBlock() == this && state.getValue(LEVEL) == 0;
|
||||
}
|
||||
|
||||
protected boolean[] getOptimalFlowDirections(World world, BlockPos pos)
|
||||
|
@ -280,18 +278,18 @@ public class BlockFluidClassic extends BlockFluidBase
|
|||
{
|
||||
if (world.isAirBlock(pos)) return true;
|
||||
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
if (block == this)
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (displacements.containsKey(block))
|
||||
if (displacements.containsKey(state.getBlock()))
|
||||
{
|
||||
return displacements.get(block);
|
||||
return displacements.get(state.getBlock());
|
||||
}
|
||||
|
||||
Material material = block.getMaterial();
|
||||
Material material = state.func_185904_a();
|
||||
if (material.blocksMovement() ||
|
||||
material == Material.water ||
|
||||
material == Material.lava ||
|
||||
|
@ -312,7 +310,7 @@ public class BlockFluidClassic extends BlockFluidBase
|
|||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import java.util.Random;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -16,8 +16,6 @@ import net.minecraft.world.World;
|
|||
*
|
||||
* It is highly recommended that you use/extend this class for finite fluid blocks.
|
||||
*
|
||||
* @author OvermindDL1, KingLemming
|
||||
*
|
||||
*/
|
||||
public class BlockFluidFinite extends BlockFluidBase
|
||||
{
|
||||
|
@ -30,7 +28,7 @@ public class BlockFluidFinite extends BlockFluidBase
|
|||
public int getQuantaValue(IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock().isAir(world, pos))
|
||||
if (state.getBlock().isAir(state, world, pos))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -39,13 +37,13 @@ public class BlockFluidFinite extends BlockFluidBase
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
return ((Integer)state.getValue(LEVEL)) + 1;
|
||||
return state.getValue(LEVEL) + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideCheck(IBlockState state, boolean fullHit)
|
||||
{
|
||||
return fullHit && ((Integer)state.getValue(LEVEL)) == quantaPerBlock - 1;
|
||||
return fullHit && state.getValue(LEVEL) == quantaPerBlock - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +56,7 @@ public class BlockFluidFinite extends BlockFluidBase
|
|||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
|
||||
{
|
||||
boolean changed = false;
|
||||
int quantaRemaining = ((Integer)state.getValue(LEVEL)) + 1;
|
||||
int quantaRemaining = state.getValue(LEVEL) + 1;
|
||||
|
||||
// Flow vertically if possible
|
||||
int prevRemaining = quantaRemaining;
|
||||
|
@ -242,4 +240,4 @@ public class BlockFluidFinite extends BlockFluidBase
|
|||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package net.minecraftforge.fluids;
|
|||
import java.util.Locale;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
|
@ -24,8 +24,6 @@ import net.minecraft.item.EnumRarity;
|
|||
* The default values can be used as a reference point for mods adding fluids such as oil or heavy
|
||||
* water.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class Fluid
|
||||
{
|
||||
|
@ -165,12 +163,6 @@ public class Fluid
|
|||
return this.fluidName;
|
||||
}
|
||||
|
||||
@Deprecated // Modders should never actually use int ID, use String
|
||||
public final int getID()
|
||||
{
|
||||
return FluidRegistry.getFluidID(this.fluidName);
|
||||
}
|
||||
|
||||
public final Block getBlock()
|
||||
{
|
||||
return block;
|
||||
|
@ -187,7 +179,7 @@ public class Fluid
|
|||
public String getLocalizedName(FluidStack stack)
|
||||
{
|
||||
String s = this.getUnlocalizedName();
|
||||
return s == null ? "" : StatCollector.translateToLocal(s);
|
||||
return s == null ? "" : I18n.translateToLocal(s);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,9 +19,10 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
*
|
||||
* For more complex items, use {@link IFluidContainerItem} instead.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
* Deprecated: We will eventually be moving this ALL away from a registry and instead EVERYTHING will use IFluidContainerItem.
|
||||
* We need to decide a way of swaping Items/Stacks.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class FluidContainerRegistry
|
||||
{
|
||||
// Holder object that implements HashCode for an ItemStack,
|
||||
|
@ -168,8 +169,8 @@ public abstract class FluidContainerRegistry
|
|||
}
|
||||
if (data.fluid == null || data.fluid.getFluid() == null)
|
||||
{
|
||||
FMLLog.bigWarning("Invalid registration attempt for a fluid container item %s has occurred. The registration has been denied to prevent crashes. The mod responsible for the registration needs to correct this.", data.filledContainer.getItem().getUnlocalizedName(data.filledContainer));
|
||||
return false;
|
||||
FMLLog.bigWarning("Invalid registration attempt for a fluid container item %s has occurred. The registration has been denied to prevent crashes. The mod responsible for the registration needs to correct this.", data.filledContainer.getItem().getUnlocalizedName(data.filledContainer));
|
||||
return false;
|
||||
}
|
||||
containerFluidMap.put(new ContainerKey(data.filledContainer), data);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
@ -32,9 +32,6 @@ import net.minecraftforge.fml.common.registry.RegistryDelegate;
|
|||
|
||||
/**
|
||||
* Handles Fluid registrations. Fluids MUST be registered in order to function.
|
||||
*
|
||||
* @author King Lemming, CovertJaguar (LiquidDictionary)
|
||||
*
|
||||
*/
|
||||
public abstract class FluidRegistry
|
||||
{
|
||||
|
@ -56,14 +53,14 @@ public abstract class FluidRegistry
|
|||
public static final Fluid WATER = new Fluid("water", new ResourceLocation("blocks/water_still"), new ResourceLocation("blocks/water_flow")) {
|
||||
@Override
|
||||
public String getLocalizedName(FluidStack fs) {
|
||||
return StatCollector.translateToLocal("tile.water.name");
|
||||
return I18n.translateToLocal("tile.water.name");
|
||||
}
|
||||
}.setBlock(Blocks.water).setUnlocalizedName(Blocks.water.getUnlocalizedName());
|
||||
|
||||
public static final Fluid LAVA = new Fluid("lava", new ResourceLocation("blocks/lava_still"), new ResourceLocation("blocks/lava_flow")) {
|
||||
@Override
|
||||
public String getLocalizedName(FluidStack fs) {
|
||||
return StatCollector.translateToLocal("tile.lava.name");
|
||||
return I18n.translateToLocal("tile.lava.name");
|
||||
}
|
||||
}.setBlock(Blocks.lava).setLuminosity(15).setDensity(3000).setViscosity(6000).setTemperature(1300).setUnlocalizedName(Blocks.lava.getUnlocalizedName());
|
||||
|
||||
|
@ -447,4 +444,4 @@ public abstract class FluidRegistry
|
|||
fluid = fluids.get(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ import net.minecraftforge.fml.common.registry.RegistryDelegate;
|
|||
* {@link #isFluidStackIdentical(FluidStack)} to determine if FluidID, Amount and NBT Tag are all
|
||||
* equal.
|
||||
*
|
||||
* @author King Lemming, SirSengir (LiquidStack)
|
||||
*
|
||||
*/
|
||||
public class FluidStack
|
||||
{
|
||||
|
@ -34,7 +32,7 @@ public class FluidStack
|
|||
FMLLog.bigWarning("Failed attempt to create a FluidStack for an unregistered Fluid %s (type %s)", fluid.getName(), fluid.getClass().getName());
|
||||
throw new IllegalArgumentException("Cannot create a fluidstack from an unregistered fluid");
|
||||
}
|
||||
this.fluidDelegate = FluidRegistry.makeDelegate(fluid);
|
||||
this.fluidDelegate = FluidRegistry.makeDelegate(fluid);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
|
@ -187,12 +185,12 @@ public class FluidStack
|
|||
@Override
|
||||
public final int hashCode()
|
||||
{
|
||||
int code = 1;
|
||||
code = 31*code + getFluid().hashCode();
|
||||
code = 31*code + amount;
|
||||
if (tag != null)
|
||||
code = 31*code + tag.hashCode();
|
||||
return code;
|
||||
int code = 1;
|
||||
code = 31*code + getFluid().hashCode();
|
||||
code = 31*code + amount;
|
||||
if (tag != null)
|
||||
code = 31*code + tag.hashCode();
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,9 +6,6 @@ import net.minecraft.tileentity.TileEntity;
|
|||
|
||||
/**
|
||||
* Reference implementation of {@link IFluidTank}. Use/extend this or implement your own.
|
||||
*
|
||||
* @author King Lemming, cpw (LiquidTank)
|
||||
*
|
||||
*/
|
||||
public class FluidTank implements IFluidTank
|
||||
{
|
||||
|
|
|
@ -2,9 +2,6 @@ package net.minecraftforge.fluids;
|
|||
|
||||
/**
|
||||
* Wrapper class used to encapsulate information about an IFluidTank.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public final class FluidTankInfo
|
||||
{
|
||||
|
|
|
@ -5,12 +5,14 @@ import net.minecraft.crash.CrashReportCategory;
|
|||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
@ -402,7 +404,7 @@ public class FluidUtil
|
|||
{
|
||||
if (world != null && pos != null)
|
||||
{
|
||||
world.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), "random.pop", 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
world.func_184148_a(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.field_187638_cR, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ import net.minecraft.world.World;
|
|||
*
|
||||
* NOTE: Using/extending the reference implementations {@link BlockFluidBase} is encouraged.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IFluidBlock
|
||||
{
|
||||
|
@ -49,4 +47,4 @@ public interface IFluidBlock
|
|||
* @return
|
||||
*/
|
||||
float getFilledPercentage(World world, BlockPos pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,18 +5,16 @@ import net.minecraft.item.ItemStack;
|
|||
/**
|
||||
* Implement this interface on Item classes that support external manipulation of their internal
|
||||
* fluid storage.
|
||||
*
|
||||
*
|
||||
* A reference implementation is provided {@link ItemFluidContainer}.
|
||||
*
|
||||
*
|
||||
* NOTE: Use of NBT data on the containing ItemStack is encouraged.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface IFluidContainerItem
|
||||
{
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param container
|
||||
* ItemStack which is the fluid container.
|
||||
* @return FluidStack representing the fluid in the container, null if the container is empty.
|
||||
|
@ -24,7 +22,7 @@ public interface IFluidContainerItem
|
|||
FluidStack getFluid(ItemStack container);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param container
|
||||
* ItemStack which is the fluid container.
|
||||
* @return Capacity of this fluid container.
|
||||
|
@ -32,7 +30,7 @@ public interface IFluidContainerItem
|
|||
int getCapacity(ItemStack container);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param container
|
||||
* ItemStack which is the fluid container.
|
||||
* @param resource
|
||||
|
@ -45,7 +43,7 @@ public interface IFluidContainerItem
|
|||
int fill(ItemStack container, FluidStack resource, boolean doFill);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param container
|
||||
* ItemStack which is the fluid container.
|
||||
* @param maxDrain
|
||||
|
|
|
@ -8,8 +8,6 @@ import net.minecraft.util.EnumFacing;
|
|||
*
|
||||
* A reference implementation is provided {@link TileFluidHandler}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IFluidHandler
|
||||
{
|
||||
|
|
|
@ -2,11 +2,8 @@ package net.minecraftforge.fluids;
|
|||
|
||||
/**
|
||||
* A tank is the unit of interaction with Fluid inventories.
|
||||
*
|
||||
*
|
||||
* A reference implementation can be found at {@link FluidTank}.
|
||||
*
|
||||
* @author King Lemming, cpw (ILiquidTank)
|
||||
*
|
||||
*/
|
||||
public interface IFluidTank
|
||||
{
|
||||
|
@ -28,15 +25,15 @@ public interface IFluidTank
|
|||
/**
|
||||
* Returns a wrapper object {@link FluidTankInfo } containing the capacity of the tank and the
|
||||
* FluidStack it holds.
|
||||
*
|
||||
*
|
||||
* Should prevent manipulation of the IFluidTank. See {@link FluidTank}.
|
||||
*
|
||||
*
|
||||
* @return State information for the IFluidTank.
|
||||
*/
|
||||
FluidTankInfo getInfo();
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param resource
|
||||
* FluidStack attempting to fill the tank.
|
||||
* @param doFill
|
||||
|
@ -46,7 +43,7 @@ public interface IFluidTank
|
|||
int fill(FluidStack resource, boolean doFill);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param maxDrain
|
||||
* Maximum amount of fluid to be removed from the container.
|
||||
* @param doFill
|
||||
|
|
|
@ -6,9 +6,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
|
||||
/**
|
||||
* Reference implementation of {@link IFluidContainerItem}. Use/extend this or implement your own.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class ItemFluidContainer extends Item implements IFluidContainerItem
|
||||
{
|
||||
|
|
|
@ -7,9 +7,6 @@ import net.minecraft.util.EnumFacing;
|
|||
|
||||
/**
|
||||
* Reference Tile Entity implementation of {@link IFluidHandler}. Use/extend this or write your own.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class TileFluidHandler extends TileEntity implements IFluidHandler
|
||||
{
|
||||
|
|
|
@ -6,15 +6,19 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
@ -88,27 +92,27 @@ public class UniversalBucket extends Item implements IFluidContainerItem
|
|||
|
||||
String unloc = this.getUnlocalizedNameInefficiently(stack);
|
||||
|
||||
if (StatCollector.canTranslate(unloc + "." + fluidStack.getFluid().getName()))
|
||||
if (I18n.canTranslate(unloc + "." + fluidStack.getFluid().getName()))
|
||||
{
|
||||
return StatCollector.translateToLocal(unloc + "." + fluidStack.getFluid().getName());
|
||||
return I18n.translateToLocal(unloc + "." + fluidStack.getFluid().getName());
|
||||
}
|
||||
|
||||
return StatCollector.translateToLocalFormatted(unloc + ".name", fluidStack.getLocalizedName());
|
||||
return I18n.translateToLocalFormatted(unloc + ".name", fluidStack.getLocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack itemstack, World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
FluidStack fluidStack = getFluid(itemstack);
|
||||
// empty bucket shouldn't exist, do nothing since it should be handled by the bucket event
|
||||
if (fluidStack == null)
|
||||
{
|
||||
return itemstack;
|
||||
return ActionResult.newResult(EnumActionResult.PASS, itemstack);
|
||||
}
|
||||
|
||||
// clicked on a block?
|
||||
MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, false);
|
||||
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
RayTraceResult mop = this.getMovingObjectPositionFromPlayer(world, player, false);
|
||||
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
BlockPos clickPos = mop.getBlockPos();
|
||||
// can we place liquid there?
|
||||
|
@ -125,7 +129,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
|
|||
&& !player.capabilities.isCreativeMode)
|
||||
{
|
||||
// success!
|
||||
player.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
|
||||
player.triggerAchievement(StatList.func_188057_b(this));
|
||||
|
||||
itemstack.stackSize--;
|
||||
ItemStack emptyStack = empty != null ? empty.copy() : new ItemStack(this);
|
||||
|
@ -133,13 +137,13 @@ public class UniversalBucket extends Item implements IFluidContainerItem
|
|||
// check whether we replace the item or add the empty one to the inventory
|
||||
if (itemstack.stackSize <= 0)
|
||||
{
|
||||
return emptyStack;
|
||||
return ActionResult.newResult(EnumActionResult.SUCCESS, emptyStack);
|
||||
}
|
||||
else
|
||||
{
|
||||
// add empty bucket to player inventory
|
||||
ItemHandlerHelper.giveItemToPlayer(player, emptyStack);
|
||||
return itemstack;
|
||||
return ActionResult.newResult(EnumActionResult.SUCCESS, itemstack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +151,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
|
|||
}
|
||||
|
||||
// couldn't place liquid there2
|
||||
return itemstack;
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, itemstack);
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,7 +162,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
|
|||
return false;
|
||||
}
|
||||
|
||||
Material material = worldIn.getBlockState(pos).getBlock().getMaterial();
|
||||
Material material = worldIn.getBlockState(pos).func_185904_a();
|
||||
boolean isSolid = material.isSolid();
|
||||
|
||||
// can only place in air or non-solid blocks
|
||||
|
@ -173,8 +177,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
|
|||
int i = pos.getX();
|
||||
int j = pos.getY();
|
||||
int k = pos.getZ();
|
||||
worldIn.playSoundEffect((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k
|
||||
+ 0.5F), "random.fizz", 0.5F,
|
||||
worldIn.func_184133_a(null, pos, SoundEvents.field_187646_bt, SoundCategory.BLOCKS, 0.5F,
|
||||
2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
|
||||
|
||||
for (int l = 0; l < 8; ++l)
|
||||
|
@ -206,21 +209,21 @@ public class UniversalBucket extends Item implements IFluidContainerItem
|
|||
}
|
||||
|
||||
// not for us to handle
|
||||
if (event.current == null ||
|
||||
!event.current.isItemEqual(empty) ||
|
||||
(nbtSensitive && ItemStack.areItemStackTagsEqual(event.current, empty)))
|
||||
if (event.getEmptyBucket() == null ||
|
||||
!event.getEmptyBucket().isItemEqual(empty) ||
|
||||
(nbtSensitive && ItemStack.areItemStackTagsEqual(event.getEmptyBucket(), empty)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// needs to target a block
|
||||
if (event.target == null || event.target.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
if (event.getTarget() == null || event.getTarget().typeOfHit != RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
World world = event.world;
|
||||
BlockPos pos = event.target.getBlockPos();
|
||||
World world = event.getWorld();
|
||||
BlockPos pos = event.getTarget().getBlockPos();
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
// Note that water and lava are NOT an instance of IFluidBlock! They are therefore not handled by this code!
|
||||
if (state.getBlock() instanceof IFluidBlock)
|
||||
|
@ -243,7 +246,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
|
|||
|
||||
// set it as the result
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
event.result = filledBucket;
|
||||
event.setFilledBucket(filledBucket);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -2,8 +2,10 @@ package net.minecraftforge.items;
|
|||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
|
||||
|
||||
|
@ -155,8 +157,8 @@ public class ItemHandlerHelper
|
|||
// play sound if something got picked up
|
||||
if (remainder == null || remainder.stackSize != stack.stackSize)
|
||||
{
|
||||
world.playSoundEffect(player.posX, player.posY, player.posZ,
|
||||
"random.pop", 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
world.func_184148_a(player, player.posX, player.posY, player.posZ,
|
||||
SoundEvents.field_187638_cR, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
}
|
||||
|
||||
// drop remaining itemstack into the world
|
||||
|
|
Loading…
Reference in New Issue