Initial 1.11-pre1 update

This commit is contained in:
cpw committed 2016-11-13 17:09:55 -05:00
1 parent c177219ff3
commit 4e6a774075
294 files changed
+3099 -2846

No files matched your search

@@ -325,7 +325,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock)
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighbourPos)
{
world.scheduleUpdate(pos, this, tickRate);
}
@@ -675,7 +675,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos)
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos)
{
return NULL_AABB;
}
@@ -152,7 +152,7 @@ public class BlockFluidClassic extends BlockFluidBase
{
world.setBlockState(pos, state.withProperty(LEVEL, quantaPerBlock - expQuanta), 2);
world.scheduleUpdate(pos, this, tickRate);
world.notifyNeighborsOfStateChange(pos, this);
world.notifyNeighborsOfStateChange(pos, this, false);
}
}
}
@@ -29,6 +29,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.capability.IFluidHandler;
import javax.annotation.Nonnull;
/**
* Fills or drains a fluid container item using a Dispenser.
*/
@@ -60,7 +62,8 @@ public class DispenseFluidContainer extends BehaviorDefaultDispenseItem
/**
* Picks up fluid in front of a Dispenser and fills a container with it.
*/
private ItemStack fillContainer(IBlockSource source, ItemStack stack)
@Nonnull
private ItemStack fillContainer(IBlockSource source, @Nonnull ItemStack stack)
{
World world = source.getWorld();
EnumFacing dispenserFacing = source.getBlockState().getValue(BlockDispenser.FACING);
@@ -72,7 +75,7 @@ public class DispenseFluidContainer extends BehaviorDefaultDispenseItem
return super.dispenseStack(source, stack);
}
if (--stack.stackSize == 0)
if (stack.func_190916_E() == 1)
{
stack.deserializeNBT(result.serializeNBT());
}
@@ -81,6 +84,7 @@ public class DispenseFluidContainer extends BehaviorDefaultDispenseItem
this.dispenseBehavior.dispense(source, result);
}
stack.func_190918_g(1);
return stack;
}
@@ -90,7 +94,7 @@ public class DispenseFluidContainer extends BehaviorDefaultDispenseItem
private ItemStack dumpContainer(IBlockSource source, ItemStack stack)
{
ItemStack dispensedStack = stack.copy();
dispensedStack.stackSize = 1;
dispensedStack.func_190920_e(1);
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(dispensedStack);
if (fluidHandler == null)
{
@@ -105,7 +109,7 @@ public class DispenseFluidContainer extends BehaviorDefaultDispenseItem
{
fluidHandler.drain(Fluid.BUCKET_VOLUME, true);
if (--stack.stackSize == 0)
if (stack.func_190916_E() == 1)
{
stack.deserializeNBT(dispensedStack.serializeNBT());
}
@@ -19,6 +19,7 @@
package net.minecraftforge.fluids;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
@@ -84,10 +85,11 @@ public class FluidUtil
* @param doFill true if the container should actually be filled, false if it should be simulated.
* @return The filled container or null if the liquid couldn't be taken from the tank.
*/
public static ItemStack tryFillContainer(ItemStack container, IFluidHandler fluidSource, int maxAmount, @Nullable EntityPlayer player, boolean doFill)
@Nonnull
public static ItemStack tryFillContainer(@Nonnull ItemStack container, IFluidHandler fluidSource, int maxAmount, @Nullable EntityPlayer player, boolean doFill)
{
container = container.copy(); // do not modify the input
container.stackSize = 1;
container.func_190920_e(1);
IFluidHandler containerFluidHandler = getFluidHandler(container);
if (containerFluidHandler != null)
{
@@ -125,11 +127,11 @@ public class FluidUtil
* NOTE The empty container will have a stackSize of 0 when a filled container is consumable,
* i.e. it has a "null" empty container but has successfully been emptied.
*/
@Nullable
public static ItemStack tryEmptyContainer(ItemStack container, IFluidHandler fluidDestination, int maxAmount, @Nullable EntityPlayer player, boolean doDrain)
@Nonnull
public static ItemStack tryEmptyContainer(@Nonnull ItemStack container, IFluidHandler fluidDestination, int maxAmount, @Nullable EntityPlayer player, boolean doDrain)
{
container = container.copy(); // do not modify the input
container.stackSize = 1;
container.func_190920_e(1);
IFluidHandler containerFluidHandler = getFluidHandler(container);
if (containerFluidHandler != null)
{
@@ -169,9 +171,9 @@ public class FluidUtil
* @param player The player that gets the items the inventory can't take. Can be null, only used if the inventory cannot take the filled stack.
* @return True if the container was filled successfully and stowed, false otherwise.
*/
public static boolean tryFillContainerAndStow(ItemStack container, IFluidHandler fluidSource, IItemHandler inventory, int maxAmount, @Nullable EntityPlayer player)
public static boolean tryFillContainerAndStow(@Nonnull ItemStack container, IFluidHandler fluidSource, IItemHandler inventory, int maxAmount, @Nullable EntityPlayer player)
{
if (container == null || container.stackSize < 1)
if (container.func_190926_b())
{
return false;
}
@@ -184,7 +186,7 @@ public class FluidUtil
return true;
}
}
else if (container.stackSize == 1) // don't need to stow anything, just fill and edit the container stack
else if (container.func_190916_E() == 1) // don't need to stow anything, just fill and edit the container stack
{
ItemStack filledReal = tryFillContainer(container, fluidSource, maxAmount, player, true);
if (filledReal != null)
@@ -211,7 +213,7 @@ public class FluidUtil
ItemHandlerHelper.giveItemToPlayer(player, remainder);
}
container.stackSize--;
container.func_190918_g(1);
return true;
}
}
@@ -234,9 +236,9 @@ public class FluidUtil
* @param player The player that gets the items the inventory can't take. Can be null, only used if the inventory cannot take the filled stack.
* @return True if the container was filled successfully and stowed, false otherwise.
*/
public static boolean tryEmptyContainerAndStow(ItemStack container, IFluidHandler fluidDestination, IItemHandler inventory, int maxAmount, @Nullable EntityPlayer player)
public static boolean tryEmptyContainerAndStow(@Nonnull ItemStack container, IFluidHandler fluidDestination, IItemHandler inventory, int maxAmount, @Nullable EntityPlayer player)
{
if (container == null || container.stackSize < 1)
if (container.func_190926_b())
{
return false;
}
@@ -249,51 +251,45 @@ public class FluidUtil
return true;
}
}
else if (container.stackSize == 1) // don't need to stow anything, just fill and edit the container stack
else if (container.func_190916_E() == 1) // don't need to stow anything, just fill and edit the container stack
{
ItemStack emptiedReal = tryEmptyContainer(container, fluidDestination, maxAmount, player, true);
if (emptiedReal != null)
if (emptiedReal.func_190926_b())
{
if (emptiedReal.stackSize <= 0)
{
container.stackSize--;
}
else
{
container.deserializeNBT(emptiedReal.serializeNBT());
}
return true;
container.func_190918_g(1);
}
else
{
container.deserializeNBT(emptiedReal.serializeNBT());
}
return true;
}
else
{
ItemStack emptiedSimulated = tryEmptyContainer(container, fluidDestination, maxAmount, player, false);
if (emptiedSimulated != null)
if (emptiedSimulated.func_190926_b())
{
tryEmptyContainer(container, fluidDestination, maxAmount, player, true);
container.func_190918_g(1);
return true;
}
else
{
if (emptiedSimulated.stackSize <= 0)
// check if we can give the itemStack to the inventory
ItemStack remainder = ItemHandlerHelper.insertItemStacked(inventory, emptiedSimulated, true);
if (remainder == null || player != null)
{
tryEmptyContainer(container, fluidDestination, maxAmount, player, true);
container.stackSize--;
return true;
}
else
{
// check if we can give the itemStack to the inventory
ItemStack remainder = ItemHandlerHelper.insertItemStacked(inventory, emptiedSimulated, true);
if (remainder == null || player != null)
ItemStack emptiedReal = tryEmptyContainer(container, fluidDestination, maxAmount, player, true);
remainder = ItemHandlerHelper.insertItemStacked(inventory, emptiedReal, false);
// give it to the player or drop it at their feet
if (remainder != null && player != null)
{
ItemStack emptiedReal = tryEmptyContainer(container, fluidDestination, maxAmount, player, true);
remainder = ItemHandlerHelper.insertItemStacked(inventory, emptiedReal, false);
// give it to the player or drop it at their feet
if (remainder != null && player != null)
{
ItemHandlerHelper.giveItemToPlayer(player, remainder);
}
container.stackSize--;
return true;
ItemHandlerHelper.giveItemToPlayer(player, remainder);
}
container.func_190918_g(1);
return true;
}
}
}
@@ -381,7 +377,7 @@ public class FluidUtil
if (container != null)
{
container = container.copy();
container.stackSize = 1;
container.func_190920_e(1);
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container);
if (fluidHandler != null)
{
@@ -488,11 +484,11 @@ public class FluidUtil
* @param side The side of the fluid that is being drained.
* @return a filled container if it was successful. returns null on failure.
*/
@Nullable
public static ItemStack tryPickUpFluid(ItemStack emptyContainer, @Nullable EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side)
@Nonnull
public static ItemStack tryPickUpFluid(@Nonnull ItemStack emptyContainer, @Nullable EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side)
{
if (emptyContainer == null || worldIn == null || pos == null) {
return null;
if (emptyContainer.func_190926_b() || worldIn == null || pos == null) {
return ItemStack.field_190927_a;
}
IBlockState state = worldIn.getBlockState(pos);
@@ -639,11 +635,11 @@ public class FluidUtil
if (liquid != null && liquid.amount > 0)
{
// check which itemstack shall be altered by the fill call
if (container.stackSize > 1)
if (container.func_190916_E() > 1)
{
// create a copy of the container and fill it
ItemStack toFill = container.copy();
toFill.stackSize = 1;
toFill.func_190920_e(1);
int filled = fluidContainer.fill(toFill, liquid, false);
if (filled > 0)
{
@@ -677,7 +673,7 @@ public class FluidUtil
tank.drain(side, filled, true);
// decrease its stacksize to accommodate the filled one (it was >1 from the check above)
container.stackSize--;
container.func_190918_g(1);
}
// just 1 empty container to fill, no special treatment needed
else
@@ -754,11 +750,11 @@ public class FluidUtil
if (drained != null && drained.amount == filled)
{
// more than 1 filled itemstack, ensure that we can insert the changed container
if (container.stackSize > 1)
if (container.func_190916_E() > 1)
{
// create a copy of the container and drain it
ItemStack toEmpty = container.copy();
toEmpty.stackSize = 1;
toEmpty.func_190920_e(1);
drained = fluidContainer.drain(toEmpty, filled, true); // modifies the container!
if(player == null || !player.worldObj.isRemote)
@@ -782,7 +778,7 @@ public class FluidUtil
tank.fill(side, drained, true);
// decrease its stacksize to accommodate the filled one (it was >1 from the check above)
container.stackSize--;
container.func_190918_g(1);
}
// itemstack of size 1, no special treatment needed
else
@@ -98,7 +98,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
@SideOnly(Side.CLIENT)
@Override
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems)
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems)
{
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values())
{
@@ -139,8 +139,9 @@ public class UniversalBucket extends Item implements IFluidContainerItem
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemstack, World world, EntityPlayer player, EnumHand hand)
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
ItemStack itemstack = player.getHeldItem(hand);
FluidStack fluidStack = getFluid(itemstack);
// empty bucket shouldn't exist, do nothing since it should be handled by the bucket event
if (fluidStack == null)
@@ -173,11 +174,11 @@ public class UniversalBucket extends Item implements IFluidContainerItem
// success!
player.addStat(StatList.getObjectUseStats(this));
itemstack.stackSize--;
itemstack.func_190918_g(1);
ItemStack emptyStack = getEmpty() != null ? getEmpty().copy() : new ItemStack(this);
// check whether we replace the item or add the empty one to the inventory
if (itemstack.stackSize <= 0)
if (itemstack.func_190926_b())
{
return ActionResult.newResult(EnumActionResult.SUCCESS, emptyStack);
}
@@ -244,7 +245,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
BlockPos pos = target.getBlockPos();
ItemStack singleBucket = emptyBucket.copy();
singleBucket.stackSize = 1;
singleBucket.func_190920_e(1);
ItemStack filledBucket = FluidUtil.tryPickUpFluid(singleBucket, event.getEntityPlayer(), world, pos, target.sideHit);
if (filledBucket != null)
@@ -285,7 +286,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
public int fill(ItemStack container, FluidStack resource, boolean doFill)
{
// has to be exactly 1, must be handled from the caller
if (container.stackSize != 1)
if (container.func_190916_E() != 1)
{
return 0;
}
@@ -342,7 +343,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain)
{
// has to be exactly 1, must be handled from the caller
if (container.stackSize != 1)
if (container.func_190916_E() != 1)
{
return null;
}
@@ -361,7 +362,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
container.deserializeNBT(getEmpty().serializeNBT());
}
else {
container.stackSize = 0;
container.func_190920_e(0);
}
}
@@ -90,7 +90,7 @@ public class FluidHandlerItemStack implements IFluidHandler, ICapabilityProvider
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (container.stackSize != 1 || resource == null || resource.amount <= 0 || !canFillFluidType(resource))
if (container.func_190916_E() != 1 || resource == null || resource.amount <= 0 || !canFillFluidType(resource))
{
return 0;
}
@@ -130,7 +130,7 @@ public class FluidHandlerItemStack implements IFluidHandler, ICapabilityProvider
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null || resource.amount <= 0 || !resource.isFluidEqual(getFluid()))
if (container.func_190916_E() != 1 || resource == null || resource.amount <= 0 || !resource.isFluidEqual(getFluid()))
{
return null;
}
@@ -140,7 +140,7 @@ public class FluidHandlerItemStack implements IFluidHandler, ICapabilityProvider
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1 || maxDrain <= 0)
if (container.func_190916_E() != 1 || maxDrain <= 0)
{
return null;
}
@@ -219,7 +219,7 @@ public class FluidHandlerItemStack implements IFluidHandler, ICapabilityProvider
protected void setContainerToEmpty()
{
super.setContainerToEmpty();
container.stackSize--;
container.func_190918_g(1);
}
}
@@ -88,7 +88,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandler, ICapabilityPr
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (container.stackSize != 1 || resource == null || resource.amount <= 0 || !canFillFluidType(resource))
if (container.func_190916_E() != 1 || resource == null || resource.amount <= 0 || !canFillFluidType(resource))
{
return 0;
}
@@ -114,7 +114,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandler, ICapabilityPr
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null || resource.amount <= 0 || !resource.isFluidEqual(getFluid()))
if (container.func_190916_E() != 1 || resource == null || resource.amount <= 0 || !resource.isFluidEqual(getFluid()))
{
return null;
}
@@ -124,7 +124,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandler, ICapabilityPr
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1 || maxDrain <= 0)
if (container.func_190916_E() != 1 || maxDrain <= 0)
{
return null;
}
@@ -196,7 +196,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandler, ICapabilityPr
protected void setContainerToEmpty()
{
super.setContainerToEmpty();
container.stackSize--;
container.func_190918_g(1);
}
}
@@ -119,7 +119,7 @@ public class FluidBucketWrapper implements IFluidHandler, ICapabilityProvider
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (container.stackSize != 1 || resource == null || resource.amount < Fluid.BUCKET_VOLUME || container.getItem() instanceof ItemBucketMilk || getFluid() != null || !canFillFluidType(resource))
if (container.func_190916_E() != 1 || resource == null || resource.amount < Fluid.BUCKET_VOLUME || container.getItem() instanceof ItemBucketMilk || getFluid() != null || !canFillFluidType(resource))
{
return 0;
}
@@ -136,7 +136,7 @@ public class FluidBucketWrapper implements IFluidHandler, ICapabilityProvider
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null || resource.amount < Fluid.BUCKET_VOLUME)
if (container.func_190916_E() != 1 || resource == null || resource.amount < Fluid.BUCKET_VOLUME)
{
return null;
}
@@ -158,7 +158,7 @@ public class FluidBucketWrapper implements IFluidHandler, ICapabilityProvider
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1 || maxDrain < Fluid.BUCKET_VOLUME)
if (container.func_190916_E() != 1 || maxDrain < Fluid.BUCKET_VOLUME)
{
return null;
}
@@ -55,7 +55,7 @@ public class FluidContainerItemWrapper implements IFluidHandler, ICapabilityProv
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (container.stackSize != 1)
if (container.func_190916_E() != 1)
{
return 0;
}
@@ -65,7 +65,7 @@ public class FluidContainerItemWrapper implements IFluidHandler, ICapabilityProv
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null)
if (container.func_190916_E() != 1 || resource == null)
{
return null;
}
@@ -84,7 +84,7 @@ public class FluidContainerItemWrapper implements IFluidHandler, ICapabilityProv
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1)
if (container.func_190916_E() != 1)
{
return null;
}
@@ -58,7 +58,7 @@ public class FluidContainerRegistryWrapper implements IFluidHandler, ICapability
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (container.stackSize != 1 || resource == null)
if (container.func_190916_E() != 1 || resource == null)
{
return 0;
}
@@ -87,7 +87,7 @@ public class FluidContainerRegistryWrapper implements IFluidHandler, ICapability
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null)
if (container.func_190916_E() != 1 || resource == null)
{
return null;
}
@@ -105,7 +105,7 @@ public class FluidContainerRegistryWrapper implements IFluidHandler, ICapability
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1)
if (container.func_190916_E() != 1)
{
return null;
}
@@ -122,7 +122,7 @@ public class FluidContainerRegistryWrapper implements IFluidHandler, ICapability
{
if (FluidContainerRegistry.hasNullEmptyContainer(container))
{
emptyContainer.stackSize = 0;
emptyContainer.func_190920_e(0);
}
container.deserializeNBT(emptyContainer.serializeNBT());
}