本文整理汇总了Java中net.minecraftforge.common.IShearable.isShearable方法的典型用法代码示例。如果您正苦于以下问题:Java IShearable.isShearable方法的具体用法?Java IShearable.isShearable怎么用?Java IShearable.isShearable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.common.IShearable
的用法示例。
在下文中一共展示了IShearable.isShearable方法的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: 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();
}
示例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;
}
示例4: 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;
}
示例5: 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());
}
}
}
}
示例6: getIdentifierItems
import net.minecraftforge.common.IShearable; //导入方法依赖的package包/类
public static ArrayList<ItemStack> getIdentifierItems(World world, EntityPlayer player, MovingObjectPosition hit) {
BlockPos pos = hit.getBlockPos();
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
ArrayList<IHighlightHandler> handlers = new ArrayList<IHighlightHandler>();
if (highlightIdentifiers.containsKey(null))
handlers.addAll(highlightIdentifiers.get(null));
if (highlightIdentifiers.containsKey(block))
handlers.addAll(highlightIdentifiers.get(block));
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 = block.getPickBlock(hit, world, pos);
if (pick != null)
items.add(pick);
try {
items.addAll(block.getDrops(world, pos, state, 0));
} catch (Exception ignored) {}
if (block instanceof IShearable) {
IShearable shearable = (IShearable) block;
if (shearable.isShearable(new ItemStack(Items.shears), world, pos))
items.addAll(shearable.onSheared(new ItemStack(Items.shears), world, pos, 0));
}
if (items.size() == 0)
items.add(0, new ItemStack(block, 1, block.getMetaFromState(state)));
return items;
}
示例7: 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;
}
示例8: 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);
}
}
}
示例9: 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;
}
示例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;
}
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;
}
示例11: 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;
}
示例12: 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;
}
示例13: 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;
}
示例14: 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;
}
}
示例15: 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();
}