本文整理匯總了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);
}
示例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);
}
}
}
示例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);
}
示例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;
}
}
示例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");
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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());
}
}
}
}