Search in sources :

Example 6 with IMessage

use of net.minecraftforge.fml.common.network.simpleimpl.IMessage in project Overloaded by CJ-MC-Mods.

the class ItemMultiTool method leftClickOnBlockClient.

@SideOnly(Side.CLIENT)
private void leftClickOnBlockClient(BlockPos pos, Vec3d hitVec) {
    IMessage message = new MultiToolLeftClickMessage(pos);
    Overloaded.proxy.networkWrapper.sendToServer(message);
//        EntityPlayerSP player = Minecraft.getMinecraft().player;
//        drawParticleStreamTo(player, hitVec, EnumParticleTypes.SMOKE_NORMAL);//EnumParticleTypes.TOWN_AURA
}
Also used : MultiToolLeftClickMessage(com.cjm721.overloaded.network.packets.MultiToolLeftClickMessage) IMessage(net.minecraftforge.fml.common.network.simpleimpl.IMessage) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 7 with IMessage

use of net.minecraftforge.fml.common.network.simpleimpl.IMessage in project SilentGems by SilentChaos512.

the class MessageKeyReturnHome method handleMessage.

@Override
public IMessage handleMessage(MessageContext ctx) {
    if (ctx.side != Side.SERVER)
        return null;
    Predicate<ItemStack> predicate = s -> s.getItem() == ModItems.returnHomeCharm;
    EntityPlayer player = ctx.getServerHandler().playerEntity;
    ItemStackList stacks = BaublesCompat.getBaubles(player, predicate);
    stacks.addAll(PlayerHelper.getNonEmptyStacks(player, predicate));
    if (stacks.isEmpty())
        return null;
    ModItems.returnHomeCharm.tryTeleportPlayer(stacks.get(0), player);
    return null;
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemStackList(net.silentchaos512.lib.collection.ItemStackList) MessageContext(net.minecraftforge.fml.common.network.simpleimpl.MessageContext) ModItems(net.silentchaos512.gems.item.ModItems) Predicate(com.google.common.base.Predicate) Side(net.minecraftforge.fml.relauncher.Side) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IMessage(net.minecraftforge.fml.common.network.simpleimpl.IMessage) Message(net.silentchaos512.gems.network.Message) PlayerHelper(net.silentchaos512.lib.util.PlayerHelper) BaublesCompat(net.silentchaos512.gems.compat.BaublesCompat) ItemStackList(net.silentchaos512.lib.collection.ItemStackList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 8 with IMessage

use of net.minecraftforge.fml.common.network.simpleimpl.IMessage in project takumicraft by TNTModders.

the class AbstractPacket method onMessage.

@Override
public IMessage onMessage(AbstractPacket message, MessageContext ctx) {
    EntityPlayer player;
    IMessage reply = null;
    switch(FMLCommonHandler.instance().getEffectiveSide()) {
        case CLIENT:
            if (message instanceof MessageToClient) {
                player = this.getClientPlayer();
                reply = ((MessageToClient) message).handleClientSide(player);
            }
            break;
        case SERVER:
            if (message instanceof MessageToServer) {
                player = ((NetHandlerPlayServer) ctx.netHandler).player;
                reply = ((MessageToServer) message).handleServerSide(player);
            }
            break;
        default:
    }
    return reply;
}
Also used : IMessage(net.minecraftforge.fml.common.network.simpleimpl.IMessage) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

IMessage (net.minecraftforge.fml.common.network.simpleimpl.IMessage)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 Predicate (com.google.common.base.Predicate)2 ItemStack (net.minecraft.item.ItemStack)2 MessageContext (net.minecraftforge.fml.common.network.simpleimpl.MessageContext)2 Side (net.minecraftforge.fml.relauncher.Side)2 BaublesCompat (net.silentchaos512.gems.compat.BaublesCompat)2 Message (net.silentchaos512.gems.network.Message)2 ItemStackList (net.silentchaos512.lib.collection.ItemStackList)2 PlayerHelper (net.silentchaos512.lib.util.PlayerHelper)2 MultiToolLeftClickMessage (com.cjm721.overloaded.network.packets.MultiToolLeftClickMessage)1 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 ItemChaosGem (net.silentchaos512.gems.item.ItemChaosGem)1 ModItems (net.silentchaos512.gems.item.ModItems)1