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


Java MessageContext类代码示例

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


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

示例1: 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

示例2: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入依赖的package包/类
@Override
public IMessage onMessage(final PacketUpdateChunkLevel message, final MessageContext ctx) 
{			
	IThreadListener mainThread = Minecraft.getMinecraft();
	mainThread.addScheduledTask(new Runnable()
	{
		@Override
		public void run() 
		{
			World world = Minecraft.getMinecraft().world;
			ChunkPos chunkPos = new ChunkPos(message.chunkX, message.chunkZ);
			
			IChunkLevelHolder chunkLevelHolder = CapabilityChunkLevel.getChunkLevelHolder(world);
			
			if (chunkLevelHolder.getChunkLevel(chunkPos) != null) return;
			
			IChunkLevel chunkLevel = new ChunkLevel(world, chunkPos, message.level);
			chunkLevelHolder.setChunkLevel(chunkPos, chunkLevel);
		}
	});
	
	return null;
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:24,代码来源:PacketUpdateChunkLevel.java

示例3: 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

示例4: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(CPacketSpawnParticle message, MessageContext ctx)
{
    Minecraft.getMinecraft().addScheduledTask(() ->
            Minecraft.getMinecraft().world.spawnParticle(message.type,
                    message.pos.getX(), message.pos.getY(), message.pos.getZ(),
                    message.motion.getX(), message.motion.getY(), message.motion.getZ()));
    return null;
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:11,代码来源:CPacketSpawnParticle.java

示例5: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入依赖的package包/类
@Override
public IMessage onMessage(MessageGlassJarUpdateStats message, MessageContext ctx) {
    ItemStack stack = message.stack;
    BlockPos pos = message.pos;
    WorldClient world = Minecraft.getMinecraft().world;
    if (world.isBlockLoaded(pos) &&
            world.getBlockState(pos).getBlock().hasTileEntity(world.getBlockState(pos))) {
        TileEntity te = world.getTileEntity(pos);
        if (te instanceof TileFaerieHome) {
            IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
            if (handler != null) {
                handler.insertItem(0, stack, false);
            }
        }
    }
    return null;
}
 
开发者ID:BenjaminSutter,项目名称:genera,代码行数:18,代码来源:MessageGlassJarUpdateStats.java

示例6: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入依赖的package包/类
@Override
public IMessage onMessage(final PacketDisplacerGuiColor msg, MessageContext ctx) {

	ctx.getServerHandler().player.getServerWorld().addScheduledTask(new Runnable() {
		@Override
		public void run() {

			if (msg.col != null) {
				for (int i = 0; i < msg.col.length; i++)
					((TileDisplacer) msg.tile).setFilterColor(i, msg.col[i]);
			}
		}
	});

	return null;
}
 
开发者ID:oMilkyy,项目名称:SimpleTubes,代码行数:17,代码来源:PacketDisplacerGuiColor.java

示例7: 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

示例8: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入依赖的package包/类
@Override
public IMessage onMessage(BrewMessage message, MessageContext ctx) {
	Minecraft.getMinecraft().addScheduledTask(() -> {
		World world = Minecraft.getMinecraft().player.world;

		EntityLivingBase entity = world.getPlayerEntityByUUID(message.target);
		if (entity == null) {
			entity = NBTHelper.getEntityByUUID(EntityLivingBase.class, message.target, world).orElse(null);
		}

		if (entity != null) {
			Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(entity);
			if (optional.isPresent()) {
				IBrewStorage storage = optional.get();
				storage.setBrewMap(message.effects);
			}
		}
	});
	return null;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:21,代码来源:BrewMessage.java

示例9: processMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入依赖的package包/类
private void processMessage(MessageBiomeChange message, MessageContext ctx, WorldClient world)
{
    Biome targetBiome = Biome.getBiomeForId(message.biomeID);
    if(targetBiome == null)
        return;

    byte[] currentArray;
    for(byte nX = -5; nX <= 5; nX++)
    {
        for(byte nZ = -5; nZ <= 5; nZ++)
        {
            Chunk c = world.getChunkFromBlockCoords(new BlockPos(message.changeCenter.getX() + nX*16, 0, message.changeCenter.getZ() + nZ*16));
            currentArray = c.getBiomeArray();
            for(int n = 0; n < currentArray.length; n++)
            {
                currentArray[n] = (byte) Biome.getIdForBiome(targetBiome);
            }
            c.setBiomeArray(currentArray);
            c.setModified(true);
        }
    }
}
 
开发者ID:Lumaceon,项目名称:CraftingParadiseMod,代码行数:23,代码来源:HandlerBiomeChange.java

示例10: handleMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public IMessage handleMessage (MessageContext context) {

    Minecraft.getMinecraft().addScheduledTask( () -> {

        final EntityPlayer player = PlayerUtils.getClientPlayer();
        final IStageData info = PlayerDataHandler.getStageData(player);

        // Remove all stages
        info.clear();

        // Re-add all stages
        for (final String stageName : this.stages) {
            info.unlockStage(stageName);
        }

        MinecraftForge.EVENT_BUS.post(new StageDataEvent.SyncRecieved(player, info));
    });

    return null;
}
 
开发者ID:Darkhax-Minecraft,项目名称:Game-Stages,代码行数:23,代码来源:PacketStageAll.java

示例11: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入依赖的package包/类
@Override
public IMessage onMessage(final PacketItemAdd msg, MessageContext ctx) {

	Minecraft.getMinecraft().addScheduledTask(new Runnable() {
		@Override
		public void run() {

			if (msg.tile != null) {
				if (msg.tile instanceof TileTube) {
					TileTube tube = (TileTube) msg.tile;
					TubeItem item = TubeItem.createFromPacket(tube, msg.id, msg.stack, msg.progress, msg.direction, msg.color);
					tube.handleItemClientSide(TileTube.ITEM_ADD, item);
				}
			}
		}
	});

	return null;
}
 
开发者ID:oMilkyy,项目名称:SimpleTubes,代码行数:20,代码来源:PacketItemAdd.java

示例12: handle

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入依赖的package包/类
private void handle(PacketNotebookToastOrFail message, MessageContext ctx)
{
	INotebookInfo cap = Minecraft.getMinecraft().player.getCapability(INotebookInfo.CAP, null);

	if (cap != null)
	{
		if (message.cat != null && !cap.isUnlocked(message.cat.getRequiredTag()))
		{
			cap.setUnlocked(message.cat.getRequiredTag());
			ArcaneMagic.proxy.addCategoryUnlockToast(message.cat, false);
		} else if (message.showIfFail)
		{
			Minecraft.getMinecraft().ingameGUI.setOverlayMessage(
					TextFormatting.RED + I18n.format("arcanemagic.message.cantlearn"), false);
		}
	}
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:18,代码来源:PacketNotebookToastOrFail.java

示例13: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入依赖的package包/类
@Override
public IMessage onMessage(SPacketUnlock message, MessageContext ctx)
{
    ctx.getServerHandler().player.getServerWorld().addScheduledTask(() ->
    {
        boolean result = false;
        TileEntity te = ctx.getServerHandler().player.world.getTileEntity(message.pos);
        if(te != null && te instanceof TileCodeStorage)
        {
            TileCodeStorage storage = (TileCodeStorage) te;
            result = storage.tryUnlock(message.code);
        }
        NetworkManager.sendTo(new CPacketUnlockResponse(result), ctx.getServerHandler().player);
    });
    return null;
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:17,代码来源:SPacketUnlock.java

示例14: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入依赖的package包/类
@Override
public IMessage onMessage(final PacketTubeSync msg, MessageContext ctx) {

	Minecraft.getMinecraft().addScheduledTask(new Runnable() {
		@Override
		public void run() {

			if (msg.tile != null && msg.tile instanceof TileTube) {
				((TileTube) msg.tile).setTubeColor(msg.color);
				((TileTube) msg.tile).markDirty();

				BlockPos pos = msg.tile.getPos();
				IBlockState state = msg.tile.getWorld().getBlockState(pos);
				msg.tile.getWorld().markAndNotifyBlock(pos, null, state, state, 2);
			}
		}
	});

	return null;
}
 
开发者ID:oMilkyy,项目名称:SimpleTubes,代码行数:21,代码来源:PacketTubeSync.java

示例15: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; //导入依赖的package包/类
@Override
public IMessage onMessage(final TileEntitySyncPacket message, final MessageContext ctx){
	FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(new Runnable(){
		@Override
		public void run(){
			TileEntity tile;
			if(ctx.side.isServer()){
				tile = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
			}else{
				tile = Minecraft.getMinecraft().theWorld.getTileEntity(new BlockPos(message.x, message.y, message.z));
			}
			if(tile != null){
				tile.readFromNBT(message.tag);
			}
			if(ctx.side.isServer()){
				OFT.OFTNet.sendToAll(message);
			}
		}
	});
	return null;
}
 
开发者ID:DonBruce64,项目名称:OpenFlexiTrack,代码行数:22,代码来源:TileEntitySyncPacket.java


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