List of usage examples for net.minecraftforge.common.util FakePlayerFactory get
public static FakePlayer get(ServerWorld world, GameProfile username)
From source file:aroma1997.betterchests.TileEntityBChest.java
License:Open Source License
@Override public void validate() { super.validate(); if (!worldObj.isRemote) { fplayer = FakePlayerFactory.get((WorldServer) worldObj, new GameProfile("", "Aroma1997BetterChests")); fplayer.posX = xCoord;/*from ww w. ja v a 2s . co m*/ fplayer.posY = yCoord; fplayer.posZ = zCoord; } }
From source file:blusunrize.immersiveengineering.common.util.FakePlayerUtil.java
@SubscribeEvent public static void onLoad(WorldEvent.Load ev) { World world = ev.getWorld();//from w ww . j av a 2s . c o m if (world instanceof WorldServer) fakePlayerInstances.put(world, FakePlayerFactory.get((WorldServer) world, IE_PROFILE)); }
From source file:buildcraft.core.proxy.CoreProxy.java
License:Minecraft Mod Public
private WeakReference<EntityPlayer> createNewPlayer(WorldServer world) { EntityPlayer player = FakePlayerFactory.get(world, BuildCraftCore.gameProfile); return new WeakReference<EntityPlayer>(player); }
From source file:buildcraft.core.proxy.CoreProxy.java
License:Minecraft Mod Public
private WeakReference<EntityPlayer> createNewPlayer(WorldServer world, int x, int y, int z) { EntityPlayer player = FakePlayerFactory.get(world, BuildCraftCore.gameProfile); player.posY = y;//from w ww.ja va 2s . c o m player.posZ = z; return new WeakReference<EntityPlayer>(player); }
From source file:com.bluepowermod.tile.tier1.TileDeployer.java
License:Open Source License
@Override protected void redstoneChanged(boolean newValue) { super.redstoneChanged(newValue); if (!worldObj.isRemote && newValue) { animationTimer = 0;//from w w w. j a v a 2s . c om sendUpdatePacket(); FakePlayer player = FakePlayerFactory.get((WorldServer) worldObj, FAKE_PLAYER_PROFILE); for (int i = 0; i < inventory.length; i++) { ItemStack stack = inventory[i]; player.inventory.setInventorySlotContents(i, stack); } rightClick(player, 9); for (int i = 0; i < inventory.length; i++) { ItemStack stack = player.inventory.getStackInSlot(i); if (stack == null || stack.stackSize <= 0) { inventory[i] = null; } else { inventory[i] = stack; } player.inventory.setInventorySlotContents(i, null); } for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stack = player.inventory.getStackInSlot(i); if (stack != null && stack.stackSize > 0) { ItemStack remainder = IOHelper.insert(this, stack, getFacingDirection().getOpposite(), false); if (remainder != null) { worldObj.spawnEntityInWorld( new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, remainder)); } player.inventory.setInventorySlotContents(i, null); } } } }
From source file:com.lothrazar.cyclicmagic.util.UtilFakePlayer.java
License:Open Source License
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 {//from w w w . j a va 2s .co m fakePlayer = new WeakReference<FakePlayer>(FakePlayerFactory.get(ws, breakerProfile)); } catch (Exception e) { ModCyclic.logger.error("Exception thrown trying to create fake player : ", e); 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; }
From source file:de.ellpeck.actuallyadditions.mod.util.FakePlayerUtil.java
public static FakePlayer getFakePlayer(World world) { if (world instanceof WorldServer) { if (theFakePlayer == null) { theFakePlayer = FakePlayerFactory.get((WorldServer) world, FAKE_PROFILE); }/*from w ww . j av a2 s . co m*/ return theFakePlayer; } else { return null; } }
From source file:forestry.core.proxy.ClientProxyCommon.java
License:Open Source License
@Override public EntityPlayer getPlayer(World world, GameProfile profile) { EntityPlayer player = world.getPlayerEntityByName(profile.getName()); if (player != null) return player; else if (world instanceof WorldServer) return FakePlayerFactory.get((WorldServer) world, profile); else// w ww .ja va2 s . c o m return null; }
From source file:forestry.core.proxy.ProxyCommon.java
License:Open Source License
/** * Get a player for a given World and GameProfile. * If they are not in the World, returns a FakePlayer. * Do not store references to the return value, to prevent worlds staying in memory. *///from w w w . j av a 2s . c o m public EntityPlayer getPlayer(World world, GameProfile profile) { if (world == null) { throw new IllegalArgumentException("World cannot be null"); } if (profile == null || profile.getName() == null) { return FakePlayerFactory.getMinecraft((WorldServer) world); } EntityPlayer player = world.getPlayerEntityByName(profile.getName()); if (player != null) { return player; } else { return FakePlayerFactory.get((WorldServer) world, profile); } }
From source file:hellfirepvp.astralsorcery.common.CommonProxy.java
License:Open Source License
public FakePlayer getASFakePlayerServer(WorldServer world) { return FakePlayerFactory.get(world, new GameProfile(UUID.randomUUID(), "AS-FakePlayer")); }