当前位置: 首页>>代码示例>>Java>>正文


Java MessageContext.getServerHandler方法代码示例

本文整理汇总了Java中net.minecraftforge.fml.common.network.simpleimpl.MessageContext.getServerHandler方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.getServerHandler方法的具体用法?Java MessageContext.getServerHandler怎么用?Java MessageContext.getServerHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.fml.common.network.simpleimpl.MessageContext的用法示例。


在下文中一共展示了MessageContext.getServerHandler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(final DisguiseMessage message, MessageContext ctx) {
	final EntityPlayerMP player = ctx.getServerHandler().player;
	((WorldServer) player.world).addScheduledTask(new Runnable() {

		@Override
		public void run() {
			ItemStack stack;
			if (((stack = player.getHeldItemMainhand()) != null && stack.getItem() instanceof ItemDisguiseKit)
					|| ((stack = player.getHeldItemOffhand()) != null
							&& stack.getItem() instanceof ItemDisguiseKit)) {
				ItemDisguiseKit.startDisguise(player, player.world, message.value);
				if (!player.capabilities.isCreativeMode)
					stack.damageItem(1, player);
			}
		}

	});
	return null;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:21,代码来源:TF2DisguiseHandler.java

示例2: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(CraftMessage message, MessageContext ctx)
{
    EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    // Try crafting recipes first:
    List<IRecipe> matching_recipes = CraftingHelper.getRecipesForRequestedOutput(message.parameters);
    for (IRecipe recipe : matching_recipes)
    {
        if (CraftingHelper.attemptCrafting(player, recipe))
            return null;
    }
    // Now try furnace recipes:
    ItemStack input = CraftingHelper.getSmeltingRecipeForRequestedOutput(message.parameters);
    if (input != null)
    {
        if (CraftingHelper.attemptSmelting(player, input))
            return null;
    }
    return null;
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:21,代码来源:SimpleCraftCommandsImplementation.java

示例3: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(TeleportRequest message, MessageContext ctx) {
    EntityPlayerMP player = ctx.getServerHandler().player;
    if(Perms.isOP(player) == false){
        Main.LOGGER.info(player.getName() + " tried to teleport, but was denied to do so!");
        return null;
    }
    new RunInServerThread(new Runnable() {
        @Override
        public void run() {
            Entity e = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityFromUuid(message.uuid);
            if(e == null){
                player.sendMessage(new TextComponentString(TextFormatting.RED + "Woops! This tile entity no longer exists!"));
                return;
            }
            Teleport.teleportPlayer(player, e.dimension, e.posX, e.posY, e.posZ);
        }
    });
    return null;
}
 
开发者ID:TerminatorNL,项目名称:LagGoggles,代码行数:21,代码来源:TeleportRequestHandler.java

示例4: processMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
/** IMPORTANT: Call this from the onMessage method in the subclass. */
public IMessage processMessage(final ObservationRequestMessage message, final MessageContext ctx)
{
	IThreadListener mainThread = (WorldServer)ctx.getServerHandler().playerEntity.worldObj;
	mainThread.addScheduledTask(new Runnable() {
		@Override
		public void run() {
			EntityPlayerMP player = ctx.getServerHandler().playerEntity;
			JsonObject json = new JsonObject();
			buildJson(json, player, message, ctx);
			// 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());
			message.addReturnData(returnData);
			MalmoMod.network.sendTo(new MalmoMod.MalmoMessage(MalmoMessageType.SERVER_OBSERVATIONSREADY, message.id, returnData), player);
		}
	});
	return null; // no response in this case
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:20,代码来源:ObservationFromServer.java

示例5: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(MessageUpdatePitchYaw message, MessageContext ctx) {
	if (ctx.side == Side.SERVER) {
		EntityPlayerMP player = ctx.getServerHandler().playerEntity;
		Entity entity =player.getEntityWorld()
				.getEntityByID(player.getEntityData().getInteger("renderViewCamera"));
		// entity.setDelay(message.delay);
		if (player != null && entity != null&&entity instanceof EntityTripod) {
			entity.rotationYaw = message.rotationYaw;
			entity.rotationPitch = message.rotationPitch;
		}
	}
	return null;
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:15,代码来源:MessageUpdatePitchYaw.java

示例6: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(MessagePlayerViewRender message, MessageContext ctx) {
	if (ctx.side == Side.SERVER) {
		if(ctx.getServerHandler().playerEntity!=null){
			ctx.getServerHandler().playerEntity.getEntityData().removeTag("renderViewCamera");
		}
	}
	return null;
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:10,代码来源:MessagePlayerViewRender.java

示例7: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(final ConfigSyncMessage message, MessageContext ctx)
{
	IThreadListener threadListener = (ctx.side == Side.SERVER ? (WorldServer)ctx.getServerHandler().player.world : Minecraft.getMinecraft());
	threadListener.addScheduledTask(new Runnable()
	{
		@Override
		public void run()
		{
			ModConfiguration.readFromNBT(message.compound);
		}
	});
	return null;
}
 
开发者ID:crazysnailboy,项目名称:Halloween,代码行数:15,代码来源:ConfigSyncMessage.java

示例8: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(final TeleportToTileEntityRequest message, MessageContext ctx) {
    EntityPlayerMP player = ctx.getServerHandler().player;
    if(Perms.isOP(player) == false){
        Main.LOGGER.info(player.getName() + " tried to teleport, but was denied to do so!");
        return null;
    }
    Teleport.teleportPlayer(player, message.dim, message.x, message.y, message.z);
    return null;
}
 
开发者ID:TerminatorNL,项目名称:LagGoggles,代码行数:11,代码来源:TeleportToTileEntityRequestHandler.java

示例9: onMessageSynchronized

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
protected void onMessageSynchronized(final MessageBookCodeData message, final MessageContext context) {
  final EntityPlayer player = context.getServerHandler().player;
  if (player != null) {
    final ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
    if (ItemBookCode.isBookCode(stack)) {
      final ItemBookCode.Data data = ItemBookCode.Data.loadFromNBT(message.getNbt());
      ItemBookCode.Data.saveToStack(stack, data);
    }
  }
}
 
开发者ID:ToroCraft,项目名称:Minecoprocessors,代码行数:12,代码来源:MessageBookCodeData.java

示例10: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(final MessageProcessorAction message, MessageContext ctx) {
  if (message.action == null) {
    return null;
  }
  final EntityPlayerMP payer = ctx.getServerHandler().player;
  payer.getServerWorld().addScheduledTask(new Worker(payer, message));
  return null;
}
 
开发者ID:ToroCraft,项目名称:Minecoprocessors,代码行数:10,代码来源:MessageProcessorAction.java

示例11: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(final MessageEnableGuiUpdates message, MessageContext ctx) {
  if (message.pos == null) {
    return null;
  }
  final EntityPlayerMP payer = ctx.getServerHandler().player;
  payer.getServerWorld().addScheduledTask(new Worker(payer, message));
  return null;
}
 
开发者ID:ToroCraft,项目名称:Minecoprocessors,代码行数:10,代码来源:MessageEnableGuiUpdates.java

示例12: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(InventoryMessage message, MessageContext ctx)
{
    EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    if (message.combine)
        combineSlots(player, message.slotA, message.slotB);
    else
        swapSlots(player, message.slotA, message.slotB);
    return null;
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:11,代码来源:InventoryCommandsImplementation.java

示例13: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(final SwapItems message, MessageContext ctx)
{
    final EntityPlayerMP player = ctx.getServerHandler().player;
    final WorldServer world = (WorldServer) player.world;

    world.addScheduledTask(() -> swapItem(message.swapWith, player));

    return null; // no response in this case
}
 
开发者ID:gigaherz,项目名称:ToolBelt,代码行数:11,代码来源:SwapItems.java

示例14: handle

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
private void handle(PacketRequestConfig message, MessageContext ctx) {
    EntityPlayerMP player = ctx.getServerHandler().player;
    PlayerWheelConfiguration config = PlayerProperties.getWheelConfig(player);
    NBTTagCompound tc = new NBTTagCompound();
    config.saveNBTData(tc);
    PacketHandler.INSTANCE.sendTo(new PacketSyncConfigToClient(tc), player);
}
 
开发者ID:McJty,项目名称:interactionwheel,代码行数:8,代码来源:PacketRequestConfig.java

示例15: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(final MessageOpenNemesisGuiRequest message, MessageContext ctx) {
	final EntityPlayerMP player = ctx.getServerHandler().player;
	player.getServerWorld().addScheduledTask(() -> sendResponse(player));
	return null;
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:7,代码来源:MessageOpenNemesisGuiRequest.java


注:本文中的net.minecraftforge.fml.common.network.simpleimpl.MessageContext.getServerHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。