mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 19:15:32 +00:00
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:
1 parent
ee82341312
commit
206a21d563
21 files changed
+149
-159
No files matched your search
@@ -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
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user