Java 类net.minecraftforge.common.util.FakePlayerFactory 实例源码

项目:pnc-repressurized    文件:SemiBlockSpawnerAgitator.java   
@Override
public void update() {
    super.update();
    if (!world.isRemote) {
        TileEntityMobSpawner te = getTileEntity();
        if(te != null){
            MobSpawnerBaseLogic spawnerLogic = te.getSpawnerBaseLogic();

            //Only tick the logic if it wasn't ticked already by the TE itself, to prevent double ticking.
            if(!Reflections.isActivated(spawnerLogic)){

                //Temporarily add a fake player to the world to trick the spawner into thinking there's a player nearby
                EntityPlayer fakePlayer = FakePlayerFactory.get((WorldServer)world, FAKE_PLAYER_PROFILE);
                fakePlayer.posX = getPos().getX();
                fakePlayer.posY = getPos().getY();
                fakePlayer.posZ = getPos().getZ();

                world.playerEntities.add(fakePlayer);
                spawnerLogic.updateSpawner();
                world.playerEntities.remove(fakePlayer);
            }                
        }
    }
}
项目:TreeChopper    文件:TreeHandler.java   
private void PlantSapling(World world, BlockPos blockPos, BlockPos originPos) {

        Set<ItemStack> leafDrop = new HashSet<>();
        BlockPos plantPos1 = new BlockPos(originPos.getX() - 1, originPos.getY(), originPos.getZ() - 1);
        int counter = 0;

        while (leafDrop.isEmpty() && counter <= 100) {
            NonNullList<ItemStack> tmpList = NonNullList.create();
            world.getBlockState(blockPos).getBlock().getDrops(tmpList, world, blockPos, world.getBlockState(blockPos), 3);
            leafDrop.addAll(tmpList);

            counter++;
        }

        if (leafDrop.isEmpty()) {
            return;
        }

        FakePlayer fakePlayer = FakePlayerFactory.getMinecraft((WorldServer) world);
        fakePlayer.setHeldItem(EnumHand.MAIN_HAND, leafDrop.iterator().next());

        for (ItemStack itemStack : leafDrop) {
            itemStack.onItemUse(fakePlayer, world, plantPos1, EnumHand.MAIN_HAND, EnumFacing.NORTH, 0, 0, 0);
        }
    }
项目:ExtraUtilities    文件:BlockSpike.java   
public boolean doPlayerLastHit(final World world, final Entity target, final TileEntity tile) {
    final FakePlayer fakePlayer = FakePlayerFactory.getMinecraft((WorldServer)world);
    try {
        final ItemStack stack = this.swordStack.copy();
        if (tile instanceof TileEntityEnchantedSpike) {
            stack.setTagCompound(((TileEntityEnchantedSpike)tile).getEnchantmentTagList());
        }
        fakePlayer.setCurrentItemOrArmor(0, stack);
        boolean b = target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)fakePlayer), 400.0f);
        fakePlayer.setCurrentItemOrArmor(0, (ItemStack)null);
        b |= target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)fakePlayer), 400.0f);
        b |= target.attackEntityFrom(DamageSource.cactus, 400.0f);
        return b;
    }
    finally {
        fakePlayer.setCurrentItemOrArmor(0, (ItemStack)null);
    }
}
项目:TechStack-s-HeavyMachineryMod    文件:BlockUtil.java   
public static boolean BreakBlock(World worldObj, BlockPos pos, Entity player) {
    IBlockState state = worldObj.getBlockState(pos);

    EntityPlayer passedPlayer;

    if (player instanceof EntityPlayer) {
        passedPlayer = (EntityPlayer) player;
    } else {
        passedPlayer = FakePlayerFactory.get((WorldServer) worldObj, Reference.gameProfile);
    }

    BlockEvent.BreakEvent breakEvent = new BlockEvent.BreakEvent(worldObj, pos, state, passedPlayer);
    MinecraftForge.EVENT_BUS.post(breakEvent);

    if (breakEvent.isCanceled()) {
        return false;
    }

    worldObj.getBlockState(pos).getBlock().dropBlockAsItem(worldObj, pos, state, 0);
    // TODO add block break sound
    worldObj.setBlockToAir(pos);

    return true;
}
项目:Cyclic    文件:UtilFakePlayer.java   
public static WeakReference<FakePlayer> initFakePlayer(WorldServer ws, UUID uname, String blockName) {
  GameProfile breakerProfile = new GameProfile(uname, Const.MODID + ".fake_player." + blockName);
  WeakReference<FakePlayer> fakePlayer;
  try {
    fakePlayer = new WeakReference<FakePlayer>(FakePlayerFactory.get(ws, breakerProfile));
  }
  catch (Exception e) {
    ModCyclic.logger.error("Exception thrown trying to create fake player : " + e.getMessage());
    fakePlayer = null;
  }
  if (fakePlayer == null || fakePlayer.get() == null) {
    fakePlayer = null;
    return null; // trying to get around https://github.com/PrinceOfAmber/Cyclic/issues/113
  }
  fakePlayer.get().onGround = true;
  fakePlayer.get().connection = new NetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.SERVERBOUND), fakePlayer.get()) {
    @SuppressWarnings("rawtypes")
    @Override
    public void sendPacket(Packet packetIn) {}
  };
  fakePlayer.get().setSilent(true);
  return fakePlayer;
}
项目:NEI-Integration    文件:CartTools.java   
/**
 * Spawns a new cart entity using the provided item.
 * <p/>
 * The backing item must implement <code>IMinecartItem</code> and/or extend
 * <code>ItemMinecart</code>.
 * <p/>
 * Generally Forge requires all cart items to extend ItemMinecart.
 *
 * @param owner The player name that should used as the owner
 * @param cart  An ItemStack containing a cart item, will not be changed by
 *              the function
 * @param world The World object
 * @param x     x-Coord
 * @param y     y-Coord
 * @param z     z-Coord
 * @return the cart placed or null if failed
 * @see IMinecartItem, ItemMinecart
 */
public static EntityMinecart placeCart(GameProfile owner, ItemStack cart, WorldServer world, int x, int y, int z) {
    if (cart == null)
        return null;
    cart = cart.copy();
    if (cart.getItem() instanceof IMinecartItem) {
        IMinecartItem mi = (IMinecartItem) cart.getItem();
        return mi.placeCart(owner, cart, world, x, y, z);
    } else if (cart.getItem() instanceof ItemMinecart)
        try {
            boolean placed = cart.getItem().onItemUse(cart, FakePlayerFactory.get(world, railcraftProfile), world, x, y, z
                    , 0, 0, 0, 0);
            if (placed) {
                List<EntityMinecart> carts = getMinecartsAt(world, x, y, z, 0.3f);
                if (carts.size() > 0) {
                    setCartOwner(carts.get(0), owner);
                    return carts.get(0);
                }
            }
        } catch (Exception e) {
            return null;
        }

    return null;
}
项目:MeeCreeps    文件:GeneralTools.java   
public static FakePlayer getHarvester() {
    if (harvester == null) {
        harvester = FakePlayerFactory.get(DimensionManager.getWorld(0), new GameProfile(new UUID(656, 123), "meecreps"));
    }
    // @todo config, make it possible to specify lesser pickaxe in config
    harvester.setHeldItem(EnumHand.MAIN_HAND, new ItemStack(Items.DIAMOND_PICKAXE));
    return harvester;
}
项目:CustomWorldGen    文件:ForgeInternalHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDimensionUnload(WorldEvent.Unload event)
{
    ForgeChunkManager.unloadWorld(event.getWorld());
    if (event.getWorld() instanceof WorldServer)
        FakePlayerFactory.unloadWorld((WorldServer) event.getWorld());
}
项目:MiningWells    文件:FakePlayerHandler.java   
public static final FakePlayer getFakePlayer() {
    if (player == null) {
        player = FakePlayerFactory.get(DimensionManager.getWorld(0), new GameProfile(UUID.randomUUID(), "RoyTheMiner"));
        LogUtils.info("Created fake player: " + player.getUniqueID() + " - " + player.getName());
    }
    return player;
}
项目:ExtraUtilities    文件:BlockSpikeGold.java   
@Override
public void onEntityCollidedWithBlock(final World world, final int x, final int y, final int z, final Entity target) {
    if (world.isRemote || !(world instanceof WorldServer)) {
        return;
    }
    final FakePlayer fakeplayer = FakePlayerFactory.getMinecraft((WorldServer)world);
    if (target instanceof EntityLivingBase) {
        final TileEntity tile = world.getTileEntity(x, y, z);
        final float damage = this.getDamageMultipliers(4.0f, tile, (EntityLivingBase)target);
        final float h = ((EntityLivingBase)target).getHealth();
        boolean flag = false;
        if (h > damage || target instanceof EntityPlayer) {
            flag = target.attackEntityFrom(DamageSource.cactus, damage);
        }
        else if (h > 0.5f) {
            flag = target.attackEntityFrom(DamageSource.generic, h - 0.001f);
        }
        else if (world.rand.nextInt(3) == 0) {
            flag = this.doPlayerLastHit(world, target, tile);
        }
        else {
            flag = target.attackEntityFrom(DamageSource.cactus, 40.0f);
        }
        if (flag) {
            this.doPostAttack(world, target, tile, x, y, z);
        }
    }
}
项目:ExtraUtilities    文件:BlockSpike.java   
public void onEntityCollidedWithBlock(final World world, final int x, final int y, final int z, final Entity target) {
    if (world.isRemote || !(world instanceof WorldServer)) {
        return;
    }
    final FakePlayer fakeplayer = FakePlayerFactory.getMinecraft((WorldServer)world);
    if (!(target instanceof EntityLivingBase)) {
        return;
    }
    final TileEntity tile = world.getTileEntity(x, y, z);
    final float damage = this.getDamageMultipliers(4.0f, tile, (EntityLivingBase)target);
    final float h = ((EntityLivingBase)target).getHealth();
    boolean flag;
    if (h > damage || target instanceof EntityPlayer) {
        flag = target.attackEntityFrom(DamageSource.cactus, damage - 0.001f);
    }
    else if (world.rand.nextInt(5) == 0) {
        flag = this.doPlayerLastHit(world, target, tile);
    }
    else {
        flag = target.attackEntityFrom(DamageSource.cactus, 400.0f);
    }
    if (flag) {
        this.doPostAttack(world, target, tile, x, y, z);
        if (target instanceof EntityLiving) {
            try {
                BlockSpike.experienceField.setInt(target, 0);
            }
            catch (IllegalAccessException ex) {}
        }
    }
}
项目:CrystalMod    文件:FakePlayerUtil.java   
private static FakePlayer getCrystalMod(WorldServer world)
{
    FakePlayer ret = CRYSTALMOD_PLAYER != null ? CRYSTALMOD_PLAYER.get() : null;
    if (ret == null)
    {
        ret = FakePlayerFactory.get(world, CRYSTALMOD);
        CRYSTALMOD_PLAYER = new WeakReference<FakePlayer>(ret);
    }
    return ret;
}
项目:TRHS_Club_Mod_2016    文件:ForgeInternalHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDimensionUnload(WorldEvent.Unload event)
{
    ForgeChunkManager.unloadWorld(event.world);
    if (event.world instanceof WorldServer)
        FakePlayerFactory.unloadWorld((WorldServer)event.world);
}
项目:CommonUtils    文件:ProxyModBase.java   
@Nonnull
public FakePlayer getFakePlayer(@Nonnull WorldServer world) {
    FakePlayer player = fakePlayer.get();
    if (player == null) {
        player = FakePlayerFactory.get(world, fakePlayerProfile);
        fakePlayer = new WeakReference<>(player);
    }
    return player;
}
项目:CauldronGit    文件:ForgeInternalHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDimensionUnload(WorldEvent.Unload event)
{
    ForgeChunkManager.unloadWorld(event.world);
    if (event.world instanceof WorldServer)
        FakePlayerFactory.unloadWorld((WorldServer)event.world);
}
项目:ThermalRecycling    文件:FakePlayerHelper.java   
private static WeakReference<EntityPlayer> createNewPlayer(
        final WorldServer world, final int x, final int y, final int z) {
    final EntityPlayer player = FakePlayerFactory.get(world, profile);
    player.posX = x;
    player.posY = y;
    player.posZ = z;
    return new WeakReference<EntityPlayer>(player);
}
项目:ConveyorBelts    文件:TravellingObjectItemStack.java   
@Override
protected boolean moveTo(ForgeDirection side, boolean simulate) {
    if (super.moveTo(side, simulate)) {
        return true;
    }

    Block block = owner.getNeighborBlock(side);

    if (block.isAir(owner.world(), owner.x() + side.offsetX, owner.y(), owner.z() + side.offsetZ)) {
        if (!simulate) {
            TileEntity t = owner.world().getTileEntity(owner.x() + side.offsetX, owner.y() - 1, owner.z() + side.offsetZ);

            if (t == null || !Technotronics.HOPPERS.contains(t.getClass())) {
                if (stack.tryPlaceItemIntoWorld(FakePlayerFactory.getMinecraft((WorldServer) owner.world()), owner.world(), owner.x() + side.offsetX, owner.y() + side.offsetY, owner.z() + side.offsetZ, side.getOpposite().ordinal(), 0.0F, 0.0F, 0.0F)) {
                    return true;
                }
            }

            ItemUtils.spawnItemEntity(owner.world(), owner.x() + 0.5 + side.offsetX, owner.y() + 0.25, owner.z() + 0.5 + side.offsetZ, stack, 0.02F, 0.03F, 0.02F);
        }
        return true;
    } else {
        TileEntity tile = owner.getNeighborTile(side);
        int added = 0;

        if (tile instanceof IInventory) {
            added += InventoryUtils.addStack((IInventory) tile, side.getOpposite(), stack.copy(), simulate);
        }

        if (!simulate) {
            stack.stackSize -= added;
            return stack.stackSize == 0;
        }

        return stack.stackSize == added;
    }
}
项目:enderutilities    文件:TileEntityDrawbridge.java   
@Nonnull
private FakePlayer getPlayer()
{
    if (this.fakePlayer == null)
    {
        int dim = this.getWorld().provider.getDimension();

        this.fakePlayer = FakePlayerFactory.get((WorldServer) this.getWorld(),
                new GameProfile(new UUID(dim, dim), Reference.MOD_ID + ":drawbridge"));
    }

    return this.fakePlayer;
}
项目:Cauldron    文件:ForgeInternalHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDimensionUnload(WorldEvent.Unload event)
{
    ForgeChunkManager.unloadWorld(event.world);
    if (event.world instanceof WorldServer)
        FakePlayerFactory.unloadWorld((WorldServer)event.world);
}
项目:Cauldron    文件:ForgeInternalHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDimensionUnload(WorldEvent.Unload event)
{
    ForgeChunkManager.unloadWorld(event.world);
    if (event.world instanceof WorldServer)
        FakePlayerFactory.unloadWorld((WorldServer)event.world);
}
项目:Cauldron    文件:ForgeInternalHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDimensionUnload(WorldEvent.Unload event)
{
    ForgeChunkManager.unloadWorld(event.world);
    if (event.world instanceof WorldServer)
        FakePlayerFactory.unloadWorld((WorldServer)event.world);
}
项目:WuppyMods    文件:EntityBonemealBottle.java   
/**
 * Called when the throwable hits a block or entity.z
 */
@Override
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
    if (!worldObj.isRemote)
    {
        if (applyBonemeal(worldObj, par1MovingObjectPosition.blockX, par1MovingObjectPosition.blockY, par1MovingObjectPosition.blockZ, FakePlayerFactory.getMinecraft((WorldServer) worldObj)))
        {

            worldObj.playAuxSFX(2005, par1MovingObjectPosition.blockX, par1MovingObjectPosition.blockY, par1MovingObjectPosition.blockZ, 0);
            worldObj.playSound(par1MovingObjectPosition.blockX, par1MovingObjectPosition.blockY, par1MovingObjectPosition.blockZ, "step.wood", 1F, 1F, true);
        }
    }
}
项目:EnderIO    文件:TileSliceAndSplice.java   
@SuppressWarnings("null")
private @Nonnull EntityLivingBase getFakePlayer() {
  if (fakePlayer == null) {
    fakePlayer = FakePlayerFactory
        .getMinecraft(FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(world.provider.getDimension()));
  }
  return fakePlayer;
}
项目:pnc-repressurized    文件:TileEntitySentryTurret.java   
private EntityPlayer getFakePlayer() {
    return FakePlayerFactory.get((WorldServer) getWorld(), new GameProfile(null, "Sentry Turret"));
}
项目:ExtraUtilities    文件:TileEntityEnderQuarry.java   
public boolean harvestBlock(final Block block, final int x, final int y, final int z, final int meta, final boolean replaceWithDirt, final DigType digType) {
    final boolean isOpaque = block.isOpaqueCube();
    final boolean seesSky = replaceWithDirt && isOpaque && this.worldObj.canBlockSeeTheSky(x, y + 1, z);
    final FakePlayer fakePlayer = FakePlayerFactory.getMinecraft((WorldServer)this.worldObj);
    fakePlayer.setCurrentItemOrArmor(0, digType.newStack(Items.diamond_pickaxe));
    try {
        if (BlockBreakingRegistry.isSpecial(block)) {
            EventHandlerEntityItemStealer.startCapture(true);
            block.onBlockHarvested(this.worldObj, x, y, z, meta, (EntityPlayer)fakePlayer);
            if (!block.removedByPlayer(this.worldObj, (EntityPlayer)fakePlayer, x, y, z, true)) {
                this.items.addAll(EventHandlerEntityItemStealer.getCapturedItemStacks());
                return false;
            }
            block.harvestBlock(this.worldObj, (EntityPlayer)fakePlayer, x, y, z, meta);
            block.onBlockDestroyedByPlayer(this.worldObj, x, y, z, meta);
            if (replaceWithDirt && isOpaque) {
                this.worldObj.setBlock(x, y, z, (Block)(seesSky ? Blocks.grass : Blocks.dirt), 0, 3);
            }
            this.items.addAll(EventHandlerEntityItemStealer.getCapturedItemStacks());
        }
        else {
            EventHandlerEntityItemStealer.startCapture(true);
            final boolean flag = this.worldObj.setBlock(x, y, z, (Block)((replaceWithDirt && isOpaque) ? (seesSky ? Blocks.grass : Blocks.dirt) : Blocks.air), 0, 3);
            this.items.addAll(EventHandlerEntityItemStealer.getCapturedItemStacks());
            if (!flag) {
                return false;
            }
            final ArrayList<ItemStack> i = new ArrayList<ItemStack>();
            if (digType.isSilkTouch() && block.canSilkHarvest(this.worldObj, (EntityPlayer)fakePlayer, x, y, z, meta)) {
                int j = 0;
                final Item item = Item.getItemFromBlock(block);
                if (item != null) {
                    if (item.getHasSubtypes()) {
                        j = meta;
                    }
                    final ItemStack itemstack = new ItemStack(item, 1, j);
                    i.add(itemstack);
                }
            }
            else {
                i.addAll(block.getDrops(this.worldObj, x, y, z, meta, digType.getFortuneModifier()));
            }
            final float p = ForgeEventFactory.fireBlockHarvesting((ArrayList)i, this.worldObj, block, x, y, z, meta, digType.getFortuneModifier(), 1.0f, digType.isSilkTouch(), (EntityPlayer)fakePlayer);
            if (p > 0.0f && !i.isEmpty() && (p == 1.0f || TileEntityEnderQuarry.rand.nextFloat() < p)) {
                this.items.addAll(i);
            }
        }
        NetworkHandler.sendParticleEvent(this.worldObj, 0, x, y, z);
        if (seesSky && TileEntityEnderQuarry.rand.nextInt(16) == 0 && this.worldObj.isAirBlock(x, y + 1, z)) {
            if (TileEntityEnderQuarry.rand.nextInt(5) == 0) {
                this.worldObj.getBiomeGenForCoords(x, z).plantFlower(this.worldObj, TileEntityEnderQuarry.rand, x, y + 1, z);
            }
            else if (TileEntityEnderQuarry.rand.nextInt(2) == 0) {
                this.worldObj.setBlock(x, y + 1, z, (Block)Blocks.yellow_flower, TileEntityEnderQuarry.rand.nextInt(BlockFlower.field_149858_b.length), 3);
            }
            else {
                this.worldObj.setBlock(x, y + 1, z, (Block)Blocks.red_flower, TileEntityEnderQuarry.rand.nextInt(BlockFlower.field_149859_a.length), 3);
            }
        }
        return true;
    }
    finally {
        fakePlayer.setCurrentItemOrArmor(0, (ItemStack)null);
    }
}
项目:CrystalMod    文件:TileEntityMobGrinder.java   
public boolean killNextEntity() {
    if (getWorld().isRemote) return false;

    if (fakePlayer == null){
        fakePlayer = FakePlayerFactory.get((WorldServer) getWorld(), GRINDER);
    }

    killList = getWorld().getEntitiesWithinAABB(EntityLiving.class, getKillBox());

    DamageSource playerSource = DamageSource.causePlayerDamage(fakePlayer);

    if (killList.size() > 0) {
        for(EntityLiving mob : killList){

            boolean riddenByPlayer = mob.getRecursivePassengersByType(EntityPlayer.class).size() > 0;

            if (!mob.isDead && mob.deathTime <= 0 && !mob.isEntityInvulnerable(playerSource) && mob.hurtResistantTime == 0 && !riddenByPlayer) {
                if (mob instanceof EntityZombie) {
                    zBlocker.cache.add((EntityZombie) mob);
                }   

                //if (this.attackTool == null) {
                    //this.attackTool = new ItemStack(Items.DIAMOND_SWORD);
                    /*final ItemStack enchantsStack = this.enchants.getStack();
                    if (enchantsStack != null) {
                        EnchantmentHelper.setEnchantments(EnchantmentHelper.getEnchantments(enchantsStack), this.attackTool);
                    }*/
                //}

                /*ItemStack prev = fakePlayer.getHeldItemMainhand();

                fakePlayer.setHeldItem(EnumHand.MAIN_HAND, attackTool);
                if(prev !=null)fakePlayer.getAttributeMap().removeAttributeModifiers(prev.getAttributeModifiers(EntityEquipmentSlot.MAINHAND));
                if(attackTool !=null)fakePlayer.getAttributeMap().applyAttributeModifiers(attackTool.getAttributeModifiers(EntityEquipmentSlot.MAINHAND));
                //fakePlayer.setPosition(mob.posX, mob.posY, mob.posZ);
                float oldHealth = mob.getHealth();
                this.fakePlayer.attackTargetEntityWithCurrentItem(mob);
                fakePlayer.resetCooldown();
                ModLogger.info("Attack2: "+(oldHealth-mob.getHealth()) + " "+fakePlayer.getHeldItemMainhand());
                this.fakePlayer.setHeldItem(EnumHand.MAIN_HAND, (ItemStack)null);
                */

                mob.attackEntityFrom(playerSource, 50000F);

                readyNext = true;
                return mob.isDead || mob.getHealth() <= 0;
            }
        }
    }
    readyNext = false;
    return false;
}
项目:Toms-Mod    文件:TomsModUtils.java   
public static FakePlayer getFakePlayer(World world) {
    if (world instanceof WorldServer) {
        return FakePlayerFactory.get((WorldServer) world, profile);
    } else
        return null;
}
项目:ThermalRecycling    文件:FakePlayerHelper.java   
private static WeakReference<EntityPlayer> createNewPlayer(final WorldServer world) {
    final EntityPlayer player = FakePlayerFactory.get(world, profile);
    return new WeakReference<EntityPlayer>(player);
}
项目:NightfallMod    文件:MLib.java   
public static FakePlayer getFakePlayer(World w) {
    if (w instanceof WorldServer) return FakePlayerFactory.getMinecraft((WorldServer) w);
    return null;
}
项目:NausicaaMod    文件:MLib.java   
public static FakePlayer getFakePlayer(World w) {
    if (w instanceof WorldServer) return FakePlayerFactory.getMinecraft((WorldServer) w);
    return null;
}
项目:Cauldron    文件:ItemDye.java   
public static boolean func_150919_a(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_)
{
    if (p_150919_1_ instanceof WorldServer)
        return applyBonemeal(p_150919_0_, p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, FakePlayerFactory.getMinecraft((WorldServer)p_150919_1_));
    return false;
}
项目:Cauldron    文件:ItemDye.java   
public static boolean func_150919_a(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_)
{
    if (p_150919_1_ instanceof WorldServer)
        return applyBonemeal(p_150919_0_, p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, FakePlayerFactory.getMinecraft((WorldServer)p_150919_1_));
    return false;
}
项目:EnderAmmunition    文件:TileEntityRockExterminator.java   
public void updateEntity() {
    if (worldObj.isRemote) return;
    int dim = 3 + getDimensionUpgrades() * 2; // tier 2 is 3 + 2*4 = 11 (11x11xtoBedrock)
    int blocksPerTick = getSpeedUpgrades();

    if (miningAtX == Integer.MIN_VALUE || miningAtY == Integer.MIN_VALUE || miningAtZ == Integer.MIN_VALUE) {
        miningAtX = xCoord - dim / 2;
        miningAtY = yCoord - 1;
        miningAtZ = zCoord - dim / 2;
    }
    if (fp == null && worldObj instanceof WorldServer) {
        fp = FakePlayerFactory.get((WorldServer) worldObj, new GameProfile(UUID.randomUUID(), "[EnderAmmunition]"));
    }
    if (miningAtY <= 1) return;
    // TODO: energy consumption (taking eff and unbrk in account)
    Map<Enchantment, Integer> enchantmentMap = getEnchantmentMap();
    boolean silk = enchantmentMap.containsKey(Enchantment.silkTouch);
    int fortune = enchantmentMap.containsKey(Enchantment.fortune) ? enchantmentMap.get(Enchantment.fortune) : 0;
    int efficiencyDivider = enchantmentMap.containsKey(Enchantment.efficiency) ? enchantmentMap.get(Enchantment.efficiency) + 1 : 1;
    int energyConsumption = RF_PER_BLOCK / efficiencyDivider;
    if (storage.getEnergyStored() < energyConsumption * blocksPerTick) return;
    TileEntity inventory = getInventoryAround();
    boolean removeBulk = hasRemoveBulkUpgrade();
    while (blocksPerTick >= 0) {
        miningAtX++;
        //miningAtZ++;
        if (miningAtX >= xCoord + dim / 2) {
            miningAtX = xCoord - dim / 2;
            miningAtZ++;
        }
        if (miningAtZ >= zCoord + dim / 2) {
            miningAtZ = zCoord - dim / 2;
            miningAtY--;
        }
        Block blockToMine = worldObj.getBlock(miningAtX, miningAtY, miningAtZ);
        // skip air (like caves) + skip unminable blocks
        if (blockToMine == Blocks.air || blockToMine.getBlockHardness(worldObj, miningAtX, miningAtY, miningAtZ) < 0) {

            continue;
        }
        List<ItemStack> drops = removeBlock(fp, worldObj, miningAtX, miningAtY, miningAtZ, fortune, silk);
        if (drops == null) {

            continue;
        } else {
            storage.extractEnergy(energyConsumption, false);
        }
        if (removeBulk) {
            List<ItemStack> clearedDrops = Lists.newArrayList();
            for (ItemStack d : drops) {
                boolean remove = false;
                for (ItemStack b : bulkItems) {
                    if (b.getItem() == d.getItem() && b.getItemDamage() == d.getItemDamage()) {
                        remove = true;
                        break;
                    }
                }
                if (!remove)
                    clearedDrops.add(d);
            }
            drops = clearedDrops;
        }
        if (inventory == null) {
            dropAway(drops);
        } else {
            List<ItemStack> leftover = tryToInsertToInventory(drops, inventory);
            if (leftover != null) dropAway(leftover);
        }
        sendParticlePacket();
        blocksPerTick--;

    }
}
项目:PneumaticCraft    文件:TileEntitySentryTurret.java   
private EntityPlayer getFakePlayer(){
    return FakePlayerFactory.get((WorldServer)worldObj, new GameProfile(null, "Sentry Turret"));
}
项目:Battlegear2    文件:DispenseQuiverArrow.java   
/**
 * Simulates a player using a bow to fire the arrow from the container
 * Necessary to build a fake, since redstone doesn't identify source of change
 *
 * @param world where the dispenser is located
 * @return a "fake" player
 */
protected EntityPlayer getUsingPlayer(World world){
    return world instanceof WorldServer ? FakePlayerFactory.getMinecraft((WorldServer)world) : null;
}