net.minecraftforge.common.util.FakePlayerFactory Java Examples
The following examples show how to use
net.minecraftforge.common.util.FakePlayerFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CartTools.java From NEI-Integration with MIT License | 6 votes |
/** * 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; }
Example #2
Source File: GregFakePlayer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static FakePlayer get(WorldServer world) { FakePlayer ret = GREGTECH_PLAYER != null ? GREGTECH_PLAYER.get() : null; if (ret == null) { ret = FakePlayerFactory.get(world, GREGTECH); GREGTECH_PLAYER = new WeakReference<>(ret); } return ret; }
Example #3
Source File: BlockUtils.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
public static EntityPlayerMP makePlacer(@Nonnull World world, @Nonnull BlockPos pos, @Nullable Entity entity) { if (entity instanceof EntityPlayerMP) { return (EntityPlayerMP) entity; } EntityPlayerMP bro = FakePlayerFactory.get((WorldServer) world, PLACER); bro.moveToBlockPosAndAngles(pos, 0, -90); bro.setSneaking(true); return bro; }
Example #4
Source File: BlockUtils.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
public static boolean placeBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing facing, @Nonnull ItemStack stack) { if (!world.isBlockLoaded(pos)) return false; FakePlayer player = FakePlayerFactory.get((WorldServer) world, PLACER); player.moveToBlockPosAndAngles(pos, 0, -90); player.setHeldItem(EnumHand.MAIN_HAND, stack); player.setSneaking(true); if (!hasEditPermission(pos, player)) return false; EnumActionResult result = player.interactionManager.processRightClickBlock( player, world, stack, EnumHand.MAIN_HAND, pos, facing, 0, 0, 0); return result != EnumActionResult.FAIL; }
Example #5
Source File: BlockUtils.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
public static EntityPlayerMP makeBreaker(@Nonnull World world, @Nonnull BlockPos pos, @Nullable Entity entity) { if (entity instanceof EntityPlayerMP) { return (EntityPlayerMP) entity; } EntityPlayerMP bro = FakePlayerFactory.get((WorldServer) world, BREAKER); bro.moveToBlockPosAndAngles(pos, 0, -90); return bro; }
Example #6
Source File: TileEntityDrawbridge.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@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; }
Example #7
Source File: TileEntitySentryTurret.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
private EntityPlayer getFakePlayer(){ return FakePlayerFactory.get((WorldServer)worldObj, new GameProfile(null, "Sentry Turret")); }