Java Code Examples for cpw.mods.fml.common.network.simpleimpl.MessageContext

The following are top voted examples for showing how to use cpw.mods.fml.common.network.simpleimpl.MessageContext. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: PAYDAY   File: LobbyBeginGamePacketHandler.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(LobbyBeginGamePacket packet, MessageContext ctx) {
	int x = packet.x;
	int y = packet.y;
	int z = packet.z;

	World w = ctx.getServerHandler().playerEntity.worldObj;

	TileEntity te = w.getTileEntity(x, y, z);

	if (te != null && te instanceof LobbyTileEntity) {
		LobbyTileEntity tile = (LobbyTileEntity) te;

		tile.setGameLive(true);

		for (EntityPlayer p : UUIDUtil.getPlayersFromProfileUUIDs(w, tile.players))
			p.travelToDimension(PAYDAY.dimensionID);
	}

	return null;
}
 
Example 2
Project: PAYDAY   File: LobbyPlayerOpenedGuiPacketHandler.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(LobbyPlayerOpenedGuiPacket packet, MessageContext ctx) {
	// SERVER
	int x = packet.x;
	int y = packet.y;
	int z = packet.z;

	EntityPlayerMP p = ctx.getServerHandler().playerEntity;

	World w = p.worldObj;
	if (w == null)
		return null;

	LobbyTileEntity tile = (LobbyTileEntity) w.getTileEntity(x, y, z);

	if (tile == null)
		return null;
	
	PAYDAY.INSTANCE.sendTo(new PacketSyncTileEntityClient(tile), p);

	return null;
}
 
Example 3
Project: PAYDAY   File: PacketSyncPlayerPropertiesServerHandler.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(final PacketSyncPlayerPropertiesServer packet, final MessageContext ctx) {
	// SERVER
	new Thread() {
		@Override
		public void run() {
			EntityPlayerMP player = ctx.getServerHandler().playerEntity;
			
			PlayerData data = PlayerData.get(player);
			data.setInLobby(packet.inLobby);
			data.setReady(packet.ready);
			
			PAYDAY.INSTANCE.sendToAll(new PacketSyncPlayerPropertiesClient(player.getGameProfile().getId(), packet.ready, packet.inLobby));
		}
	}.start();

	return null;
}
 
Example 4
Project: MineDonate   File: SupportedFeaturesPacketHandler.java   View source code 6 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(SupportedFeaturesPacket message, MessageContext ctx) {
	
    MineDonate.cfg.sellItems = message.items;
    MineDonate.cfg.itemsMoneyType = message.itemsMoneyType;
    MineDonate.cfg.sellPrivelegies = message.privelegies;
    MineDonate.cfg.privelegiesMoneyType = message.privelegiesMoneyType;
    MineDonate.cfg.sellRegions = message.regions;
    MineDonate.cfg.regionMoneyType = message.regionsMoneyType;
    MineDonate.cfg.sellEntities = message.entities;
    MineDonate.cfg.entitiesMoneyType = message.entitiesMoneyType;
    MineDonate.cfg.userShops = message.userShops;

    MineDonate . loadClientMerch ( ) ;
    
    ShopGUI . instance . defaultCategory = message . firstCatId ;

    return null;
    
}
 
Example 5
Project: HazardsLib   File: MsgSyncRadiation.java   View source code 6 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(MsgSyncRadiation message, MessageContext ctx)
{
	PlayerTracker tracker = TrackerManager.lookupTrackerFromUsername(Minecraft.getMinecraft().thePlayer.getCommandSenderName());
	
	if (tracker == null) {
		tracker = new PlayerTracker(Minecraft.getMinecraft().thePlayer);
		TrackerManager.addToManager(tracker);
		System.out.println("Tracker == null? Add new!");
	}
	
	
	if (tracker != null) {
		tracker.prevRadiation = tracker.radiation;
		tracker.radiation = message.radiation;
	}
	
	//System.out.println("RECV! " + message.radiation);

	return null;
}
 
Example 6
Project: Ye-Olde-Chat   File: MessageSyncRoleplayMode.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(MessageSyncRoleplayMode message, MessageContext ctx)
{
    EntityPlayer player = YeOldeChat.proxy.getPlayerFromMessageContext(ctx);
    if (player == null)
        return null;
    
    PlayerRoleplayMode props = PlayerRoleplayMode.get(player);
    if (props == null) {
    	return null;
    }
    
    if (player.worldObj.isRemote)
    props.setRoleplayMode(message.roleplayMode, true);
    
    return null;
}
 
Example 7
Project: Ye-Olde-Chat   File: ClientProxy.java   View source code 6 votes vote down vote up
@Override
public EntityPlayer getPlayerFromMessageContext(MessageContext ctx)
{
    switch (ctx.side)
    {
        case CLIENT:
        {
            EntityPlayer entityClientPlayerMP = Minecraft.getMinecraft().thePlayer;
            return entityClientPlayerMP;
        }
        case SERVER:
        {
            EntityPlayer entityPlayerMP = ctx.getServerHandler().playerEntity;
            return entityPlayerMP;
        }
        default:
        {
            break;
        }
    }
    return null;
}
 
Example 8
Project: Ye-Olde-Chat   File: CommonProxy.java   View source code 6 votes vote down vote up
public EntityPlayer getPlayerFromMessageContext(MessageContext ctx)
{
    switch (ctx.side)
    {
        case SERVER:
        {
            EntityPlayer entityPlayerMP = ctx.getServerHandler().playerEntity;
            return entityPlayerMP;
        }
        default:
        {
            break;
        }
    }
    return null;
}
 
Example 9
Project: CustomNEIPlugins   File: PacketClientCommand.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(PacketClientCommand message, MessageContext ctx) {
    switch (message.commandType) {
    case 0: // Command /cnp reload
        ConfigLoader.reloadPlugins();
        Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("customneiplugins.command.reload.info", ConfigLoader.loadedPlugins.size()));
        break;
    case 1: // Command /cnp status
        Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("customneiplugins.command.status.info", ConfigLoader.loadedPlugins.size(), ConfigLoader.disabledPlugins.size(), ConfigLoader.erroredPlugins.size()));
        for (String loadedPluginName: ConfigLoader.loadedPlugins)
            Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("customneiplugins.command.status_loaded.info", loadedPluginName));
        for (String disabledPluginName: ConfigLoader.disabledPlugins)
            Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("customneiplugins.command.status_disabled.info", disabledPluginName));
        for (String erroredPluginName: ConfigLoader.erroredPlugins)
            Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("customneiplugins.command.status_errored.info", erroredPluginName));
    }
    return null;
}
 
Example 10
Project: NoteblockTweak   File: BlockMessageHandler.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(BlockMessage message, MessageContext ctx) {
	/*int d = message.dimension == 0 ? 0 : (message.dimension == -1 ? 1 : 2);
	switch(message.id){
	case 0:
	MinecraftServer.getServer().worldServers[d].setBlock(message.x, message.y - 1, message.z, Blocks.planks);break;
	case 1:
	MinecraftServer.getServer().worldServers[d].setBlock(message.x, message.y - 1, message.z, Blocks.dirt);break;
	case 2:
	MinecraftServer.getServer().worldServers[d].setBlock(message.x, message.y - 1, message.z, Blocks.stone);break;
	}*/
	int d = message.dimension == 0 ? 0 : (message.dimension == -1 ? 1 : 2);
	switch(message.id){
	case 0:
		ctx.getServerHandler().playerEntity.worldObj.setBlock(message.x, message.y - 1, message.z, Blocks.planks);break;
	case 1:
		ctx.getServerHandler().playerEntity.worldObj.setBlock(message.x, message.y - 1, message.z, Blocks.dirt);break;
	case 2:
		ctx.getServerHandler().playerEntity.worldObj.setBlock(message.x, message.y - 1, message.z, Blocks.stone);break;
	}
	TileEntityNote entity = (TileEntityNote) ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z);
	entity.note = (byte) message.note;
	entity.triggerNote(ctx.getServerHandler().playerEntity.worldObj, message.x, message.y, message.z);
	return null;
}
 
Example 11
Project: Rival-Rebels-Mod   File: ADSUpdatePacket.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(ADSUpdatePacket m, MessageContext ctx)
{
	TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
	
	if (te instanceof TileEntityReciever)
	{
		TileEntityReciever ter = (TileEntityReciever) te;
		ter.yawLimit = m.range;
		ter.kMobs = m.mob;
		ter.kTeam = m.chip;
		ter.kPlayers = m.player;
		ter.hasWeapon = m.haswep;
		ter.username = m.user;
	}
	return null;
}
 
Example 12
Project: Rival-Rebels-Mod   File: EntityDebrisPacket.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(EntityDebrisPacket m, MessageContext ctx)
{
	Iterator iter = Minecraft.getMinecraft().theWorld.loadedEntityList.iterator();
	while (iter.hasNext())
	{
		Entity e = (Entity) iter.next();
		if (e.getEntityId() == m.id && e instanceof EntityDebris)
		{
			EntityDebris ed = (EntityDebris) e;
			ed.block = m.block;
			ed.metadata = m.metadata;
			break;
		}
	}
	return null;
}
 
Example 13
Project: Rival-Rebels-Mod   File: ItemUpdate.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(ItemUpdate message, MessageContext ctx)
{
	ItemStack itemstack = ctx.getServerHandler().playerEntity.inventory.getStackInSlot(message.item);
	if (itemstack.getItem() instanceof ItemTesla)
	{
		if (itemstack.stackTagCompound == null) itemstack.stackTagCompound = new NBTTagCompound();
		itemstack.stackTagCompound.setInteger("dial", message.value);
	}
	if (itemstack.getItem() instanceof ItemFlameThrower)
	{
		if (itemstack.stackTagCompound == null) itemstack.stackTagCompound = new NBTTagCompound();
		itemstack.stackTagCompound.setInteger("mode", message.value);
	}
	return null;
}
 
Example 14
Project: Rival-Rebels-Mod   File: TextPacket.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(TextPacket m, MessageContext ctx)
{
	if (m.text.startsWith("-t"))
	{
		String[] str = m.text.substring(2, m.text.length()).split("\n");
		for (int i = 0; i < str.length; i++) Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(str[i]));
	}
	else
	{
		String[] s = m.text.split(" ");
		StringBuilder strb = new StringBuilder();
		for (int i = 0; i < s.length; i++)
		{
			strb.append(StatCollector.translateToLocal(s[i]));
			strb.append(" ");
		}
		Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(strb.toString()));
	}
	return null;
}
 
Example 15
Project: Rival-Rebels-Mod   File: EntityGorePacket.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(EntityGorePacket m, MessageContext ctx)
{
	Iterator iter = Minecraft.getMinecraft().theWorld.loadedEntityList.iterator();
	while (iter.hasNext())
	{
		Entity e = (Entity) iter.next();
		if (e.getEntityId() == m.id && e instanceof EntityGore)
		{
			EntityGore eg = (EntityGore) e;
			eg.mob = m.mob;
			eg.type = m.type;
			eg.greenblood = m.green;
			
			if (m.mob == 0) eg.username = m.username;
			if (m.mob == 11) eg.size = m.size;
			break;
		}
	}
	return null;
}
 
Example 16
Project: RFUtilities   File: PacketDialerChangeMode.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(PacketDialerChangeMode message, MessageContext ctx)
{
    ItemStack dialer = null;
    InventoryPlayer inv = ctx.getServerHandler().playerEntity.inventory;
    for (int i = 0; i < inv.getSizeInventory(); i++)
    {
        if (inv.getStackInSlot(i) != null && inv.getStackInSlot(i).getItem() instanceof ItemDialer)
        {
            dialer = inv.getStackInSlot(i);
            dialer.stackTagCompound.setBoolean("modeDial", !dialer.stackTagCompound.getBoolean("modeDial"));
            break;
        }
    }
    return null;
}
 
Example 17
Project: Avaritiaddons   File: InfinityChestConfirmation.java   View source code 6 votes vote down vote up
@Override
public InfinityChestConfirmation onMessage(final InfinityChestConfirmation message, final MessageContext ctx)
{
	final EntityPlayer entityPlayer = ctx.side == Side.SERVER ? ctx.getServerHandler().playerEntity : Avaritiaddons.proxy.getEntityPlayerFromContext(ctx);
	switch (ctx.side) {
		case CLIENT:
			Container container = null;
			if (message.windowID == 0)
				container = entityPlayer.inventoryContainer;
			else if (message.windowID == entityPlayer.openContainer.windowId)
				container = entityPlayer.openContainer;
			return container != null && !message.confirmed ? new InfinityChestConfirmation(message.windowID, message.transactionID, true) : null;
		case SERVER:
			final short transactionId = transactionMap.get(message.windowID);
			if (transactionId != -1 && message.transactionID == transactionId && entityPlayer.openContainer.windowId == message.windowID && !entityPlayer.openContainer.isPlayerNotUsingContainer(entityPlayer))
				entityPlayer.openContainer.setPlayerIsPresent(entityPlayer, true);
			return new InfinityChestConfirmation(message.windowID, message.transactionID, true);
		default:
			return null;
	}
}
 
Example 18
Project: GTVeinLocator   File: ClientWaypointPacketHandler.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(ClientWaypointPacket message, MessageContext ctx) {
    if (LoadedModHelper.supportMod == null) 
        return null;
    else if (!LoadedModHelper.failedCompat) {
        int targetY = message.posY==-1? ModConfig.waypointYLevelEliteLocator: message.posY;
        switch(LoadedModHelper.supportMod) {
        case JOURNEYMAP:
            if (!JourneyMapHelper.isWaypointExist(message.posX, message.posZ, message.dimId, true))
                JourneyMapHelper.addWaypoint(I18n.format(message.wpName), message.posX, targetY, message.posZ, message.dimId);        
            break;
        case XAEROMINIMAP:
            if (!XaeroMinimapHelper.isWaypointExist(message.posX, message.posZ, true))
                XaeroMinimapHelper.addWaypoint(I18n.format(message.wpName), message.posX, targetY, message.posZ);
            break;
        }
    }
    return null;
}
 
Example 19
Project: GTVeinLocator   File: ClientInfoMessageTranslationPacketHandler.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(ClientInfoMessageTranslationPacket message, MessageContext ctx) {
    SupportModsEnum supportMod = LoadedModHelper.supportMod;
    if (supportMod == null) {
        Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("modcompat.gtveinlocator.no_minimap.info"));
        return null;
    }
    else if (LoadedModHelper.failedCompat) {
        Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("modcompat.gtveinlocator.oldversion_minimap.info", supportMod.getName()));
        return null;
    }
    int[] intParaArray = message.intParaArray;
    int infoIndex = message.infoIndex;
    switch (infoIndex) {
    case 2:
        Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("chat.gtveinlocator.info"+infoIndex, intParaArray[0], intParaArray[1], intParaArray[2], supportMod.getName()));
        break;
    default:
        break;
    }
    return null;
}
 
Example 20
Project: CollectiveFramework   File: ConfigPacket.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(ConfigPacket message, MessageContext ctx) {
	ConfigLoadEvent.Pre event = new ConfigLoadEvent.Pre();
	event.configName = message.configName;
	event.config = message.config;
	event.isRevert = message.isRevert;
	if (!MinecraftForge.EVENT_BUS.post(event)) {
		ConfigRegistry.onConfigReload(event);
		ConfigLoadEvent.Post newEvent = new ConfigLoadEvent.Post();
		newEvent.configName = event.configName;
		newEvent.config = event.config;
		newEvent.isRevert = event.isRevert;
		MinecraftForge.EVENT_BUS.post(event);
	}
	return null;
}
 
Example 21
Project: vsminecraft   File: PacketSimpleGui.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(SimpleGuiMessage message, MessageContext context) 
{
	EntityPlayer player = PacketHandler.getPlayer(context);
	
	if(!player.worldObj.isRemote)
	{
		World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.coord4D.dimensionId);

		if(worldServer != null && message.coord4D.getTileEntity(worldServer) instanceof TileEntityBasicBlock)
		{
			if(message.guiId == -1)
			{
				return null;
			}

			SimpleGuiMessage.openServerGui(message.guiId, (EntityPlayerMP)player, player.worldObj, message.coord4D);
		}
	}
	else {
		FMLCommonHandler.instance().showGuiScreen(SimpleGuiMessage.getGui(message.guiId, player, player.worldObj, message.coord4D));
		player.openContainer.windowId = message.windowId;
	}
	
	return null;
}
 
Example 22
Project: vsminecraft   File: PacketFlamethrowerActive.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(FlamethrowerActiveMessage message, MessageContext context) 
{
	EntityPlayer player = PacketHandler.getPlayer(context);
	
	if(message.value)
	{
		Mekanism.flamethrowerActive.add(message.username);
	}
	else {
		Mekanism.flamethrowerActive.remove(message.username);
	}
	
	if(!player.worldObj.isRemote)
	{
		Mekanism.packetHandler.sendToDimension(new FlamethrowerActiveMessage(message.username, message.value), player.worldObj.provider.dimensionId);
	}
	
	return null;
}
 
Example 23
Project: betterbeginnings-MC1.7   File: ClientProxy.java   View source code 6 votes vote down vote up
@Override
public EntityPlayer getPlayerFromMessageContext(MessageContext ctx)
{
	switch (ctx.side)
	{
		case CLIENT:
		{
			return Minecraft.getMinecraft().thePlayer;
		}
		case SERVER:
		{
			return ctx.getServerHandler().playerEntity;
		}
		default:
			LogUtil.log(Level.ERROR, "Invalid side in TestMsgHandler: " + ctx.side);
	}
	return null;
}
 
Example 24
Project: vsminecraft   File: PacketRemoveUpgrade.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(RemoveUpgradeMessage message, MessageContext context) 
{
	EntityPlayer player = PacketHandler.getPlayer(context);
	TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj);
	
	if(tileEntity instanceof IUpgradeTile && tileEntity instanceof TileEntityBasicBlock)
	{
		IUpgradeTile upgradeTile = (IUpgradeTile)tileEntity;
		Upgrade upgrade = Upgrade.values()[message.upgradeType];

		if(upgradeTile.getComponent().getUpgrades(upgrade) > 0)
		{
			if(player.inventory.addItemStackToInventory(upgrade.getStack()))
			{
				upgradeTile.getComponent().removeUpgrade(upgrade);
			}
		}
	}
	
	return null;
}
 
Example 25
Project: Gadomancy   File: PacketAnimationAbsorb.java   View source code 6 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(PacketAnimationAbsorb p, MessageContext ctx) {
    Block b;
    int md;
    if(p.bid != -1 && p.bmd != -1) {
        b = Block.getBlockById(p.bid);
        md = p.bmd;
    } else {
        b = Minecraft.getMinecraft().theWorld.getBlock(p.targetX, p.targetY, p.targetZ);
        md = Minecraft.getMinecraft().theWorld.getBlockMetadata(p.targetX, p.targetY, p.targetZ);
    }
    MultiTickEffectDispatcher.VortexDigInfo info =
            new MultiTickEffectDispatcher.VortexDigInfo(Minecraft.getMinecraft().theWorld.provider.dimensionId, p.x, p.y, p.z, p.targetX, p.targetY, p.targetZ, b, md, p.tickCap);
    MultiTickEffectDispatcher.registerVortexDig(info);
    return null;
}
 
Example 26
Project: Coding   File: DragonPlayerUpdateIsDragon.java   View source code 6 votes vote down vote up
@Override
		public IMessage onMessage(DragonPlayerUpdateIsDragon message, MessageContext ctx) {
			EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
			if (player != null) {
				if (player != null) {
					DragonPlayer dragonPlayer = DragonPlayer.get(player);
					dragonPlayer.setDragon(message.value, false);
					if (!message.value) {
						// Some other human defaults
//				        player.noClip = false;
						player.stepHeight = 0.5F; // Normally 0.5F for player
					}
				}

			}
			return null;
		}
 
Example 27
Project: Electrometrics   File: PacketTileEntity.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(PacketTileEntity message, MessageContext messageContext) {
	TileEntity tileEntity = message.getLocation().getTileEntity(NetworkHandler.getWorld(messageContext));

	if (tileEntity != null && tileEntity instanceof ITileNetworkable) {
		ITileNetworkable tileNetworkable = (ITileNetworkable) tileEntity;

		try {
			tileNetworkable.handlePacketData(message.storedBuffer);
		} catch (Exception e) {
			e.printStackTrace();
		}

		message.storedBuffer.release();
	}

	return null;
}
 
Example 28
Project: M4thThings   File: PacketNBTHandler.java   View source code 6 votes vote down vote up
@Override
    public IMessage onMessage(PacketNBT message, MessageContext ctx)
    {
//        if (message==null || ctx==null)
//        {
//            return null;
//        }
//        TileEntity tileEntity =  (Minecraft.getMinecraft().theWorld.getTileEntity(message.location[0],message.location[1],message.location[2]));
//
//        if (tileEntity!=null && tileEntity instanceof IM4thNBTSync)
//        {
//            ((IM4thNBTSync)tileEntity).receiveNBTPacket(message.tagCompound);
//        }

        M4thThings.proxy.handleNBTPacket(message);

        return null;
    }
 
Example 29
Project: Yamcl   File: AbstractMessageHandler.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage( T message, MessageContext ctx )
{
  // due to compile-time issues, FML will crash if you try to use Minecraft.getMinecraft() here,
  // even when you restrict this code to the client side and before the code is ever accessed;
  // a solution is to use your proxy classes to get the player (see below).
  if( ctx.side.isClient() )
  {
    // the only reason to check side here is to use our more aptly named handling methods
    // client side proxy will return the client side EntityPlayer
    return handleClientMessage( YAMCore.proxy.getPlayerEntity( ctx ), message, ctx );
  }
  else
  {
    // server side proxy will return the server side EntityPlayer
    return handleServerMessage( YAMCore.proxy.getPlayerEntity( ctx ), message, ctx );
  }
}
 
Example 30
Project: ToggleBlocks   File: MessageSetStoragePriority.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(MessageSetStoragePriority message, MessageContext context)
{
    if (context.getServerHandler().playerEntity != null)
    {
        if (!context.getServerHandler().playerEntity.worldObj.isRemote)
        {
            World world = context.getServerHandler().playerEntity.worldObj;
            int x = message.controllerX, y = message.controllerY, z = message.controllerZ;
            if (world.getTileEntity(x, y, z) instanceof TileEntityToggleBlock)
            {
                TileEntityToggleBlock tileEntity = (TileEntityToggleBlock) world.getTileEntity(x, y, z);
                tileEntity.getStorageHandler().setStoragePriority(message.priority);
            }
        }
    }
    return null;
}
 
Example 31
Project: ToggleBlocks   File: MessageSetOverride.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(MessageSetOverride message, MessageContext context)
{
    if (context.getServerHandler().playerEntity != null)
    {
        if (!context.getServerHandler().playerEntity.worldObj.isRemote)
        {
            World world = context.getServerHandler().playerEntity.worldObj;
            int x = message.changeX, y = message.changeY, z = message.changeZ;
            if (world.getTileEntity(x, y, z) instanceof TileEntityChangeBlock)
            {
                TileEntityChangeBlock tileEntity = (TileEntityChangeBlock) world.getTileEntity(x, y, z);
                System.out.println("Overrides " + message.state + " with: " + message.override);
                tileEntity.getBlockInfo().setOverridesState(message.state, message.override);
                world.markBlockForUpdate(x, y, z);
            }
        }
    }
    return null;
}
 
Example 32
Project: EnderIOAddons   File: PacketPMon.java   View source code 6 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(PacketPMon msg, MessageContext ctx) {
  EntityPlayer player = EnderIO.proxy.getClientPlayer();
  if (player != null) {
    TilePMon te = msg.getTileEntity(player.worldObj);
    if (te != null && msg.no >= 0 && msg.no < te.stats.length) {
      te.stats[msg.no].setCollectCount(msg.collectCount);
      te.stats[msg.no].setPos(msg.pos);
      te.stats[msg.no].setData(msg.data);
      if (msg.no == te.stats.length - 1 && te.dynaTextureProvider != null) {
        ((DynaTextureProvider) te.dynaTextureProvider).updateTexture();
      }
    }
  }
  return null;
}
 
Example 33
Project: DaVincing   File: SculptureOperationMessage.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(SculptureOperationMessage message,
        MessageContext ctx) {

  World w = ctx.getServerHandler().playerEntity.worldObj;
  if (Operations.validOperation(w, message.x, message.y, message.z, message.pos, message.flags)) {
    Operations.applyOperation(w, message.x, message.y, message.z, message.pos, message.flags, message.block, message.meta);
  }

  EntityPlayer ep = ctx.getServerHandler().playerEntity;
  ItemStack is = ep.getCurrentEquippedItem();

  if ((message.flags & Operations.DAMAGE) != 0) {
    is.damageItem(1, ep);
  } else if ((Operations.CONSUME & message.flags) != 0) {
    if (!ep.capabilities.isCreativeMode) {
      is.stackSize--;
      if (is.stackSize <= 0) {
        ForgeEventFactory.onPlayerDestroyItem(ep, is);
        ep.inventory.mainInventory[ep.inventory.currentItem] = null;
      }
    }
  }

  return null;
}
 
Example 34
Project: PAYDAY   File: PacketSyncPlayerPropertiesClientHandler.java   View source code 5 votes vote down vote up
@Override
public IMessage onMessage(final PacketSyncPlayerPropertiesClient packet, final MessageContext ctx) {
	// CLIENT

	new Thread() {
		@Override
		public void run() {
			PlayerData data = PlayerData.get(UUIDUtil.getPlayerFromProfileUUID(Minecraft.getMinecraft().theWorld, packet.playerProfileUUID));
			data.setInLobby(packet.inLobby);
			data.setReady(packet.ready);
		}
	}.start();

	return null;
}
 
Example 35
Project: PAYDAY   File: PacketSyncTileEntityServerHandler.java   View source code 5 votes vote down vote up
@Override
public IMessage onMessage(final PacketSyncTileEntityServer packet, final MessageContext ctx) {
	// THIS IS ON SERVER
	new Thread() {
		@Override
		public void run() {
			EntityPlayerMP p = ctx.getServerHandler().playerEntity;
			World w = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers[packet.dimensionID];
			LobbyTileEntity te = (LobbyTileEntity) w.getTileEntity(packet.x, packet.y, packet.z);

			if (te != null) {
				te.players = packet.players;
				te.lobbyHost = packet.lobbyHost;
				te.isGameLive = packet.isGameLive;
				te.check();
			}

			w = p.worldObj;
			te = (LobbyTileEntity) w.getTileEntity(packet.x, packet.y, packet.z);
			te.check();
			PAYDAY.INSTANCE.sendToAll(new PacketSyncTileEntityClient(te));

			// PAYDAY.INSTANCE.sendToServer(new
			// LobbyPlayerOpenedGuiPacket(packet.x, packet.y,
			// packet.z));//new PacketSyncTileEntityClient(te));
		}
	}.start();

	return null;
}
 
Example 36
Project: connor41-etfuturum2   File: ArmourStandInteractHandler.java   View source code 5 votes vote down vote up
@Override
public IMessage onMessage(ArmourStandInteractMessage message, MessageContext ctx) {
	World world = DimensionManager.getWorld(message.dimID);
	EntityArmourStand stand = (EntityArmourStand) world.getEntityByID(message.standID);
	EntityPlayer player = (EntityPlayer) world.getEntityByID(message.playerID);

	stand.interact(player, message.hitPos);
	return null;
}
 
Example 37
Project: connor41-etfuturum2   File: SetPlayerModelHandler.java   View source code 5 votes vote down vote up
@Override
public IMessage onMessage(SetPlayerModelMessage message, MessageContext ctx) {
	String playerName = message.playerName;
	boolean isAlex = message.isAlex;

	for (Object obj : Minecraft.getMinecraft().theWorld.playerEntities)
		if (obj instanceof EntityPlayer && playerName.equals(((EntityPlayer) obj).getCommandSenderName())) {
			EntityPlayer player = (EntityPlayer) obj;
			player.getEntityData().setBoolean(SetPlayerModelCommand.MODEL_KEY, isAlex);
		}

	return null;
}
 
Example 38
Project: minecraft-quiverbow   File: KickbackPacket.java   View source code 5 votes vote down vote up
@Override
public IMessage onMessage(KickbackMessage message, MessageContext ctx)
{		
	if (ctx.side.isClient())	// just to make sure that the side is correct 
	{
		Helper_Client.knockUserBackClient(message.strength);
	}
	
	return null;	// Don't care about returning anything
}
 
Example 39
Project: minecraft-quiverbow   File: PositionPacket.java   View source code 5 votes vote down vote up
@Override
public IMessage onMessage(PositionMessage message, MessageContext ctx)
{		
	if (ctx.side.isClient())	// just to make sure that the side is correct 
	{
		// Setting the position of the passed in entity, for precision purposes
		Helper_Client.updateEntityPositionClient(message.entityID, message.posX, message.posY, message.posZ);
	}
	
	return null;	// Don't care about returning anything
}
 
Example 40
Project: minecraft-quiverbow   File: TurretInventoryPacket.java   View source code 5 votes vote down vote up
@Override
public IMessage onMessage(TurretInventoryMessage message, MessageContext ctx)
{		
	if (ctx.side.isClient())	// just to make sure that the side is correct 
	{
		Helper_Client.setTurretInventory(message.entityID, message.itemID, message.itemSlot, message.metadata);
	}
	
	return null;	// Don't care about returning anything
}