net.minecraft.entity.player.EntityPlayerMP Java Examples

The following examples show how to use net.minecraft.entity.player.EntityPlayerMP. 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: CraftPlayer.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public void setExtraData(net.minecraft.nbt.NBTTagCompound nbttagcompound) {
    if (!nbttagcompound.hasKey("bukkit")) {
        nbttagcompound.setTag("bukkit", new net.minecraft.nbt.NBTTagCompound());
    }

    net.minecraft.nbt.NBTTagCompound data = nbttagcompound.getCompoundTag("bukkit");
    net.minecraft.entity.player.EntityPlayerMP handle = getHandle();
    data.setInteger("newExp", handle.newExp);
    data.setInteger("newTotalExp", handle.newTotalExp);
    data.setInteger("newLevel", handle.newLevel);
    data.setInteger("expToDrop", handle.expToDrop);
    data.setBoolean("keepLevel", handle.keepLevel);
    data.setLong("firstPlayed", getFirstPlayed());
    data.setLong("lastPlayed", System.currentTimeMillis());
    data.setString("lastKnownName", handle.getCommandSenderName());
}
 
Example #2
Source File: ItemEnderBag.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static boolean targetOutsideOfPlayerRange(ItemStack stack, EntityPlayer player)
{
    TargetData target = TargetData.getTargetFromSelectedModule(stack, ModuleType.TYPE_LINKCRYSTAL);

    if (target == null)
    {
        return true;
    }

    // We allow a max range of 64 blocks, to hopefully be on the safer side
    //return target.dimension != player.dimension || player.getDistanceSq(target.posX, target.posY, target.posZ) >= 4096.0d;

    WorldServer world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(target.dimension);

    if ((player instanceof EntityPlayerMP) == false || world == null ||
         world.getPlayerChunkMap().isPlayerWatchingChunk((EntityPlayerMP) player, target.pos.getX() >> 4, target.pos.getZ() >> 4) == false)
    {
        return true;
    }

    return false;
}
 
Example #3
Source File: TileEntityShipHelm.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@Override
void processControlMessage(PilotControlsMessage message, EntityPlayerMP sender) {
    double rotationDelta = 0;
    if (message.airshipLeft_KeyDown) {
        rotationDelta -= 12.5D;
    }
    if (message.airshipRight_KeyDown) {
        rotationDelta += 12.5D;
    }
    IBlockState blockState = this.getWorld().getBlockState(getPos());
    if (blockState.getBlock() instanceof BlockShipHelm) {
        EnumFacing facing = blockState.getValue(BlockShipHelm.FACING);
        if (this.isPlayerInFront(sender, facing)) {
            wheelRotation += rotationDelta;
        } else {
            wheelRotation -= rotationDelta;
        }
    }
    double max_rotation = 720D;
    wheelRotation = Math.min(Math.max(wheelRotation, -max_rotation), max_rotation);
}
 
Example #4
Source File: CommandGenPearl.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, @NotNull String[] args) {
	Entity entity = sender.getCommandSenderEntity();
	if (entity instanceof EntityPlayerMP) {
		ItemStack item = new ItemStack(ModItems.PEARL_NACRE);


		List<ItemStack> recipe = new ArrayList<>();
		recipe.add(ModuleRegistry.INSTANCE.getModules(ModuleType.SHAPE).get(RandUtil.nextInt(ModuleRegistry.INSTANCE.getModules(ModuleType.SHAPE).size() - 1)).getItemStack());
		recipe.add(ModuleRegistry.INSTANCE.getModules(ModuleType.EFFECT).get(RandUtil.nextInt(ModuleRegistry.INSTANCE.getModules(ModuleType.EFFECT).size() - 1)).getItemStack());
		recipe.add(new ItemStack(ModItems.DEVIL_DUST));

		SpellBuilder builder = new SpellBuilder(recipe, 1);

		NBTTagList list = new NBTTagList();
		for (SpellRing spellRing : builder.getSpell())
			list.appendTag(spellRing.serializeNBT());
		NBTHelper.setList(item, NBTConstants.NBT.SPELL, list);
		NBTHelper.setBoolean(item, "infused", true);

		((EntityPlayerMP) entity).addItemStackToInventory(item);
		((EntityPlayerMP) entity).openContainer.detectAndSendChanges();
	} else notifyCommandListener(sender, this, "wizardry.command.notplayer");
}
 
Example #5
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static BlockBreakEvent callBlockBreakEvent(net.minecraft.world.World world, BlockPos pos, IBlockState state, EntityPlayerMP player) {
    Block bBlock = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
    BlockBreakEvent bbe = new BlockBreakEvent(bBlock, player.getBukkitEntity());
    EntityPlayerMP playermp = player;
    net.minecraft.block.Block block = state.getBlock();
    if (!(playermp instanceof FakePlayer)) {
        boolean isSwordNoBreak = playermp.interactionManager.getGameType().isCreative() && !playermp.getHeldItemMainhand().isEmpty() && playermp.getHeldItemMainhand().getItem() instanceof ItemSword;
        if (!isSwordNoBreak) {
            int exp = 0;
            if (!(block == null || !player.canHarvestBlock(block.getDefaultState()) || block.canSilkHarvest(world, pos, block.getBlockState().getBaseState(), player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0)) {
                int bonusLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, player.getHeldItemMainhand());
                exp = block.getExpDrop(state, world, pos, bonusLevel);
            }
            bbe.setExpToDrop(exp);
        } else {
            bbe.setCancelled(true);
        }
    }

    world.getServer().getPluginManager().callEvent(bbe);
    return bbe;
}
 
Example #6
Source File: ServerStateMachine.java    From malmo with MIT License 6 votes vote down vote up
private void resetPlayerGameTypes()
{
    // Go through and set all the players to their correct game type:
    for (Map.Entry<String, String> entry : this.usernameToAgentnameMap.entrySet())
    {
        AgentSection as = getAgentSectionFromAgentName(entry.getValue());
        EntityPlayerMP player = getPlayerFromUsername(entry.getKey());
        if (as != null && player != null)
        {
            player.setGameType(GameType.getByName(as.getMode().name().toLowerCase()));
            // Also make sure we haven't accidentally left the player flying:
            player.capabilities.isFlying = false;
            player.sendPlayerAbilities();
        }
    }
}
 
Example #7
Source File: BlockPortalBase.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Called when the block is right clicked by a player.
 */
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (world.isRemote || !(playerIn instanceof EntityPlayerMP))
    {
        return true;
    }
    else
    {
        EntityPlayerMP entityplayermp = (EntityPlayerMP)playerIn;

        if (entityplayermp.connection.getNetworkManager().isChannelOpen() && entityplayermp.world == world && !entityplayermp.isPlayerSleeping())
        {
            
         if (playerIn.isRiding())
         {
         	playerIn.dismountRidingEntity();
         }

         playerIn.setPositionAndUpdate(world.rand.nextDouble()*2000000D-1000000D, 2550D, world.rand.nextDouble()*2000000D-1000000D);
         
        }
        return true;
    }
}
 
Example #8
Source File: ComponentObscurity.java    From Artifacts with MIT License 6 votes vote down vote up
@Override
	public boolean hitEntity(ItemStack itemStack, EntityLivingBase entityVictim, EntityLivingBase entityAttacker) {
		EntityPlayerMP player = UtilsForComponents.getPlayerFromUsername(entityAttacker.getCommandSenderName());
		
		if(player != null) {
			player.addPotionEffect(new PotionEffect(14, 600, 0));
			
			PacketBuffer out = new PacketBuffer(Unpooled.buffer());
			
			out.writeInt(PacketHandlerClient.OBSCURITY);
			SToCMessage packet = new SToCMessage(out);
			DragonArtifacts.artifactNetworkWrapper.sendTo(packet, player);
			
			//System.out.println("Cloaking player.");
			itemStack.damageItem(1, player);
//			UtilsForComponents.sendItemDamagePacket(entityAttacker, entityAttacker.inventory.currentItem, 1); //itemStack.damageItem(1, player);
//			itemStack.stackTagCompound.setInteger("onItemRightClickDelay", 200);
		}
		return false;
	}
 
Example #9
Source File: BlockUtils.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Breaks the block as a player, and thus drops the item(s) from it
 */
public static void breakBlockAsPlayer(World world, BlockPos pos, EntityPlayerMP playerMP, ItemStack toolStack)
{
    PlayerInteractionManager manager = playerMP.interactionManager;
    int exp = ForgeHooks.onBlockBreakEvent(world, manager.getGameType(), playerMP, pos);

    if (exp != -1)
    {
        IBlockState stateExisting = world.getBlockState(pos);
        Block blockExisting = stateExisting.getBlock();

        blockExisting.onBlockHarvested(world, pos, stateExisting, playerMP);
        boolean harvest = blockExisting.removedByPlayer(stateExisting, world, pos, playerMP, true);

        if (harvest)
        {
            blockExisting.onPlayerDestroy(world, pos, stateExisting);
            blockExisting.harvestBlock(world, playerMP, pos, stateExisting, world.getTileEntity(pos), toolStack);
        }
    }
}
 
Example #10
Source File: MessageQuestUpdate.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
@Override
public IMessage onMessage(final MessageQuestUpdate message, MessageContext ctx) {
	if (ctx.side != Side.SERVER) {
		return null;
	}

	final EntityPlayerMP player = ctx.getServerHandler().player;

	if (player == null) {
		return null;
	}

	final WorldServer worldServer = player.getServerWorld();

	worldServer.addScheduledTask(new Runnable() {
		@Override
		public void run() {
			new Worker(message.action).work(message, player);
		}
	});

	return null;
}
 
Example #11
Source File: GT_TileEntity_BioVat.java    From bartworks with MIT License 6 votes vote down vote up
private void check_Chunk() {
    World aWorld = this.getBaseMetaTileEntity().getWorld();
    if (!aWorld.isRemote) {

        for (Object tObject : aWorld.playerEntities) {
            if (!(tObject instanceof EntityPlayerMP)) {
                break;
            }
            EntityPlayerMP tPlayer = (EntityPlayerMP) tObject;
            Chunk tChunk = aWorld.getChunkFromBlockCoords(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getZCoord());
            if (tPlayer.getServerForPlayer().getPlayerManager().isPlayerWatchingChunk(tPlayer, tChunk.xPosition, tChunk.zPosition)) {
                if (!this.playerMPHashSet.contains(tPlayer)) {
                    this.playerMPHashSet.add(tPlayer);
                    this.sendAllRequiredRendererPackets();
                }
            } else {
                this.playerMPHashSet.remove(tPlayer);
            }

        }
    }
}
 
Example #12
Source File: PacketRemovePearlFromBelt.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void handle(@NotNull MessageContext ctx) {
	EntityPlayerMP player = ctx.getServerHandler().player;

	ItemStack stack = player.getHeldItemMainhand();

	if (stack.getItem() instanceof IPearlStorageHolder) {
		IPearlStorageHolder holder = (IPearlStorageHolder) stack.getItem();
		int originalPearlCount = holder.getPearlCount(stack);

		ItemStack pearl = holder.removePearl(stack, index, true);
		player.addItemStackToInventory(pearl);

		int newPearlCount = holder.getPearlCount(stack);

		PacketHandler.NETWORK.sendTo(new PacketUpdatePearlGUI(originalPearlCount, newPearlCount, index, null, stack.getTagCompound()), player);
	}
}
 
Example #13
Source File: ObservationFromServer.java    From malmo with MIT License 6 votes vote down vote up
/** IMPORTANT: Call this from the onMessage method in the subclass. */
public IMessage processMessage(ObservationRequestMessage message, MessageContext ctx)
{
    IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.world;
    final EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    final ObservationRequestMessage mess = message;
    mainThread.addScheduledTask(new Runnable()
    {
        @Override
        public void run()
        {
            JsonObject json = new JsonObject();
            buildJson(json, player, mess);
            // Send this message back again now we've filled in the json stats.
            Map<String, String> returnData = new HashMap<String, String>();
            returnData.put("json", json.toString());
            mess.addReturnData(returnData);
            MalmoMod.network.sendTo(new MalmoMod.MalmoMessage(MalmoMessageType.SERVER_OBSERVATIONSREADY, mess.id, returnData), player);
        }
    });
    return null; // no response in this case
}
 
Example #14
Source File: MessageRequestPlayerCivilizationSync.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
@Override
public IMessage onMessage(final MessageRequestPlayerCivilizationSync message, MessageContext ctx) {
	if (ctx.side != Side.SERVER) {
		return null;
	}

	final EntityPlayerMP player = ctx.getServerHandler().player;

	if (player == null) {
		return null;
	}

	final WorldServer worldServer = player.getServerWorld();

	worldServer.addScheduledTask(new Runnable() {
		@Override
		public void run() {
			PlayerCivilizationCapabilityImpl.get(player).syncClient();
		}
	});

	return null;
}
 
Example #15
Source File: NEIServerUtils.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public static void givePlayerItem(EntityPlayerMP player, ItemStack stack, boolean infinite, boolean doGive) {
    if (stack.getItem() == null) {
        player.sendMessage(setColour(new TextComponentTranslation("nei.chat.give.noitem"), TextFormatting.WHITE));
        return;
    }

    int given = stack.getCount();
    if (doGive) {
        if (infinite) {
            player.inventory.addItemStackToInventory(stack);
        } else {
            given -= InventoryUtils.insertItem(player.inventory, stack, false);
        }
    }

    sendNotice(player, new TextComponentTranslation("commands.give.success", stack.getTextComponent(), infinite ? "\u221E" : Integer.toString(given), player.getName()), "notify-item");
    player.openContainer.detectAndSendChanges();
}
 
Example #16
Source File: JSONWorldDataHelper.java    From malmo with MIT License 5 votes vote down vote up
/** Builds the player position data to be used as observation signals by the listener.
 * @param json a JSON object into which the positional information will be added.
 */
public static void buildPositionStats(JsonObject json, EntityPlayerMP player)
{
    json.addProperty("XPos",  player.posX);
    json.addProperty("YPos",  player.posY);
    json.addProperty("ZPos", player.posZ);
    json.addProperty("Pitch",  player.rotationPitch);
    json.addProperty("Yaw", player.rotationYaw);
}
 
Example #17
Source File: EventHandler.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onJoinWorld(EntityJoinWorldEvent event){
    if(!event.getWorld().isRemote && event.getEntity() instanceof EntityPlayer) {
        RailNetworkManager.getInstance(event.getWorld().isRemote).onPlayerJoin((EntityPlayerMP)event.getEntity());
    }
    if(!event.getWorld().isRemote && event.getEntity() instanceof EntityMinecart) {
        RailNetworkManager.getInstance(event.getWorld().isRemote).onMinecartJoinedWorld((EntityMinecart)event.getEntity());
        CapabilityMinecartDestination cap = event.getEntity().getCapability(CapabilityMinecartDestination.INSTANCE, null);
        if(cap != null) cap.onCartJoinWorld((EntityMinecart)event.getEntity());
    }
}
 
Example #18
Source File: JSONWorldDataHelper.java    From malmo with MIT License 5 votes vote down vote up
/** Builds the basic life world data to be used as observation signals by the listener.
 * @param json a JSON object into which the life stats will be added.
 */
public static void buildLifeStats(JsonObject json, EntityPlayerMP player)
{
    json.addProperty("Life", player.getHealth());
    json.addProperty("Score", player.getScore());    // Might always be the same as XP?
    json.addProperty("Food", player.getFoodStats().getFoodLevel());
    json.addProperty("XP", player.experienceTotal);
    json.addProperty("IsAlive", !player.isDead);
    json.addProperty("Air", player.getAir());
    json.addProperty("Name", player.getName());
}
 
Example #19
Source File: Resident.java    From MyTown2 with The Unlicense 5 votes vote down vote up
/**
 * Respawns the player at town's spawn point or, if that doesn't exist, at his own spawn point.
 */
public void respawnPlayer() {
    if (townsContainer.getMainTown() != null) {
        townsContainer.getMainTown().sendToSpawn(this);
        return;
    }

    ChunkCoordinates spawn = player.getBedLocation(player.dimension);
    if (spawn == null)
        spawn = player.worldObj.getSpawnPoint();
    ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(spawn.posX, spawn.posY, spawn.posZ, player.rotationYaw, player.rotationPitch);
}
 
Example #20
Source File: MoCEntityFox.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean interact(EntityPlayer entityplayer)
{
    if (super.interact(entityplayer)) { return false; }
    ItemStack itemstack = entityplayer.inventory.getCurrentItem();
    if ((itemstack != null) && ((itemstack.itemID == MoCreatures.rawTurkey.itemID)))
    {
        if (--itemstack.stackSize == 0)
        {
            entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null);
        }

        if (MoCreatures.isServer())
        {
            MoCTools.tameWithName((EntityPlayerMP) entityplayer, this);
        }
        health = getMaxHealth();

        if (MoCreatures.isServer() && !getIsAdult() && (getEdad() < 100))
        {
            setEdad(getEdad() + 1);
        }

        return true;
    }
    return false;
}
 
Example #21
Source File: ServerStateMachine.java    From malmo with MIT License 5 votes vote down vote up
private void initialiseEnderInventory(EntityPlayerMP player, EnderBoxInventory inventory)
{
    player.getInventoryEnderChest().clear();
    for (JAXBElement<? extends InventoryObjectType> el : inventory.getInventoryObject())
    {
        InventoryObjectType obj = el.getValue();
        ItemStack item = itemStackFromInventoryObject(obj);
        if( item != null )
        {
            player.getInventoryEnderChest().setInventorySlotContents(obj.getSlot(), item);
        }
    }
}
 
Example #22
Source File: PacketHolder.java    From LookingGlass with GNU General Public License v3.0 5 votes vote down vote up
public int sendPacket() {
	if (packet != null) {
		LookingGlassPacketManager.bus.sendTo(packet, (EntityPlayerMP) player);
		return packet.payload().writerIndex();
	}
	return 0;
}
 
Example #23
Source File: ContainerEnderUtilities.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Syncs the locked status and the current template ItemStack in a lockable inventory.
 * The current values are cached into the provided boolean and ItemStack arrays.
 * The locked status is sent via a sendProgressBarUpdate, using the id <b>progressBarId</b>.
 * The value for that is in the form '(locked ? 0x8000 : 0) | slot'.
 *
 * @param inv the lockable inventory to sync the locked status and template stacks from
 * @param typeId The id that is used in the MessageSyncCustomSlot packet
 * @param progressBarId The id to use in the sendProgressBarUpdate for the locked status
 * @param lockedLast an array for caching the locked status
 * @param templateStacksLast a list for caching the template stacks
 */
protected void syncLockableSlots(ItemStackHandlerLockable inv, int typeId, int progressBarId,
        boolean[] lockedLast, NonNullList<ItemStack> templateStacksLast)
{
    final int numSlots = inv.getSlots();

    for (int slot = 0; slot < numSlots; slot++)
    {
        boolean locked = inv.isSlotLocked(slot);

        if (lockedLast[slot] != locked)
        {
            for (int i = 0; i < this.listeners.size(); i++)
            {
                this.listeners.get(i).sendWindowProperty(this, progressBarId, (locked ? 0x8000 : 0) | slot);
            }

            lockedLast[slot] = locked;
        }

        ItemStack templateStack = inv.getTemplateStackInSlot(slot);

        if (InventoryUtils.areItemStacksEqual(templateStacksLast.get(slot), templateStack) == false)
        {
            for (int i = 0; i < this.listeners.size(); i++)
            {
                IContainerListener listener = this.listeners.get(i);

                if (listener instanceof EntityPlayerMP)
                {
                    PacketHandler.INSTANCE.sendTo(
                        new MessageSyncCustomSlot(this.windowId, typeId, slot, templateStack), (EntityPlayerMP) listener);
                }
            }

            templateStacksLast.set(slot, templateStack.copy());
        }
    }
}
 
Example #24
Source File: ContainerSynchronised.java    From CodeChickenCore with MIT License 5 votes vote down vote up
@Override
public void sendContainerAndContentsToPlayer(Container container, List<ItemStack> list, List<EntityPlayerMP> playerCrafters)
{
    super.sendContainerAndContentsToPlayer(container, list, playerCrafters);
    for(int i = 0; i < syncVars.size(); i++)
    {
        IContainerSyncVar var = syncVars.get(i);
        PacketCustom packet = createSyncPacket();
        packet.writeByte(i);
        var.writeChange(packet);
        var.reset();
        for(EntityPlayerMP player : playerCrafters)
            packet.sendToPlayer(player);
    }
}
 
Example #25
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerChangedWorld(EntityJoinWorldEvent event) {
    Entity entity = event.getEntity();
    if (!(entity instanceof EntityPlayerMP)) {
        return;
    }
    EntityPlayerMP player = (EntityPlayerMP) entity;
    if (player.world.isRemote) {
        return;
    }
}
 
Example #26
Source File: PacketSuccPearlsToStorageHolder.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void handle(@NotNull MessageContext ctx) {
	EntityPlayerMP player = ctx.getServerHandler().player;

	ItemStack stack = player.getHeldItemMainhand();

	if (stack.getItem() instanceof IPearlStorageHolder) {
		IPearlStorageHolder holder = (IPearlStorageHolder) stack.getItem();
		int originalPearlCount = holder.getPearlCount(stack);

		holder.succPearls(player);

		PacketHandler.NETWORK.sendTo(new PacketUpdatePearlGUI(originalPearlCount, holder.getPearlCount(stack), null, stack.getTagCompound()), player);
	}
}
 
Example #27
Source File: Town.java    From MyTown2 with The Unlicense 5 votes vote down vote up
public void sendToSpawn(Resident res) {
    EntityPlayer pl = res.getPlayer();
    if (pl != null) {
        PlayerUtils.teleport((EntityPlayerMP)pl, spawn.getDim(), spawn.getX(), spawn.getY(), spawn.getZ());
        res.setTeleportCooldown(Config.instance.teleportCooldown.get());
    }
}
 
Example #28
Source File: NEIServerPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void setInventorySlot(EntityPlayerMP player, PacketCustom packet) {
    boolean container = packet.readBoolean();
    int slot = packet.readShort();
    ItemStack item = packet.readItemStack();

    ItemStack old = NEIServerUtils.getSlotContents(player, slot, container);
    boolean deleting = item.isEmpty() || !old.isEmpty() && NEIServerUtils.areStacksSameType(item, old) && item.getCount() < old.getCount();
    if (NEIServerConfig.canPlayerPerformAction(player.getName(), deleting ? "delete" : "item")) {
        NEIServerUtils.setSlotContents(player, slot, item, container);
    }
}
 
Example #29
Source File: ForgeCommand.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute(MinecraftServer minecraftServer, ICommandSender sender, String[] args) throws CommandException {
    if ((sender instanceof EntityPlayerMP)) {
        EntityPlayerMP player = (EntityPlayerMP) sender;
        if (player.worldObj.isRemote) {
            return;
        }
        FawePlayer<Object> fp = FawePlayer.wrap(player);
        cmd.executeSafe(fp, args);
    }
}
 
Example #30
Source File: WRCoreSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
private void decrementSlot(EntityPlayerMP player, int slot) {
    try {
        ItemStack item = player.inventory.mainInventory[slot];
        item.stackSize--;

        if (item.stackSize == 0) {
            player.inventory.mainInventory[slot] = null;
        }
    } catch (ArrayIndexOutOfBoundsException e) {}
}