0 errors. Everything seems to run at least

This commit is contained in:
Adubbz 2016-03-15 17:53:54 +11:00
parent f2998d6182
commit 41bbf12ad4
14 changed files with 190 additions and 140 deletions

View file

@ -20,6 +20,10 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.SoundEvents; import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.network.play.server.SPacketChangeGameState; import net.minecraft.network.play.server.SPacketChangeGameState;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
@ -32,6 +36,7 @@ import net.minecraft.world.World;
public class EntityDart extends EntityArrow public class EntityDart extends EntityArrow
{ {
private static final DataParameter<Byte> TYPE = EntityDataManager.<Byte>createKey(EntityDart.class, DataSerializers.BYTE);
private int ticksInAir = 0; private int ticksInAir = 0;
@ -40,9 +45,9 @@ public class EntityDart extends EntityArrow
super(world); super(world);
} }
public EntityDart(World world, EntityLivingBase shootingEntity, float velocity) public EntityDart(World world, EntityLivingBase shootingEntity)
{ {
super(world, shootingEntity, velocity); super(world, shootingEntity);
} }
public EntityDart(World world, double x, double y, double z) public EntityDart(World world, double x, double y, double z)
@ -53,17 +58,17 @@ public class EntityDart extends EntityArrow
@Override @Override
protected void entityInit() protected void entityInit()
{ {
this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); this.dataWatcher.register(TYPE, Byte.valueOf((byte)0));
} }
public void setDartType(ItemDart.DartType dartType) public void setDartType(ItemDart.DartType dartType)
{ {
dataWatcher.updateObject(16, (byte)dartType.ordinal()); dataWatcher.set(TYPE, (byte)dartType.ordinal());
} }
public ItemDart.DartType getDartType() public ItemDart.DartType getDartType()
{ {
return ItemDart.DartType.values()[dataWatcher.getWatchableObjectByte(16)]; return ItemDart.DartType.values()[dataWatcher.get(TYPE)];
} }
// TODO: read/write to NBT? // TODO: read/write to NBT?
@ -72,7 +77,7 @@ public class EntityDart extends EntityArrow
// Called from onUpdate when it is detected that the dart has hit a solid block // Called from onUpdate when it is detected that the dart has hit a solid block
public void onHitSolidBlock() public void onHitSolidBlock()
{ {
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); this.playSound(SoundEvents.entity_arrow_hit, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
int itemId = Item.getIdFromItem(BOPItems.dart); int itemId = Item.getIdFromItem(BOPItems.dart);
int itemMeta = this.getDartType().ordinal(); int itemMeta = this.getDartType().ordinal();
for (int i = 0; i < 16; ++i) for (int i = 0; i < 16; ++i)
@ -92,7 +97,7 @@ public class EntityDart extends EntityArrow
{ {
if (entityHit instanceof EntityLivingBase) if (entityHit instanceof EntityLivingBase)
{ {
((EntityLivingBase)entityHit).addPotionEffect(new PotionEffect(BOPPotions.paralysis.id, 100)); ((EntityLivingBase)entityHit).addPotionEffect(new PotionEffect(BOPPotions.paralysis, 100));
} }
} }
@ -262,4 +267,10 @@ public class EntityDart extends EntityArrow
this.setPosition(this.posX, this.posY, this.posZ); this.setPosition(this.posX, this.posY, this.posZ);
this.doBlockCollisions(); this.doBlockCollisions();
} }
@Override
protected ItemStack getArrowStack()
{
return new ItemStack(BOPItems.dart);
}
} }

View file

@ -124,6 +124,7 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.MobEffects; import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.Item.ToolMaterial;
@ -140,6 +141,7 @@ import net.minecraft.item.ItemSword;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLCommonHandler;
@ -213,16 +215,16 @@ public class ModItems
// DIAMOND("diamond", 33, new int[]{3, 8, 6, 3}, 10); // DIAMOND("diamond", 33, new int[]{3, 8, 6, 3}, 10);
// TODO: do we really want durability of -1 for these unprotective armor items? does that mean it lasts forever? // TODO: do we really want durability of -1 for these unprotective armor items? does that mean it lasts forever?
wading_boots_material = EnumHelper.addArmorMaterial("WADING_BOOTS", "biomesoplenty:wading_boots", -1, new int[]{0,0,0,0}, 0); wading_boots_material = addArmorMaterial("WADING_BOOTS", "biomesoplenty:wading_boots", -1, new int[]{0,0,0,0}, 0);
flippers_material = EnumHelper.addArmorMaterial("FLIPPERS", "biomesoplenty:flippers", -1, new int[]{0,0,0,0}, 0); flippers_material = addArmorMaterial("FLIPPERS", "biomesoplenty:flippers", -1, new int[]{0,0,0,0}, 0);
plain_flower_band_material = EnumHelper.addArmorMaterial("PLAIN_FLOWER_BAND", "biomesoplenty:plain_flower_band", -1, new int[]{0,0,0,0}, 0); plain_flower_band_material = addArmorMaterial("PLAIN_FLOWER_BAND", "biomesoplenty:plain_flower_band", -1, new int[]{0,0,0,0}, 0);
lush_flower_band_material = EnumHelper.addArmorMaterial("LUSH_FLOWER_BAND", "biomesoplenty:lush_flower_band", -1, new int[]{0,0,0,0}, 0); lush_flower_band_material = addArmorMaterial("LUSH_FLOWER_BAND", "biomesoplenty:lush_flower_band", -1, new int[]{0,0,0,0}, 0);
exotic_flower_band_material = EnumHelper.addArmorMaterial("EXOTIC_FLOWER_BAND", "biomesoplenty:exotic_flower_band", -1, new int[]{0,0,0,0}, 0); exotic_flower_band_material = addArmorMaterial("EXOTIC_FLOWER_BAND", "biomesoplenty:exotic_flower_band", -1, new int[]{0,0,0,0}, 0);
dull_flower_band_material = EnumHelper.addArmorMaterial("DULL_FLOWER_BAND", "biomesoplenty:dull_flower_band", -1, new int[]{0,0,0,0}, 0); dull_flower_band_material = addArmorMaterial("DULL_FLOWER_BAND", "biomesoplenty:dull_flower_band", -1, new int[]{0,0,0,0}, 0);
mud_armor_material = EnumHelper.addArmorMaterial("MUD", "biomesoplenty:mud_armor", 2, new int[]{1,1,1,1}, 5); mud_armor_material = addArmorMaterial("MUD", "biomesoplenty:mud_armor", 2, new int[]{1,1,1,1}, 5);
mud_armor_material.customCraftingMaterial = mudball; mud_armor_material.customCraftingMaterial = mudball;
amethyst_armor_material = EnumHelper.addArmorMaterial("AMETHYST", "biomesoplenty:amethyst_armor", 40, new int[]{3,8,8,3}, 20); amethyst_armor_material = addArmorMaterial("AMETHYST", "biomesoplenty:amethyst_armor", 40, new int[]{3,8,8,3}, 20);
wading_boots = registerItem(new ItemWadingBoots(wading_boots_material, 0), "wading_boots"); wading_boots = registerItem(new ItemWadingBoots(wading_boots_material, 0), "wading_boots");
flippers = registerItem(new ItemFlippers(flippers_material, 0), "flippers"); flippers = registerItem(new ItemFlippers(flippers_material, 0), "flippers");
@ -250,9 +252,9 @@ public class ModItems
// IRON(2, 250, 6.0F, 2.0F, 14), // IRON(2, 250, 6.0F, 2.0F, 14),
// EMERALD(3, 1561, 8.0F, 3.0F, 10), // EMERALD(3, 1561, 8.0F, 3.0F, 10),
// GOLD(0, 32, 12.0F, 0.0F, 22); // GOLD(0, 32, 12.0F, 0.0F, 22);
mud_tool_material = EnumHelper.addToolMaterial("MUD", 0, 32, 0.5F, 0.0F, 1); mud_tool_material = /*TODO: 1.9 EnumHelper.addToolMaterial("MUD", 0, 32, 0.5F, 0.0F, 1)*/ToolMaterial.DIAMOND;
mud_tool_material.setRepairItem(new ItemStack(mudball)); //TODO: 1.9 mud_tool_material.setRepairItem(new ItemStack(mudball));
amethyst_tool_material = EnumHelper.addToolMaterial("AMETHYST", 4, 2013, 15.0F, 5.0F, 16); amethyst_tool_material = /*TODO: 1.9 EnumHelper.addToolMaterial("AMETHYST", 4, 2013, 15.0F, 5.0F, 16)*/ToolMaterial.DIAMOND;
// no repair item for amethyst tool - they can't be repaired // no repair item for amethyst tool - they can't be repaired
// ItemAxe and ItemPickaxe have protected constructors - use reflection to construct // ItemAxe and ItemPickaxe have protected constructors - use reflection to construct
@ -342,4 +344,14 @@ public class ModItems
return item; return item;
} }
private static ItemArmor.ArmorMaterial addArmorMaterial(String name, String textureName, int durability, int[] reductionAmounts, int enchantability, SoundEvent event)
{
//TODO: 1.9
return ItemArmor.ArmorMaterial.IRON;
}
private static ItemArmor.ArmorMaterial addArmorMaterial(String name, String textureName, int durability, int[] reductionAmounts, int enchantability)
{
return ModItems.addArmorMaterial(name, textureName, durability, reductionAmounts, enchantability, SoundEvents.item_armor_equip_generic);
}
} }

View file

@ -17,6 +17,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList; import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -31,13 +34,13 @@ public class ItemBOPLilypad extends ItemBOPBlock {
// (usually when you point the cursor at water the picked block is whatever is underneath the water - when placing lilies the water itself has to be picked) // (usually when you point the cursor at water the picked block is whatever is underneath the water - when placing lilies the water itself has to be picked)
// The below is copied from vanille BlockLilyPad // The below is copied from vanille BlockLilyPad
@Override @Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{ {
RayTraceResult movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true); RayTraceResult movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);
if (movingobjectposition == null) if (movingobjectposition == null)
{ {
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
} }
else else
{ {
@ -47,18 +50,18 @@ public class ItemBOPLilypad extends ItemBOPBlock {
if (!worldIn.isBlockModifiable(playerIn, blockpos)) if (!worldIn.isBlockModifiable(playerIn, blockpos))
{ {
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
} }
if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn)) if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
{ {
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
} }
BlockPos blockpos1 = blockpos.up(); BlockPos blockpos1 = blockpos.up();
IBlockState iblockstate = worldIn.getBlockState(blockpos); IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock().getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1)) if (iblockstate.getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1))
{ {
// special case for handling block placement with water lilies // special case for handling block placement with water lilies
net.minecraftforge.common.util.BlockSnapshot blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(worldIn, blockpos1); net.minecraftforge.common.util.BlockSnapshot blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(worldIn, blockpos1);
@ -67,7 +70,7 @@ public class ItemBOPLilypad extends ItemBOPBlock {
if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(playerIn, blocksnapshot, net.minecraft.util.EnumFacing.UP).isCanceled()) if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(playerIn, blocksnapshot, net.minecraft.util.EnumFacing.UP).isCanceled())
{ {
blocksnapshot.restore(true, false); blocksnapshot.restore(true, false);
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
} }
if (!playerIn.capabilities.isCreativeMode) if (!playerIn.capabilities.isCreativeMode)
@ -79,7 +82,7 @@ public class ItemBOPLilypad extends ItemBOPBlock {
} }
} }
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
} }
} }

View file

@ -18,7 +18,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList; import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ItemBOPPlant extends ItemBOPBlock { public class ItemBOPPlant extends ItemBOPBlock {
@ -30,7 +34,7 @@ public class ItemBOPPlant extends ItemBOPBlock {
// The code for right clicking needs to be overridden to handle the unique way reeds are placed - on top of the water // The code for right clicking needs to be overridden to handle the unique way reeds are placed - on top of the water
// (usually when you point the cursor at water the picked block is whatever is underneath the water - when placing reeds the water itself has to be picked) // (usually when you point the cursor at water the picked block is whatever is underneath the water - when placing reeds the water itself has to be picked)
@Override @Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{ {
if (this.block instanceof BlockBOPPlant) if (this.block instanceof BlockBOPPlant)
{ {
@ -40,32 +44,32 @@ public class ItemBOPPlant extends ItemBOPBlock {
if (plant == BOPPlants.REED) if (plant == BOPPlants.REED)
{ {
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true); RayTraceResult movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);
if (movingobjectposition == null) if (movingobjectposition == null)
{ {
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
} }
else else
{ {
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) if (movingobjectposition.typeOfHit == RayTraceResult.Type.BLOCK)
{ {
BlockPos blockpos = movingobjectposition.getBlockPos(); BlockPos blockpos = movingobjectposition.getBlockPos();
if (!worldIn.isBlockModifiable(playerIn, blockpos)) if (!worldIn.isBlockModifiable(playerIn, blockpos))
{ {
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
} }
if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn)) if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
{ {
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
} }
BlockPos blockpos1 = blockpos.up(); BlockPos blockpos1 = blockpos.up();
IBlockState iblockstate = worldIn.getBlockState(blockpos); IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock().getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1)) if (iblockstate.getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1))
{ {
// special case for handling block placement with reeds // special case for handling block placement with reeds
net.minecraftforge.common.util.BlockSnapshot blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(worldIn, blockpos1); net.minecraftforge.common.util.BlockSnapshot blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(worldIn, blockpos1);
@ -74,7 +78,7 @@ public class ItemBOPPlant extends ItemBOPBlock {
if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(playerIn, blocksnapshot, net.minecraft.util.EnumFacing.UP).isCanceled()) if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(playerIn, blocksnapshot, net.minecraft.util.EnumFacing.UP).isCanceled())
{ {
blocksnapshot.restore(true, false); blocksnapshot.restore(true, false);
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
} }
if (!playerIn.capabilities.isCreativeMode) if (!playerIn.capabilities.isCreativeMode)
@ -86,7 +90,7 @@ public class ItemBOPPlant extends ItemBOPBlock {
} }
} }
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
} }
@ -94,7 +98,7 @@ public class ItemBOPPlant extends ItemBOPBlock {
} }
// in all other cases take the default action // in all other cases take the default action
return super.onItemRightClick(itemStackIn, worldIn, playerIn); return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
} }

View file

@ -8,6 +8,7 @@
package biomesoplenty.common.item; package biomesoplenty.common.item;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemRecord; import net.minecraft.item.ItemRecord;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -16,7 +17,7 @@ public class ItemBOPRecord extends ItemRecord
public ItemBOPRecord(String name) public ItemBOPRecord(String name)
{ {
super(name); super(name, SoundEvents.record_11);
} }
@Override @Override

View file

@ -68,12 +68,12 @@ public class ItemBOPScythe extends Item
@Override @Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn) public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving)
{ {
if (blockIn == null || worldIn.getBlockState(pos).getBlock() == Blocks.air) {return false;} if (state.getBlock() == null || worldIn.getBlockState(pos).getBlock() == Blocks.air) {return false;}
boolean isLeaves = blockIn.isLeaves(worldIn, pos); boolean isLeaves = state.getBlock().isLeaves(worldIn.getBlockState(pos), worldIn, pos);
int radius = isLeaves ? 0 : 3; int radius = isLeaves ? 0 : 3;
int height = isLeaves ? 0 : 4; int height = isLeaves ? 0 : 4;
@ -94,22 +94,22 @@ public class ItemBOPScythe extends Item
} }
// automatically damage the item once - for the block originally destroyed // automatically damage the item once - for the block originally destroyed
stack.damageItem(1, playerIn); stack.damageItem(1, entityLiving);
int numberTrimmed = 0; int numberTrimmed = 0;
if (isLeaves) if (isLeaves)
{ {
numberTrimmed += trim(stack, playerIn, worldIn, pos, height, radius, TrimType.TRIM_LEAVES, false, 40); numberTrimmed += trim(stack, entityLiving, worldIn, pos, height, radius, TrimType.TRIM_LEAVES, false, 40);
} }
else else
{ {
// trim once with the corners cut // trim once with the corners cut
numberTrimmed += trim(stack, playerIn, worldIn, pos, height, radius, TrimType.TRIM_GRASS_AND_FLOWERS, true, 70); numberTrimmed += trim(stack, entityLiving, worldIn, pos, height, radius, TrimType.TRIM_GRASS_AND_FLOWERS, true, 70);
if (worldIn.rand.nextInt(3) == 0) if (worldIn.rand.nextInt(3) == 0)
{ {
// with one in 3 chance, also do another 'free' trim of a smaller radius, without the corners cut // with one in 3 chance, also do another 'free' trim of a smaller radius, without the corners cut
// ('free' in the sense that it does not damage the scythe) // ('free' in the sense that it does not damage the scythe)
numberTrimmed += trim(stack, playerIn, worldIn, pos, height, radius - 1, TrimType.TRIM_GRASS_AND_FLOWERS, false, 0); numberTrimmed += trim(stack, entityLiving, worldIn, pos, height, radius - 1, TrimType.TRIM_GRASS_AND_FLOWERS, false, 0);
} }
} }
return numberTrimmed > 0; return numberTrimmed > 0;
@ -155,7 +155,7 @@ public class ItemBOPScythe extends Item
case TRIM_LEAVES: case TRIM_LEAVES:
// remove leaves // remove leaves
if (block.isLeaves(world, pos)) if (block.isLeaves(state, world, pos))
{ {
block.dropBlockAsItem(world, pos, state, fortune); block.dropBlockAsItem(world, pos, state, fortune);
world.setBlockToAir(pos); world.setBlockToAir(pos);

View file

@ -29,9 +29,13 @@ import net.minecraft.stats.StatList;
import net.minecraft.tileentity.MobSpawnerBaseLogic; import net.minecraft.tileentity.MobSpawnerBaseLogic;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityMobSpawner; import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -54,7 +58,7 @@ public class ItemBOPSpawnEgg extends Item
while (iterator.hasNext()) while (iterator.hasNext())
{ {
EntityList.EntityEggInfo entityegginfo = (EntityList.EntityEggInfo)iterator.next(); EntityList.EntityEggInfo entityegginfo = (EntityList.EntityEggInfo)iterator.next();
subItems.add(new ItemStack(itemIn, 1, entityegginfo.spawnedID)); subItems.add(new ItemStack(itemIn, 1, EntityList.getIDFromString(entityegginfo.spawnedID)));
} }
} }
@ -87,23 +91,15 @@ public class ItemBOPSpawnEgg extends Item
} }
@Override @Override
@SideOnly(Side.CLIENT) public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
public int getColorFromItemStack(ItemStack stack, int renderPass)
{
EntityList.EntityEggInfo entityegginfo = ModEntities.entityEggs.get(Integer.valueOf(stack.getMetadata()));
return entityegginfo != null ? (renderPass == 0 ? entityegginfo.primaryColor : entityegginfo.secondaryColor) : 16777215;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{ {
if (worldIn.isRemote) if (worldIn.isRemote)
{ {
return true; return EnumActionResult.SUCCESS;
} }
else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack)) else if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack))
{ {
return false; return EnumActionResult.FAIL;
} }
else else
{ {
@ -116,23 +112,23 @@ public class ItemBOPSpawnEgg extends Item
if (tileentity instanceof TileEntityMobSpawner) if (tileentity instanceof TileEntityMobSpawner)
{ {
MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic(); MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
mobspawnerbaselogic.setEntityName(EntityList.getStringFromID(stack.getMetadata())); mobspawnerbaselogic.setEntityName(EntityList.classToStringMapping.get(EntityList.getClassFromID(stack.getMetadata())));
tileentity.markDirty(); tileentity.markDirty();
worldIn.markBlockForUpdate(pos); worldIn.notifyBlockUpdate(pos, iblockstate, iblockstate, 3);
if (!playerIn.capabilities.isCreativeMode) if (!playerIn.capabilities.isCreativeMode)
{ {
--stack.stackSize; --stack.stackSize;
} }
return true; return EnumActionResult.SUCCESS;
} }
} }
pos = pos.offset(side); pos = pos.offset(facing);
double d0 = 0.0D; double d0 = 0.0D;
if (side == EnumFacing.UP && iblockstate instanceof BlockFence) if (facing == EnumFacing.UP && iblockstate instanceof BlockFence)
{ {
d0 = 0.5D; d0 = 0.5D;
} }
@ -152,63 +148,63 @@ public class ItemBOPSpawnEgg extends Item
} }
} }
return true; return EnumActionResult.SUCCESS;
} }
} }
@Override @Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{ {
if (worldIn.isRemote) if (world.isRemote)
{ {
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
} }
else else
{ {
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true); RayTraceResult movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true);
if (movingobjectposition == null) if (movingobjectposition == null)
{ {
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
} }
else else
{ {
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) if (movingobjectposition.typeOfHit == RayTraceResult.Type.BLOCK)
{ {
BlockPos blockpos = movingobjectposition.getBlockPos(); BlockPos blockpos = movingobjectposition.getBlockPos();
if (!worldIn.isBlockModifiable(playerIn, blockpos)) if (!world.isBlockModifiable(player, blockpos))
{ {
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
} }
if (!playerIn.canPlayerEdit(blockpos, movingobjectposition.sideHit, itemStackIn)) if (!player.canPlayerEdit(blockpos, movingobjectposition.sideHit, stack))
{ {
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
} }
if (worldIn.getBlockState(blockpos).getBlock() instanceof BlockLiquid) if (world.getBlockState(blockpos).getBlock() instanceof BlockLiquid)
{ {
Entity entity = spawnBOPCreature(worldIn, itemStackIn.getMetadata(), (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D); Entity entity = spawnBOPCreature(world, stack.getMetadata(), (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D);
if (entity != null) if (entity != null)
{ {
if (entity instanceof EntityLivingBase && itemStackIn.hasDisplayName()) if (entity instanceof EntityLivingBase && stack.hasDisplayName())
{ {
((EntityLiving)entity).setCustomNameTag(itemStackIn.getDisplayName()); ((EntityLiving)entity).setCustomNameTag(stack.getDisplayName());
} }
if (!playerIn.capabilities.isCreativeMode) if (!player.capabilities.isCreativeMode)
{ {
--itemStackIn.stackSize; --stack.stackSize;
} }
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); //TODO: 1.9 playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
} }
} }
} }
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
} }
} }
} }

View file

@ -12,8 +12,13 @@ package biomesoplenty.common.item;
import biomesoplenty.api.item.BOPItems; import biomesoplenty.api.item.BOPItems;
import biomesoplenty.common.entities.projectiles.EntityDart; import biomesoplenty.common.entities.projectiles.EntityDart;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -25,19 +30,19 @@ public class ItemDartBlower extends Item
this.maxStackSize = 1; this.maxStackSize = 1;
this.setMaxDamage(63); this.setMaxDamage(63);
} }
@Override @Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{ {
if (worldIn.isRemote) {return itemStackIn;} if (world.isRemote) {return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);}
boolean isCreative = playerIn.capabilities.isCreativeMode; boolean isCreative = player.capabilities.isCreativeMode;
// look for the best dart in inventory - find out which slot it's in // look for the best dart in inventory - find out which slot it's in
int bestDartSlot = -1; int bestDartSlot = -1;
ItemDart.DartType bestAvailableDartType = ItemDart.DartType.DART; ItemDart.DartType bestAvailableDartType = ItemDart.DartType.DART;
for (int k = 0; k < playerIn.inventory.mainInventory.length; ++k) for (int k = 0; k < player.inventory.mainInventory.length; ++k)
{ {
ItemStack current = playerIn.inventory.mainInventory[k]; ItemStack current = player.inventory.mainInventory[k];
if (current != null && current.getItem()==BOPItems.dart) if (current != null && current.getItem()==BOPItems.dart)
{ {
ItemDart.DartType currentDartType = ItemDart.DartType.fromMeta(current.getMetadata()); ItemDart.DartType currentDartType = ItemDart.DartType.fromMeta(current.getMetadata());
@ -52,18 +57,18 @@ public class ItemDartBlower extends Item
if (isCreative || (bestDartSlot > -1)) if (isCreative || (bestDartSlot > -1))
{ {
// there is a dart available to blow - blow it. // there is a dart available to blow - blow it.
EntityDart entityDart = new EntityDart(worldIn, playerIn, 1.0F); EntityDart entityDart = new EntityDart(world, player);
entityDart.setDartType(bestAvailableDartType); entityDart.setDartType(bestAvailableDartType);
if (!isCreative) if (!isCreative)
{ {
itemStackIn.damageItem(1, playerIn); stack.damageItem(1, player);
playerIn.inventory.decrStackSize(bestDartSlot, 1); player.inventory.decrStackSize(bestDartSlot, 1);
} }
worldIn.spawnEntityInWorld(entityDart); world.spawnEntityInWorld(entityDart);
worldIn.playSoundAtEntity(playerIn, "random.bow", 1.0F, 1.75F); world.playSound(player, player.getPosition(), SoundEvents.entity_arrow_shoot, SoundCategory.NEUTRAL, 1.0F, 1.75F);
} }
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
} }

View file

@ -9,10 +9,18 @@
package biomesoplenty.common.item; package biomesoplenty.common.item;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ItemEnderporter extends Item { public class ItemEnderporter extends Item {
@ -22,34 +30,34 @@ public class ItemEnderporter extends Item {
this.maxStackSize = 1; this.maxStackSize = 1;
this.setMaxDamage(9); this.setMaxDamage(9);
} }
@Override @Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{ {
if (player.ridingEntity != null) {return stack;} if (player.getRidingEntity() != null) {return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);}
// can only use the enderporter on the surface world // can only use the enderporter on the surface world
if (world.provider.isSurfaceWorld()) if (world.provider.isSurfaceWorld())
{ {
stack.damageItem(1, player); stack.damageItem(1, player);
player.addPotionEffect(new PotionEffect(Potion.blindness.id, 30, 999)); player.addPotionEffect(new PotionEffect(MobEffects.blindness, 30, 999));
player.addPotionEffect(new PotionEffect(Potion.resistance.id, 200, 999)); player.addPotionEffect(new PotionEffect(MobEffects.resistance, 200, 999));
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 100, 999)); player.addPotionEffect(new PotionEffect(MobEffects.nightVision, 100, 999));
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, 3)); player.addPotionEffect(new PotionEffect(MobEffects.regeneration, 200, 3));
player.setPosition((double)world.getSpawnPoint().getX(), 250, (double)world.getSpawnPoint().getZ()); player.setPosition((double)world.getSpawnPoint().getX(), 250, (double)world.getSpawnPoint().getZ());
world.playSoundAtEntity(player, "random.levelup", 1.0F, 5.0F); world.playSound(player, player.getPosition(), SoundEvents.entity_player_levelup, SoundCategory.NEUTRAL, 1.0F, 5.0F);
//TODO: FEATURE par3EntityPlayer.addStat(BOPAchievements.achEnderporter, 1); //TODO: FEATURE par3EntityPlayer.addStat(BOPAchievements.achEnderporter, 1);
} }
else else
{ {
// have the server inform the client that they can't use the enderporter // have the server inform the client that they can't use the enderporter
if (!world.isRemote) if (!world.isRemote)
{ {
ChatComponentText msg = new ChatComponentText(StatCollector.translateToLocal("enderporter.prevent")); TextComponentTranslation msg = new TextComponentTranslation("enderporter.prevent");
msg.getChatStyle().setColor(EnumChatFormatting.DARK_PURPLE); msg.getChatStyle().setColor(TextFormatting.DARK_PURPLE);
player.addChatMessage(msg); player.addChatMessage(msg);
} }
} }
return stack; return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
} }

View file

@ -1,5 +1,6 @@
package biomesoplenty.common.item; package biomesoplenty.common.item;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor;
public class ItemFlippers extends ItemArmor public class ItemFlippers extends ItemArmor
@ -8,7 +9,7 @@ public class ItemFlippers extends ItemArmor
public ItemFlippers(ItemArmor.ArmorMaterial material, int renderIndex) public ItemFlippers(ItemArmor.ArmorMaterial material, int renderIndex)
{ {
// flippers are always on your feet - armorType = 3 // flippers are always on your feet - armorType = 3
super(material, renderIndex, 3); super(material, renderIndex, EntityEquipmentSlot.FEET);
} }
} }

View file

@ -17,6 +17,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.IShearable; import net.minecraftforge.common.IShearable;
@ -27,9 +30,9 @@ public class ItemFlowerBasket extends Item
{ {
this.maxStackSize = 1; this.maxStackSize = 1;
} }
@Override @Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{ {
if (!world.isRemote) if (!world.isRemote)
{ {
@ -44,7 +47,7 @@ public class ItemFlowerBasket extends Item
player.openGui(BiomesOPlenty.instance, GuiHandler.FLOWER_BASKET_ID, world, 0, 0, 0); player.openGui(BiomesOPlenty.instance, GuiHandler.FLOWER_BASKET_ID, world, 0, 0, 0);
} }
return stack; return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
} }
public static ItemStack findBasketStack(EntityPlayer player) public static ItemStack findBasketStack(EntityPlayer player)

View file

@ -18,7 +18,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList; import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
@ -30,18 +34,18 @@ public class ItemJarEmpty extends Item
{ {
this.setMaxDamage(0); this.setMaxDamage(0);
} }
@Override @Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{ {
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true); RayTraceResult hit = this.getMovingObjectPositionFromPlayer(world, player, true);
if (hit == null) {return stack;} if (hit == null) {new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);}
if (hit.typeOfHit != MovingObjectType.BLOCK) {return stack;} if (hit.typeOfHit != RayTraceResult.Type.BLOCK) {new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);}
BlockPos pos = hit.getBlockPos(); BlockPos pos = hit.getBlockPos();
if (!world.isBlockModifiable(player, pos)) {return stack;} if (!world.isBlockModifiable(player, pos)) {new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);}
if (!player.canPlayerEdit(pos, hit.sideHit, stack)) {return stack;} if (!player.canPlayerEdit(pos, hit.sideHit, stack)) {new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);}
// determine if the block is one of our BOP fluids // determine if the block is one of our BOP fluids
// note - no need to check level - you don't get a hit unless it's full // note - no need to check level - you don't get a hit unless it's full
@ -61,13 +65,13 @@ public class ItemJarEmpty extends Item
{ {
world.setBlockToAir(pos); world.setBlockToAir(pos);
--stack.stackSize; --stack.stackSize;
player.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); //TODO: 1.9 player.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
ItemStack honeyJar = new ItemStack(BOPItems.jar_filled, 1, jarContents.ordinal()); ItemStack honeyJar = new ItemStack(BOPItems.jar_filled, 1, jarContents.ordinal());
// if there was only one empty jar in the stack, replace it, otherwise add the filledJar elsewhere in the inventory // if there was only one empty jar in the stack, replace it, otherwise add the filledJar elsewhere in the inventory
if (stack.stackSize <= 0) if (stack.stackSize <= 0)
{ {
return honeyJar; return new ActionResult<ItemStack>(EnumActionResult.FAIL, honeyJar);
} }
else if (!player.inventory.addItemStackToInventory(honeyJar)) else if (!player.inventory.addItemStackToInventory(honeyJar))
{ {
@ -75,12 +79,12 @@ public class ItemJarEmpty extends Item
player.dropPlayerItemWithRandomChoice(honeyJar, false); player.dropPlayerItemWithRandomChoice(honeyJar, false);
} }
} }
return stack; return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
} }
@Override @Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase target) public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase target, EnumHand hand)
{ {
// right clicking a pixie with an empty jar catches it in the jar // right clicking a pixie with an empty jar catches it in the jar
if (target instanceof EntityPixie) if (target instanceof EntityPixie)

View file

@ -15,8 +15,7 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.*;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
@ -136,9 +135,9 @@ public class ItemJarFilled extends Item
@Override @Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{ {
if (world.isRemote) {return stack;} if (world.isRemote) {return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);}
switch (this.getContentsType(stack)) switch (this.getContentsType(stack))
{ {
// right click in air releases pixie // right click in air releases pixie
@ -149,18 +148,18 @@ public class ItemJarFilled extends Item
Vec3d releasePoint = this.getAirPositionInFrontOfPlayer(world, player, 0.8D); Vec3d releasePoint = this.getAirPositionInFrontOfPlayer(world, player, 0.8D);
this.releasePixie(stack, world, player, releasePoint); this.releasePixie(stack, world, player, releasePoint);
} }
return stack; return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
case HONEY: case POISON: default: case HONEY: case POISON: default:
return stack; return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
} }
} }
@Override @Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{ {
if (world.isRemote) {return false;} if (world.isRemote) {return EnumActionResult.FAIL;}
switch (this.getContentsType(stack)) switch (this.getContentsType(stack))
{ {
// right click on block also releases pixie // right click on block also releases pixie
@ -170,11 +169,11 @@ public class ItemJarFilled extends Item
double distZ = hitZ - player.posZ; double distZ = hitZ - player.posZ;
double a = 0.9D; double a = 0.9D;
Vec3d releasePoint = new Vec3d(player.posX + a * distX, player.posY + (double)player.getEyeHeight() + a * distY, player.posZ + a * distZ); Vec3d releasePoint = new Vec3d(player.posX + a * distX, player.posY + (double)player.getEyeHeight() + a * distY, player.posZ + a * distZ);
return this.releasePixie(stack, world, player, releasePoint); return this.releasePixie(stack, world, player, releasePoint) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
// TODO: are you supposed to be able to pour out honey? How much should you get? Why don't we just use buckets? // TODO: are you supposed to be able to pour out honey? How much should you get? Why don't we just use buckets?
case HONEY: case POISON: default: case HONEY: case POISON: default:
return false; return EnumActionResult.SUCCESS;
} }
} }

View file

@ -14,6 +14,9 @@ import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList; import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -26,21 +29,21 @@ public class ItemMudball extends Item
// throw a mudball on right click // throw a mudball on right click
@Override @Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{ {
if (!playerIn.capabilities.isCreativeMode) if (!player.capabilities.isCreativeMode)
{ {
--itemStackIn.stackSize; --stack.stackSize;
} }
worldIn.playSound(playerIn, playerIn.getPosition(), SoundEvents.entity_arrow_shoot, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); world.playSound(player, player.getPosition(), SoundEvents.entity_arrow_shoot, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote) if (!world.isRemote)
{ {
worldIn.spawnEntityInWorld(new EntityMudball(worldIn, playerIn)); world.spawnEntityInWorld(new EntityMudball(world, player));
} }
//TODO: playerIn.addState(StatList.objectUseStats[Item.getIdFromItem(this)]); //TODO: playerIn.addState(StatList.objectUseStats[Item.getIdFromItem(this)]);
return itemStackIn; return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
} }
} }