当前位置: 首页>>代码示例>>Java>>正文


Java IShearable.onSheared方法代码示例

本文整理汇总了Java中net.minecraftforge.common.IShearable.onSheared方法的典型用法代码示例。如果您正苦于以下问题:Java IShearable.onSheared方法的具体用法?Java IShearable.onSheared怎么用?Java IShearable.onSheared使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.common.IShearable的用法示例。


在下文中一共展示了IShearable.onSheared方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDrops

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
public List<ItemStack> getDrops(World world, Random unused, Map<String, Boolean> harvesterSettings, int x, int y,
                                int z)
{
    final Block targetBlock = world.getBlock(x, y, z);
    if (harvesterSettings.get("silkTouch").equals(Boolean.TRUE))
    {
        if (targetBlock instanceof IShearable)
        {
            final ItemStack shears = new ItemStack(Items.shears, 1, 0);
            final IShearable shearable = (IShearable) targetBlock;
            if (shearable.isShearable(shears, world, x, y, z))
                return shearable.onSheared(shears, world, x, y, z, 0);
        }
        if (Item.getItemFromBlock(targetBlock) != null)
        {
            final List<ItemStack> drops = Lists.newArrayList();
            drops.add(new ItemStack(targetBlock, 1, targetBlock.getDamageValue(world, x, y, z)));
            return drops;
        }
    }
    return targetBlock.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
}
 
开发者ID:MinecraftModArchive,项目名称:Dendrology,代码行数:24,代码来源:MFRLeaves.java

示例2: onImpact

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
protected void onImpact(RayTraceResult objectPosition) {
    if (objectPosition.entityHit != null) {
        Entity entity = objectPosition.entityHit;
        entity.motionX += motionX;
        entity.motionY += motionY;
        entity.motionZ += motionZ;
        if (!entity.world.isRemote && entity instanceof IShearable) {
            IShearable shearable = (IShearable) entity;
            BlockPos pos = new BlockPos(posX, posY, posZ);
            if (shearable.isShearable(ItemStack.EMPTY, world, pos)) {
                List<ItemStack> drops = shearable.onSheared(ItemStack.EMPTY, world, pos, 0);
                for (ItemStack stack : drops) {
                    PneumaticCraftUtils.dropItemOnGround(stack, world, entity.posX, entity.posY, entity.posZ);
                }
            }
        }
    } else {
        Block block = world.getBlockState(objectPosition.getBlockPos()).getBlock();
        if (block instanceof IPlantable || block instanceof BlockLeaves) {
            motionX = oldMotionX;
            motionY = oldMotionY;
            motionZ = oldMotionZ;
        } else {
            setDead();
        }
    }
    hitCounter++;
    if (hitCounter > 20) setDead();
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:31,代码来源:EntityVortex.java

示例3: onBlockStartBreak

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player)
{
    if (player.world.isRemote || player.capabilities.isCreativeMode)
    {
        return false;
    }
    IBlockState state = player.world.getBlockState(pos);
    Block block = state.getBlock();
    if (canShear(itemstack,state) && block instanceof IShearable)
    {
        IShearable target = (IShearable)block;
        if (target.isShearable(itemstack, player.world, pos))
        {
            List<ItemStack> drops = target.onSheared(itemstack, player.world, pos,
                    getEnchantmentLevel(net.minecraft.init.Enchantments.FORTUNE, itemstack));

            for (ItemStack stack : drops)
            {
                InventoryUtil.addItemToPlayer(player,stack);
            }

            itemstack.damageItem(1, player);
            player.addStat(getBlockStats(block));
            player.world.setBlockState(pos, Blocks.AIR.getDefaultState(), 11); //TODO: Move to IShearable implementors in 1.12+
            return true;
        }
    }
    return false;
}
 
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:31,代码来源:ItemSpadeConvenient.java

示例4: shear

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
public List<ItemStack> shear(ItemStack stack, int fortune) {
    List<ItemStack> result = Lists.newArrayList();
    EntityAnimal animal = this.getAnimal();
    if ((animal instanceof IShearable)) {
        IShearable shearable = (IShearable)animal;
        if (shearable.isShearable(stack, animal.getEntityWorld(), animal.getPosition())) {
            result = shearable.onSheared(stack, animal.getEntityWorld(), animal.getPosition(), fortune);
        }
    }
    return result;
}
 
开发者ID:faceofcat,项目名称:Mekfarm,代码行数:13,代码来源:VanillaGenericAnimal.java

示例5: onEntityCollidedWithBlock

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
  if (entity instanceof IShearable) {
    IShearable sheep = (IShearable) entity;
    ItemStack fake = new ItemStack(Items.SHEARS);
    if (sheep.isShearable(fake, world, pos)) {
      List<ItemStack> drops = sheep.onSheared(fake, world, pos, FORTUNE);//since iShearable doesnt do drops, but DOES do sound/make sheep naked
      UtilItemStack.dropItemStacksInWorld(world, pos, drops);
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:12,代码来源:BlockShears.java

示例6: itemInteractionForEntity

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity)
{
    if (entity.worldObj.isRemote)
    {
        return false;
    }
    if (entity instanceof IShearable)
    {
        IShearable target = (IShearable)entity;
        if (target.isShearable(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ))
        {
            // Cauldron start
            PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) player.getBukkitEntity(), entity.getBukkitEntity());
            player.worldObj.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled())
            {
                return false;
            }

            // Cauldron end
            ArrayList<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ,
                    EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));

            Random rand = new Random();
            for(ItemStack stack : drops)
            {
                EntityItem ent = entity.entityDropItem(stack, 1.0F);
                ent.motionY += rand.nextFloat() * 0.05F;
                ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
                ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
            }
            itemstack.damageItem(1, entity);
        }
        return true;
    }
    return false;
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:40,代码来源:ItemShears.java

示例7: onBlockStartBreak

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player)
{
    if (player.worldObj.isRemote)
    {
        return false;
    }
    Block block = player.worldObj.getBlock(x, y, z);
    if (block instanceof IShearable)
    {
        IShearable target = (IShearable)block;
        if (target.isShearable(itemstack, player.worldObj, x, y, z))
        {
            ArrayList<ItemStack> drops = target.onSheared(itemstack, player.worldObj, x, y, z,
                    EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));
            Random rand = new Random();

            for(ItemStack stack : drops)
            {
                float f = 0.7F;
                double d  = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
                double d1 = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
                double d2 = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
                EntityItem entityitem = new EntityItem(player.worldObj, (double)x + d, (double)y + d1, (double)z + d2, stack);
                entityitem.delayBeforeCanPickup = 10;
                player.worldObj.spawnEntityInWorld(entityitem);
            }

            itemstack.damageItem(1, player);
            player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1);
        }
    }
    return false;
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:35,代码来源:ItemShears.java

示例8: itemInteractionForEntity

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity)
{
    if (entity.worldObj.isRemote)
    {
        return false;
    }
    if (entity instanceof IShearable)
    {
        IShearable target = (IShearable)entity;
        if (target.isShearable(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ))
        {
            ArrayList<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ,
                    EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));

            Random rand = new Random();
            for(ItemStack stack : drops)
            {
                EntityItem ent = entity.entityDropItem(stack, 1.0F);
                ent.motionY += rand.nextFloat() * 0.05F;
                ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
                ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
            }
            itemstack.damageItem(1, entity);
        }
        return true;
    }
    return false;
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:30,代码来源:ItemShears.java

示例9: onBlockStartBreak

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
    if (player.worldObj.isRemote) {
        return false;
    }
    Block block = player.worldObj.getBlock(x, y, z);
    if (block instanceof IShearable) {
        IShearable target = (IShearable) block;
        if (target.isShearable(stack, player.worldObj, x, y, z)) {
            ArrayList<ItemStack> drops = target.onSheared(stack, player.worldObj, x, y, z,
                    EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack));
            Random rand = new Random();
            for (ItemStack drop : drops) {
                float f = 0.7F;
                double d = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
                double d1 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
                double d2 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
                EntityItem entityitem = new EntityItem(player.worldObj, (double) x + d, (double) y + d1, (double) z + d2, drop);
                entityitem.delayBeforeCanPickup = 10;
                player.worldObj.spawnEntityInWorld(entityitem);
            }
            stack.damageItem(1, player);
            player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1);
        }
    }
    return false;
}
 
开发者ID:TeamAmeriFrance,项目名称:Electro-Magic-Tools,代码行数:28,代码来源:ItemBaseChainsaw.java

示例10: onBlockStartBreak

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player)
{
    if (player.worldObj.isRemote)
    {
        return false;
    }
    int id = player.worldObj.getBlockId(x, y, z);
    if (Block.blocksList[id] instanceof IShearable)
    {
        IShearable target = (IShearable)Block.blocksList[id];
        if (target.isShearable(itemstack, player.worldObj, x, y, z))
        {
            ArrayList<ItemStack> drops = target.onSheared(itemstack, player.worldObj, x, y, z,
                    EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));
            Random rand = new Random();

            for(ItemStack stack : drops)
            {
                float f = 0.7F;
                double d  = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
                double d1 = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
                double d2 = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
                EntityItem entityitem = new EntityItem(player.worldObj, (double)x + d, (double)y + d1, (double)z + d2, stack);
                entityitem.delayBeforeCanPickup = 10;
                player.worldObj.spawnEntityInWorld(entityitem);
            }

            itemstack.damageItem(1, player);
            player.addStat(StatList.mineBlockStatArray[id], 1);
        }
    }
    return false;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:35,代码来源:ItemShears.java

示例11: onHitGround

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
public void onHitGround(BlockPos pos) {
       boolean broken = false;
       if(canBreakBlocks()) {
           IBlockState block = world.getBlockState(pos);
           if (block.getMaterial() == Material.GLASS) {
               broken = world.destroyBlock(pos, false);
           } else if (block.getBlock() instanceof IShearable) {
               IShearable target = (IShearable) block.getBlock();
               if (target.isShearable(ItemStack.EMPTY, world, pos)) {
                   List<ItemStack> drops = target.onSheared(ItemStack.EMPTY, world, pos, 1);
                   if (!world.isRemote) {
                       for (ItemStack stack : drops) {
                           float f = 0.7F;
                           double d = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
                           double d1 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
                           double d2 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
                           EntityItem entityitem = new EntityItem(world, (double) pos.getY() + d, (double) pos.getY() + d1, (double) pos.getZ() + d2, stack);
                           entityitem.setDefaultPickupDelay();
                           world.spawnEntity(entityitem);
                       }
                   }
                   broken = world.setBlockToAir(pos);
               }
           }
       }
       if(broken){
           this.ticksInGround = 0;
           this.yTile = -1;
           this.motionY += 0.05F;
       }
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:33,代码来源:EntityPiercingArrow.java

示例12: onImpact

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
protected void onImpact(MovingObjectPosition objectPosition){
    if(objectPosition.entityHit != null) {
        Entity entity = objectPosition.entityHit;
        entity.motionX += motionX;
        entity.motionY += motionY;
        entity.motionZ += motionZ;
        if(!entity.worldObj.isRemote && entity instanceof IShearable) {
            IShearable shearable = (IShearable)entity;
            int x = (int)Math.floor(posX);
            int y = (int)Math.floor(posY);
            int z = (int)Math.floor(posZ);
            if(shearable.isShearable(null, worldObj, x, y, z)) {
                List<ItemStack> drops = shearable.onSheared(null, worldObj, x, y, z, 0);
                for(ItemStack stack : drops) {
                    PneumaticCraftUtils.dropItemOnGround(stack, worldObj, entity.posX, entity.posY, entity.posZ);
                }
            }
        }

    } else {
        Block block = worldObj.getBlock(objectPosition.blockX, objectPosition.blockY, objectPosition.blockZ);
        if(block instanceof IPlantable || block instanceof BlockLeaves) {
            motionX = oldMotionX;
            motionY = oldMotionY;
            motionZ = oldMotionZ;
        } else {
            setDead();
        }
    }
    hitCounter++;
    if(hitCounter > 20) setDead();
}
 
开发者ID:MineMaarten,项目名称:PneumaticCraft,代码行数:34,代码来源:EntityVortex.java

示例13: run

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
public boolean run(EntityMinionWorker worker, TileWorksiteBase worksite) {
	if(worker.getEntityWorld().isRemote) return false;
	if(this.animalToShear == null || this.animalToShear.isDead || !(this.animalToShear instanceof IShearable)) return true;
	if(worksite == null || !(worksite instanceof WorksiteAnimalFarm)) return true;
	WorksiteAnimalFarm aFarm = (WorksiteAnimalFarm)worksite;

	
	destroyTool(worker);
	aFarm.giveShears(worker);
	ItemStack held = worker.getHeldItemMainhand();
	if(held == null || !(held.getItem() instanceof ItemShears)){
		return true;
	}
	worker.getLookHelper().setLookPositionWithEntity(animalToShear, 10, 40);
	double d = worker.getDistanceToEntity(animalToShear);
	if(d <= 2.5D){
		IShearable shearable = (IShearable)this.animalToShear;
		BlockPos shearPos = new BlockPos(animalToShear);
		if(shearable.isShearable(held, worker.getEntityWorld(), shearPos)){
			worker.swingArm(EnumHand.MAIN_HAND);
            
			int fourtune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, held);
	  		if(fourtune < 2)fourtune += aFarm.getUpgrades().contains(WorksiteUpgrade.ENCHANTED_TOOLS_1)? 1 : aFarm.getUpgrades().contains(WorksiteUpgrade.ENCHANTED_TOOLS_2)? 2 : aFarm.getUpgrades().contains(WorksiteUpgrade.ENCHANTED_TOOLS_3) ? 3 : 0;
	  		
			List<ItemStack> stacks = shearable.onSheared(held, worker.getEntityWorld(), shearPos, fourtune);
			for(ItemStack item : stacks){
				if(item !=null){
					aFarm.addStackToInventory(item, RelativeSide.TOP);
				}
			}
			held.damageItem(1, worker);
			destroyTool(worker);
			animalToShear = null;
			return true;
		}
	} else {
		if(worker.getNavigator().noPath()){
			worker.getNavigator().tryMoveToEntityLiving(animalToShear, MinionConstants.SPEED_WALK);
		}
	}
	
	return false;
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:45,代码来源:JobShearEntity.java

示例14: itemInteractionForEntity

import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
@Override
public boolean itemInteractionForEntity(ItemStack stack,
        EntityPlayer player, EntityLivingBase entity, EnumHand hand) {

    if (entity.world.isRemote) {
        
        return false;
    }
    
    if (entity instanceof IShearable) {
        
        IShearable target = (IShearable) entity;
        
        BlockPos pos = new BlockPos(entity.posX, entity.posY, entity.posZ);
        
        if (target.isShearable(stack, entity.world, pos)) {
            
            target.onSheared(stack, entity.world, pos, 0);
            entity.dropItem(GeoItems.WOOL,
                    this.yield.apply(entity.world.rand));
            
            stack.damageItem(1, entity);
        }
        
        return true;
    }
    
    return false;
}
 
开发者ID:JayAvery,项目名称:geomastery,代码行数:30,代码来源:ItemShears.java


注:本文中的net.minecraftforge.common.IShearable.onSheared方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。