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


Java IShearable类代码示例

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


IShearable类属于net.minecraftforge.common包,在下文中一共展示了IShearable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onSheared

import net.minecraftforge.common.IShearable; //导入依赖的package包/类
@SubscribeEvent
public void onSheared(EntityInteractSpecific event) {
	
	ItemStack rainbow = BaublesApi.getBaublesHandler((EntityPlayer)event.getEntityPlayer()).getStackInSlot(6);
	if (rainbow == null || (rainbow != null && rainbow.getItem() != this)) return;
	
	if (!(event.getTarget() instanceof IShearable)) return;
	if (!(event.getTarget() instanceof EntitySheep) || (event.getTarget() instanceof EntitySheep && ((EntitySheep)event.getTarget()).getSheared())) return;
	if (event.getItemStack() == null || (event.getItemStack() != null && !(event.getItemStack().getItem() instanceof ItemShears))) return;
	
	int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, event.getItemStack());
	if (!event.getWorld().isRemote) {
		List<ItemStack> wools = ((IShearable)event.getTarget()).onSheared(event.getItemStack(), event.getWorld(), event.getPos(), fortune);
		for (ItemStack is : wools) {
			Random rand = new Random();
			is.setItemDamage(rand.nextInt(15));
			EntityItem wool = new EntityItem(event.getWorld(), event.getTarget().posX, event.getTarget().posY, event.getTarget().posZ, is);
			event.getWorld().spawnEntityInWorld(wool);
		}
	}
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:22,代码来源:EmblemRainbow.java

示例3: onBlockDestroyed

import net.minecraftforge.common.IShearable; //导入依赖的package包/类
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity)
{
    if(!this.hasEnoughEnergy(stack, energyCostUseSmall)) {
        return false;
    }
    this.consumePower(stack, entity, energyCostUseSmall);
    if(this.getMode(stack) == Mode.SHEARS) {

        if (block.getMaterial() != Material.leaves && block != Blocks.web && block != Blocks.tallgrass && block != Blocks.vine && block != Blocks.tripwire && !(block instanceof IShearable))
        {
            return super.onBlockDestroyed(stack, world, block, x, y, z, entity);
        }
        else
        {
            return true;
        }
    }
    return super.onBlockDestroyed(stack, world, block, x, y, z, entity);
}
 
开发者ID:katzenpapst,项目名称:amunra,代码行数:21,代码来源:ItemNanotool.java

示例4: onBlockDestroyed

import net.minecraftforge.common.IShearable; //导入依赖的package包/类
public boolean onBlockDestroyed(ItemStack item, World world, int id, int y, int z, int s, EntityLivingBase user)
  {
Random rand = new Random();
      if(getMaterial() == ToolMaterialMedieval.IGNOTUMITE)
      {
      	if(user instanceof EntityPlayer)
      	{
      		((EntityPlayer)user).getFoodStats().addStats(1, 0.2F);
      	}
      }
      
      
      if (id != Block.leaves.blockID && id != Block.web.blockID && id != Block.tallGrass.blockID && id != Block.vine.blockID && id != Block.tripWire.blockID && !(Block.blocksList[id] instanceof IShearable))
      {
          return super.onBlockDestroyed(item, world, id, y, z, s, user);
      }
      else
      {
          return true;
      }
  }
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:22,代码来源:ItemShearsMF.java

示例5: useTool

import net.minecraftforge.common.IShearable; //导入依赖的package包/类
@Override
public TurtleCommandResult useTool(ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, int direction) {
	if (!Config.enableShearTurtle)
		return TurtleCommandResult.failure("Shearing turtles have been disabled");
	FakeTurtlePlayer player = new FakeTurtlePlayer(turtle);
	switch (verb) {
		case Attack:
			List<Entity> entities = TurtleUtil.getEntitiesNearTurtle(turtle, player, direction);
			Entity ent = TurtleUtil.getClosestShearableEntity(entities, player);
			if (ent != null)
				if (((IShearable) ent).isShearable(new ItemStack(Items.shears), ent.worldObj, (int) ent.posX, (int) ent.posY, (int) ent.posZ)) {
					TurtleUtil.addItemListToInv(((IShearable) ent).onSheared(new ItemStack(Items.shears), ent.worldObj, (int) ent.posX, (int) ent.posY, (int) ent.posZ, 0), turtle);
					return TurtleCommandResult.success();
				}
			return TurtleCommandResult.failure();
		case Dig:
			List<ItemStack> items = TurtleUtil.harvestBlock(turtle, player, direction, new ItemStack(Items.shears));
			if (items != null) {
				TurtleUtil.addItemListToInv(items, turtle);
				return TurtleCommandResult.success();
			}
			return TurtleCommandResult.failure();
	}
	return TurtleCommandResult.failure("An unknown error has occurred, please tell the mod author");
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:26,代码来源:TurtleShear.java

示例6: findAnimalToShear

import net.minecraftforge.common.IShearable; //导入依赖的package包/类
protected EntityAnimal findAnimalToShear(int n) {
	if (!hasUpgrade(UpgradeType.SHEARING)) return null;
	Point3I point = getPoint(n);
	boundCheck = new AxisAlignedBB(point.getX(), point.getY()-1, point.getZ(), 
			point.getX()+1, point.getY()+2, point.getZ()+1);
	List<EntityAnimal> entities = world.getEntitiesWithinAABB(EntityAnimal.class, boundCheck);
	if (!entities.isEmpty()) {
		for (EntityAnimal animal: entities) {
			if ( !slots[SLOT_SHEARS].isEmpty() ) {
				if (animal instanceof IShearable) {
					if (((IShearable)animal).isShearable(slots[SLOT_SHEARS], world, point.toPosition())) {
						return animal;
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:Vanhal,项目名称:ProgressiveAutomation,代码行数:20,代码来源:TileFarmer.java

示例7: shearAnimal

import net.minecraftforge.common.IShearable; //导入依赖的package包/类
protected void shearAnimal(EntityAnimal animal) {
	if ( (!slots[SLOT_SHEARS].isEmpty()) && (hasUpgrade(UpgradeType.SHEARING)) ) {
		if (animal instanceof IShearable) {
			int fortuneLevel =  EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByLocation("fortune"), slots[SLOT_SHEARS]);
			
			List<ItemStack> items = ((IShearable)animal).onSheared(slots[SLOT_SHEARS], world, pos, fortuneLevel);
			//get the drops
			for (ItemStack item : items) {
				addToInventory(item);
			}
			
			if (ToolHelper.damageTool(slots[SLOT_SHEARS], world, pos.getX(), pos.getY(), pos.getZ())) {
				destroyTool(SLOT_SHEARS);
			}
			
			currentTime = waitTime;
			addPartialUpdate("currentTime", currentTime);
		}
	}
}
 
开发者ID:Vanhal,项目名称:ProgressiveAutomation,代码行数:21,代码来源:TileFarmer.java

示例8: onHitEntity

import net.minecraftforge.common.IShearable; //导入依赖的package包/类
@Override
public boolean onHitEntity(Entity entityHit, DamageSource source, float ammount) {
    if(!source.getDamageType().equals("piercing.arrow")) {
           if(entityHit != this.shootingEntity && entityHit.attackEntityFrom(getPiercingDamage(), ammount)) {
               this.playSound(SoundEvents.ENTITY_ARROW_HIT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
           }
           if (entityHit instanceof IShearable) {
               if (((IShearable) entityHit).isShearable(ItemStack.EMPTY, world, new BlockPos(entityHit))) {
                   List<ItemStack> drops = ((IShearable) entityHit).onSheared(ItemStack.EMPTY, world, new BlockPos(entityHit), 1);
                   if(!world.isRemote) {
                       for (ItemStack stack : drops) {
                           EntityItem ent = entityHit.entityDropItem(stack, 1.0F);
                           if (ent != null) {
                               ent.motionY += rand.nextFloat() * 0.05F;
                               ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
                               ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
                           }
                       }
                   }
               }
           }
           return true;
       }
	return false;
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:26,代码来源:EntityPiercingArrow.java

示例9: BlockProperties

import net.minecraftforge.common.IShearable; //导入依赖的package包/类
/**
 * Build the properties for the given block and store them into the internal map
 */
private BlockProperties(Block block){
    // Lava is considered to NOT be a liquid, and is therefore not wallable. This is so we can build cities on the lava surface.
    isWater = block.getMaterial() == Material.water || block == Blocks.ice;
    isStair = block instanceof BlockStairs;
    isTree = block instanceof BlockLog || block instanceof IShearable || block instanceof BlockSnow;
    isFlowing = isWater ||  block.getMaterial() == Material.lava || block instanceof BlockDynamicLiquid || block instanceof BlockFalling;
    isWallable = isWater || block instanceof BlockAir || isTree || block instanceof BlockWeb || block instanceof BlockPumpkin
            || block instanceof BlockMelon || block instanceof BlockHugeMushroom || block instanceof IPlantable;
    isOre = block instanceof BlockClay || block instanceof BlockRedstoneOre || block instanceof BlockOre;
    isGround = block == Blocks.stone || block instanceof BlockDirt || block instanceof BlockGrass
            || block instanceof BlockGravel || block instanceof BlockSand || block instanceof BlockNetherrack || block instanceof BlockSoulSand || block instanceof BlockMycelium;
    // Define by what it is not. Not IS_WALLABLE and not a naturally occurring solid block (obsidian/bedrock are exceptions)
    isArtificial = !(isWallable || isOre || isGround);
    isDelayed = isStair || isFlowing || block instanceof BlockTorch || block instanceof BlockGlowstone || block instanceof BlockDoor || block instanceof BlockLever || block instanceof BlockSign
            || block instanceof BlockFire || block instanceof BlockButton || block instanceof BlockVine || block instanceof BlockRedstoneWire || block instanceof BlockDispenser
            || block instanceof BlockFurnace;
    // Define by what it is not.
    isLoaded = !(isWallable || isFlowing || block instanceof BlockTorch || block instanceof BlockLadder);
    props.put(block, this);
}
 
开发者ID:GotoLink,项目名称:Generatormods,代码行数:24,代码来源:BlockProperties.java

示例10: 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

示例11: chop

import net.minecraftforge.common.IShearable; //导入依赖的package包/类
public List<ItemStack> chop(Queue<BlockPos> cache, boolean shear) {
    BlockPos p = cache.peek();
    NonNullList<ItemStack> stacks = NonNullList.create();
    if (BlockUtils.isLeaves(world, p) || BlockUtils.isLog(world, p)) {
        IBlockState s = world.getBlockState(p);
        if (s.getBlock() instanceof IShearable && shear) {
            stacks.addAll(((IShearable) s.getBlock()).onSheared(new ItemStack(Items.SHEARS), world, p, 0));
        } else {
            s.getBlock().getDrops(stacks, world, p, s, 0);
        }
        world.setBlockToAir(p);
    }
    cache.poll();
    return stacks;
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:16,代码来源:TreeCache.java

示例12: 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

示例13: getIdentifierItems

import net.minecraftforge.common.IShearable; //导入依赖的package包/类
public static ArrayList<ItemStack> getIdentifierItems(World world, EntityPlayer player, MovingObjectPosition hit) {
    int x = hit.blockX;
    int y = hit.blockY;
    int z = hit.blockZ;
    Block mouseoverBlock = world.getBlock(x, y, z);

    ArrayList<ItemStack> items = new ArrayList<ItemStack>();

    ArrayList<IHighlightHandler> handlers = new ArrayList<IHighlightHandler>();
    if (highlightIdentifiers.containsKey(null))
        handlers.addAll(highlightIdentifiers.get(null));
    if (highlightIdentifiers.containsKey(mouseoverBlock))
        handlers.addAll(highlightIdentifiers.get(mouseoverBlock));
    for (IHighlightHandler ident : handlers) {
        ItemStack item = ident.identifyHighlight(world, player, hit);
        if (item != null)
            items.add(item);
    }

    if (items.size() > 0)
        return items;

    ItemStack pick = mouseoverBlock.getPickBlock(hit, world, x, y, z);
    if (pick != null)
        items.add(pick);

    try {
        items.addAll(mouseoverBlock.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0));
    } catch (Exception ignored) {}
    if (mouseoverBlock instanceof IShearable) {
        IShearable shearable = (IShearable) mouseoverBlock;
        if (shearable.isShearable(new ItemStack(Items.shears), world, x, y, z))
            items.addAll(shearable.onSheared(new ItemStack(Items.shears), world, x, y, z, 0));
    }

    if (items.size() == 0)
        items.add(0, new ItemStack(mouseoverBlock, 1, world.getBlockMetadata(x, y, z)));

    return items;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:41,代码来源:ItemInfo.java

示例14: isBlockValidForCover

import net.minecraftforge.common.IShearable; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private static boolean isBlockValidForCover(Block block) {
       try {
       	if(block == Blocks.AIR || block instanceof IShearable)return false;
       	IBlockState state = block.getDefaultState();
       	if (block.hasTileEntity() || block.hasTileEntity(block.getDefaultState())) return false;
           if(!state.isFullCube())return false;
           return true;
       } catch (Throwable ignored) {
           return false;
       }
   }
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:13,代码来源:ItemPipeCover.java

示例15: scanForSheep

import net.minecraftforge.common.IShearable; //导入依赖的package包/类
private void scanForSheep(List<EntityAnimal> sheep) {
	scanForAnimals(sheep, sheepToBreed, maxSheepCount);
	for (EntityAnimal animal : sheep) {
		if (animal instanceof IShearable) {
			IShearable sheep1 = (IShearable) animal;
			if (sheep1.isShearable(null, getWorld(), new BlockPos(animal))) {
				sheepToShear.add(animal.getEntityId());
			}
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:12,代码来源:WorksiteAnimalFarm.java


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