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