Fixed NPE if fluid blockID is null when using a fluid bucket
This commit is contained in:
parent
6c93020dea
commit
ea176da493
1 changed files with 219 additions and 219 deletions
|
@ -13,6 +13,7 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.Event;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import net.minecraftforge.fluids.BlockFluidFinite;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.TabRI;
|
||||
|
@ -22,11 +23,9 @@ import calclavia.lib.utility.LanguageUtility;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Modified version of the MC bucket to meet the needs of a dynamic fluid registry system
|
||||
/** Modified version of the MC bucket to meet the needs of a dynamic fluid registry system
|
||||
*
|
||||
* @author Darkguardsman
|
||||
*/
|
||||
* @author Darkguardsman */
|
||||
public class ItemOreResourceBucket extends Item
|
||||
{
|
||||
final boolean isMolten;
|
||||
|
@ -64,16 +63,20 @@ public class ItemOreResourceBucket extends Item
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack,
|
||||
* world, entityPlayer
|
||||
*/
|
||||
/** Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack,
|
||||
* world, entityPlayer */
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
|
||||
{
|
||||
String materialName = ResourceGenerator.getName(itemStack.getItemDamage());
|
||||
int fluidID = isMolten ? ResourceGenerator.getMolten(materialName).blockID : ResourceGenerator.getMixture(materialName).blockID;
|
||||
if (materialName != null)
|
||||
{
|
||||
BlockFluidFinite molten_block = ResourceGenerator.getMolten(materialName);
|
||||
BlockFluidFinite mix_block = ResourceGenerator.getMixture(materialName);
|
||||
int fluidID = isMolten ? molten_block != null ? molten_block.blockID : 0 : mix_block != null ? mix_block.blockID : 0;
|
||||
|
||||
if (fluidID > 0)
|
||||
{
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, entityPlayer, false);
|
||||
|
||||
if (movingobjectposition == null)
|
||||
|
@ -218,14 +221,13 @@ public class ItemOreResourceBucket extends Item
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to place the liquid contained inside the bucket.
|
||||
*/
|
||||
/** Attempts to place the liquid contained inside the bucket. */
|
||||
public boolean tryPlaceContainedLiquid(World world, int x, int y, int z, int fluidID)
|
||||
{
|
||||
if (fluidID <= 0)
|
||||
|
@ -281,9 +283,7 @@ public class ItemOreResourceBucket extends Item
|
|||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack itemStack, int par2)
|
||||
{
|
||||
/**
|
||||
* Auto-color based on the texture of the ingot.
|
||||
*/
|
||||
/** Auto-color based on the texture of the ingot. */
|
||||
String name = ItemOreResource.getMaterialFromStack(itemStack);
|
||||
return ResourceGenerator.getColor(name);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue