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.init.SoundEvents;
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.potion.PotionEffect;
import net.minecraft.util.DamageSource;
@ -32,6 +36,7 @@ import net.minecraft.world.World;
public class EntityDart extends EntityArrow
{
private static final DataParameter<Byte> TYPE = EntityDataManager.<Byte>createKey(EntityDart.class, DataSerializers.BYTE);
private int ticksInAir = 0;
@ -40,9 +45,9 @@ public class EntityDart extends EntityArrow
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)
@ -53,17 +58,17 @@ public class EntityDart extends EntityArrow
@Override
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)
{
dataWatcher.updateObject(16, (byte)dartType.ordinal());
dataWatcher.set(TYPE, (byte)dartType.ordinal());
}
public ItemDart.DartType getDartType()
{
return ItemDart.DartType.values()[dataWatcher.getWatchableObjectByte(16)];
return ItemDart.DartType.values()[dataWatcher.get(TYPE)];
}
// 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
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 itemMeta = this.getDartType().ordinal();
for (int i = 0; i < 16; ++i)
@ -92,7 +97,7 @@ public class EntityDart extends EntityArrow
{
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.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.init.Blocks;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
@ -140,6 +141,7 @@ import net.minecraft.item.ItemSword;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.FMLCommonHandler;
@ -213,16 +215,16 @@ public class ModItems
// 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?
wading_boots_material = EnumHelper.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);
plain_flower_band_material = EnumHelper.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);
exotic_flower_band_material = EnumHelper.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);
wading_boots_material = addArmorMaterial("WADING_BOOTS", "biomesoplenty:wading_boots", -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 = addArmorMaterial("PLAIN_FLOWER_BAND", "biomesoplenty:plain_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 = addArmorMaterial("EXOTIC_FLOWER_BAND", "biomesoplenty:exotic_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;
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");
flippers = registerItem(new ItemFlippers(flippers_material, 0), "flippers");
@ -250,9 +252,9 @@ public class ModItems
// IRON(2, 250, 6.0F, 2.0F, 14),
// EMERALD(3, 1561, 8.0F, 3.0F, 10),
// GOLD(0, 32, 12.0F, 0.0F, 22);
mud_tool_material = EnumHelper.addToolMaterial("MUD", 0, 32, 0.5F, 0.0F, 1);
mud_tool_material.setRepairItem(new ItemStack(mudball));
amethyst_tool_material = EnumHelper.addToolMaterial("AMETHYST", 4, 2013, 15.0F, 5.0F, 16);
mud_tool_material = /*TODO: 1.9 EnumHelper.addToolMaterial("MUD", 0, 32, 0.5F, 0.0F, 1)*/ToolMaterial.DIAMOND;
//TODO: 1.9 mud_tool_material.setRepairItem(new ItemStack(mudball));
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
// ItemAxe and ItemPickaxe have protected constructors - use reflection to construct
@ -342,4 +344,14 @@ public class ModItems
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.ItemStack;
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.RayTraceResult;
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)
// The below is copied from vanille BlockLilyPad
@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);
if (movingobjectposition == null)
{
return itemStackIn;
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
else
{
@ -47,18 +50,18 @@ public class ItemBOPLilypad extends ItemBOPBlock {
if (!worldIn.isBlockModifiable(playerIn, blockpos))
{
return itemStackIn;
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
{
return itemStackIn;
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
BlockPos blockpos1 = blockpos.up();
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
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())
{
blocksnapshot.restore(true, false);
return itemStackIn;
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
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.ItemStack;
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.RayTraceResult;
import net.minecraft.world.World;
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
// (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
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)
{
@ -40,32 +44,32 @@ public class ItemBOPPlant extends ItemBOPBlock {
if (plant == BOPPlants.REED)
{
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);
RayTraceResult movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);
if (movingobjectposition == null)
{
return itemStackIn;
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
else
{
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
if (movingobjectposition.typeOfHit == RayTraceResult.Type.BLOCK)
{
BlockPos blockpos = movingobjectposition.getBlockPos();
if (!worldIn.isBlockModifiable(playerIn, blockpos))
{
return itemStackIn;
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
{
return itemStackIn;
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
BlockPos blockpos1 = blockpos.up();
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
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())
{
blocksnapshot.restore(true, false);
return itemStackIn;
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
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
return super.onItemRightClick(itemStackIn, worldIn, playerIn);
return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
}

View File

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

View File

@ -68,12 +68,12 @@ public class ItemBOPScythe extends Item
@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 height = isLeaves ? 0 : 4;
@ -94,22 +94,22 @@ public class ItemBOPScythe extends Item
}
// automatically damage the item once - for the block originally destroyed
stack.damageItem(1, playerIn);
stack.damageItem(1, entityLiving);
int numberTrimmed = 0;
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
{
// 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)
{
// 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)
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;
@ -155,7 +155,7 @@ public class ItemBOPScythe extends Item
case TRIM_LEAVES:
// remove leaves
if (block.isLeaves(world, pos))
if (block.isLeaves(state, world, pos))
{
block.dropBlockAsItem(world, pos, state, fortune);
world.setBlockToAir(pos);

View File

@ -29,9 +29,13 @@ import net.minecraft.stats.StatList;
import net.minecraft.tileentity.MobSpawnerBaseLogic;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -54,7 +58,7 @@ public class ItemBOPSpawnEgg extends Item
while (iterator.hasNext())
{
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
@SideOnly(Side.CLIENT)
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)
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
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
{
@ -116,23 +112,23 @@ public class ItemBOPSpawnEgg extends Item
if (tileentity instanceof TileEntityMobSpawner)
{
MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
mobspawnerbaselogic.setEntityName(EntityList.getStringFromID(stack.getMetadata()));
mobspawnerbaselogic.setEntityName(EntityList.classToStringMapping.get(EntityList.getClassFromID(stack.getMetadata())));
tileentity.markDirty();
worldIn.markBlockForUpdate(pos);
worldIn.notifyBlockUpdate(pos, iblockstate, iblockstate, 3);
if (!playerIn.capabilities.isCreativeMode)
{
--stack.stackSize;
}
return true;
return EnumActionResult.SUCCESS;
}
}
pos = pos.offset(side);
pos = pos.offset(facing);
double d0 = 0.0D;
if (side == EnumFacing.UP && iblockstate instanceof BlockFence)
if (facing == EnumFacing.UP && iblockstate instanceof BlockFence)
{
d0 = 0.5D;
}
@ -152,63 +148,63 @@ public class ItemBOPSpawnEgg extends Item
}
}
return true;
return EnumActionResult.SUCCESS;
}
}
@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
{
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);
RayTraceResult movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true);
if (movingobjectposition == null)
{
return itemStackIn;
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
}
else
{
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
if (movingobjectposition.typeOfHit == RayTraceResult.Type.BLOCK)
{
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 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.common.entities.projectiles.EntityDart;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
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;
@ -27,17 +32,17 @@ public class ItemDartBlower extends Item
}
@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;}
boolean isCreative = playerIn.capabilities.isCreativeMode;
if (world.isRemote) {return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);}
boolean isCreative = player.capabilities.isCreativeMode;
// look for the best dart in inventory - find out which slot it's in
int bestDartSlot = -1;
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)
{
ItemDart.DartType currentDartType = ItemDart.DartType.fromMeta(current.getMetadata());
@ -52,18 +57,18 @@ public class ItemDartBlower extends Item
if (isCreative || (bestDartSlot > -1))
{
// 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);
if (!isCreative)
{
itemStackIn.damageItem(1, playerIn);
playerIn.inventory.decrStackSize(bestDartSlot, 1);
stack.damageItem(1, player);
player.inventory.decrStackSize(bestDartSlot, 1);
}
worldIn.spawnEntityInWorld(entityDart);
worldIn.playSoundAtEntity(playerIn, "random.bow", 1.0F, 1.75F);
world.spawnEntityInWorld(entityDart);
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;
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.ItemStack;
import net.minecraft.potion.Potion;
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;
public class ItemEnderporter extends Item {
@ -24,19 +32,19 @@ public class ItemEnderporter extends Item {
}
@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
if (world.provider.isSurfaceWorld())
{
stack.damageItem(1, player);
player.addPotionEffect(new PotionEffect(Potion.blindness.id, 30, 999));
player.addPotionEffect(new PotionEffect(Potion.resistance.id, 200, 999));
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 100, 999));
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, 3));
player.addPotionEffect(new PotionEffect(MobEffects.blindness, 30, 999));
player.addPotionEffect(new PotionEffect(MobEffects.resistance, 200, 999));
player.addPotionEffect(new PotionEffect(MobEffects.nightVision, 100, 999));
player.addPotionEffect(new PotionEffect(MobEffects.regeneration, 200, 3));
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);
}
else
@ -44,12 +52,12 @@ public class ItemEnderporter extends Item {
// have the server inform the client that they can't use the enderporter
if (!world.isRemote)
{
ChatComponentText msg = new ChatComponentText(StatCollector.translateToLocal("enderporter.prevent"));
msg.getChatStyle().setColor(EnumChatFormatting.DARK_PURPLE);
TextComponentTranslation msg = new TextComponentTranslation("enderporter.prevent");
msg.getChatStyle().setColor(TextFormatting.DARK_PURPLE);
player.addChatMessage(msg);
}
}
return stack;
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}

View File

@ -1,5 +1,6 @@
package biomesoplenty.common.item;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor;
public class ItemFlippers extends ItemArmor
@ -8,7 +9,7 @@ public class ItemFlippers extends ItemArmor
public ItemFlippers(ItemArmor.ArmorMaterial material, int renderIndex)
{
// 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.ItemStack;
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.minecraftforge.common.IPlantable;
import net.minecraftforge.common.IShearable;
@ -29,7 +32,7 @@ public class ItemFlowerBasket extends Item
}
@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)
{
@ -44,7 +47,7 @@ public class ItemFlowerBasket extends Item
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)

View File

@ -18,7 +18,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
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.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
@ -33,15 +37,15 @@ public class ItemJarEmpty extends Item
@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);
if (hit == null) {return stack;}
if (hit.typeOfHit != MovingObjectType.BLOCK) {return stack;}
RayTraceResult hit = this.getMovingObjectPositionFromPlayer(world, player, true);
if (hit == null) {new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);}
if (hit.typeOfHit != RayTraceResult.Type.BLOCK) {new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);}
BlockPos pos = hit.getBlockPos();
if (!world.isBlockModifiable(player, pos)) {return stack;}
if (!player.canPlayerEdit(pos, hit.sideHit, stack)) {return stack;}
if (!world.isBlockModifiable(player, pos)) {new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);}
if (!player.canPlayerEdit(pos, hit.sideHit, stack)) {new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);}
// 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
@ -61,13 +65,13 @@ public class ItemJarEmpty extends Item
{
world.setBlockToAir(pos);
--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());
// if there was only one empty jar in the stack, replace it, otherwise add the filledJar elsewhere in the inventory
if (stack.stackSize <= 0)
{
return honeyJar;
return new ActionResult<ItemStack>(EnumActionResult.FAIL, honeyJar);
}
else if (!player.inventory.addItemStackToInventory(honeyJar))
{
@ -76,11 +80,11 @@ public class ItemJarEmpty extends Item
}
}
return stack;
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
@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
if (target instanceof EntityPixie)

View File

@ -15,8 +15,7 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
@ -136,9 +135,9 @@ public class ItemJarFilled extends Item
@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))
{
// right click in air releases pixie
@ -149,18 +148,18 @@ public class ItemJarFilled extends Item
Vec3d releasePoint = this.getAirPositionInFrontOfPlayer(world, player, 0.8D);
this.releasePixie(stack, world, player, releasePoint);
}
return stack;
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
case HONEY: case POISON: default:
return stack;
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
}
}
@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))
{
// right click on block also releases pixie
@ -170,11 +169,11 @@ public class ItemJarFilled extends Item
double distZ = hitZ - player.posZ;
double a = 0.9D;
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?
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.ItemStack;
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.world.World;
@ -26,21 +29,21 @@ public class ItemMudball extends Item
// throw a mudball on right click
@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)]);
return itemStackIn;
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
}