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


Java IMessage类代码示例

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


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

示例1: handleServerMessage

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的package包/类
@Override
public IMessage handleServerMessage(EntityPlayer player, MessageSyncAdd message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (player.getEntityId() == en.getEntityId() && en.getEntityWorld() != null && en.hasCapability(Currency.ACCOUNT_DATA, null)) {
				AccountCapability entityData = en.getCapability(Currency.ACCOUNT_DATA, null);
				for (ItemStack stack : CurrencyUtils.itemMoneyAmount(message.amount)) {
					if (stack != null && stack != ItemStack.EMPTY && en instanceof EntityPlayer) {
						EntityPlayer pl = (EntityPlayer) en;
						pl.inventory.addItemStackToInventory(stack);
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:19,代码来源:MessageSyncAdd.java

示例2: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的package包/类
@Override
public IMessage onMessage(final PacketClassGui message, final MessageContext ctx) 
{			
	IThreadListener mainThread = Minecraft.getMinecraft();
	mainThread.addScheduledTask(new Runnable()
	{
		@Override
		public void run() 
		{
			EntityPlayer player = Minecraft.getMinecraft().player;
			PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
			
			if (playerInfo != null && playerInfo.getPlayerClass() == 0)
			{
				player.openGui(LootSlashConquer.instance, GuiHandler.CLASS_SELECTION, player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
			}
		}
	});
	
	return null;
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:22,代码来源:PacketClassGui.java

示例3: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的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

示例4: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的package包/类
@Override
public IMessage onMessage(final MessageWorldCraft message, final MessageContext ctx)
{
    if(ctx.side != Side.SERVER)
    {
        System.err.println("MessageWorldCraft received on wrong side:" + ctx.side);
        return null;
    }

    final EntityPlayerMP sendingPlayer = ctx.getServerHandler().player;
    if(sendingPlayer == null)
    {
        System.err.println("MessageWorldCraft received with null player.");
        return null;
    }

    final WorldServer playerWorldServer = sendingPlayer.getServerWorld();
    playerWorldServer.addScheduledTask(() -> processMessage(message, ctx, playerWorldServer));
    return null;
}
 
开发者ID:Lumaceon,项目名称:CraftingParadiseMod,代码行数:21,代码来源:HandlerWorldCraft.java

示例5: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的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

示例6: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(MessageReceiveConfiguration message, MessageContext ctx) {
    FirstAid.activeHealingConfig = message.healingCfg;
    FirstAid.activeDamageConfig = message.damageCfg;
    FirstAid.scaleMaxHealth = message.scaleMaxHealth;
    AbstractPlayerDamageModel damageModel = PlayerDamageModel.create();
    damageModel.deserializeNBT(message.playerDamageModel);
    Minecraft mc = Minecraft.getMinecraft();

    FirstAid.playerMaxHealth = FirstAid.activeDamageConfig.maxHealthHead + FirstAid.activeDamageConfig.maxHealthLeftArm
            + FirstAid.activeDamageConfig.maxHealthLeftLeg + FirstAid.activeDamageConfig.maxHealthLeftFoot
            + FirstAid.activeDamageConfig.maxHealthBody + FirstAid.activeDamageConfig.maxHealthRightArm
            + FirstAid.activeDamageConfig.maxHealthRightLeg + FirstAid.activeDamageConfig.maxHealthRightFoot;

    FirstAid.logger.info("Received configuration");
    mc.addScheduledTask(() -> {
        PlayerDataManager.capList.put(mc.player, damageModel);
        if (damageModel.hasTutorial)
            PlayerDataManager.tutorialDone.add(mc.player.getName());
        else
            mc.player.sendMessage(new TextComponentString("[First Aid] " + I18n.format("firstaid.tutorial.hint", ClientProxy.showWounds.getDisplayName())));
    });
    return null;
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:26,代码来源:MessageReceiveConfiguration.java

示例7: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的package包/类
@Override
public IMessage onMessage(final JumpkinRotationMessage message, MessageContext ctx)
{
	Minecraft minecraft = Minecraft.getMinecraft();
	final WorldClient world = minecraft.world;

	minecraft.addScheduledTask(new Runnable()
	{
		@Override
		public void run()
		{
			EntityJumpkin entity = (EntityJumpkin)world.getEntityByID(message.entityId);
			entity.rotationYaw = message.rotationYaw;
			entity.rotationPitch = message.rotationPitch;
		}
	});
	return null;
}
 
开发者ID:crazysnailboy,项目名称:Halloween,代码行数:19,代码来源:JumpkinRotationMessage.java

示例8: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的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

示例9: onMessage

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

		if (entityTarget != null) {
			final Optional<IEnergy> optData = EnergyHandler.getEnergy(entityTarget);
			if (optData.isPresent()) {
				final IEnergy data = optData.get();
				data.set(message.energy.get());
				data.setMax(message.energy.getMax());
				data.setRegen(message.energy.getRegenTime(), message.energy.getRegenBurst());
				data.setUses(message.energy.getUses());
				data.setType(message.energy.getType());
			}
		}
	});
	return null;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:20,代码来源:EnergyMessage.java

示例10: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(MessageReceiveDamage message, MessageContext ctx) {
    Minecraft.getMinecraft().addScheduledTask(() -> {
       AbstractPlayerDamageModel damageModel = PlayerDataManager.getDamageModel(Minecraft.getMinecraft().player);
        Objects.requireNonNull(damageModel);
        AbstractDamageablePart part = damageModel.getFromEnum(message.part);
        part.damage(message.damageAmount, null, false, message.minHealth);
    });
    return null;
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:12,代码来源:MessageReceiveDamage.java

示例11: processMessage

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的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

示例12: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public IMessage onMessage(final MessageSoulDrainFX message, final MessageContext ctx) {
	World world = Minecraft.getMinecraft().world;
	if (world.isRemote) {
		for (double i = 0; i < 8; i++) {
			double xCoord = message.posX + (rand.nextDouble() - 0.5);
			double yCoord = message.posY + (rand.nextDouble() - 0.5);
			double zCoord = message.posZ + (rand.nextDouble() - 0.5);
			world.spawnParticle(EnumParticleTypes.CRIT, true, xCoord, yCoord, zCoord, (rand.nextDouble() - 0.5),
					(rand.nextDouble() - 0.5), (rand.nextDouble() - 0.5));
		}
		ParticleUtils.spawnParticleBeam(world, EnumParticleTypes.CRIT, message.posX, message.posY, message.posZ,
				message.castX, message.castY, message.castZ, 0.2);
	}
	return null;
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:18,代码来源:MessageSoulDrainFX.java

示例13: onMessage

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的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.IMessage; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(RandoresDataNeededQuery message, MessageContext ctx) {
    Minecraft.getMinecraft().addScheduledTask(() -> {
        Randores.debug("Received data needed query from server: " + message.getId());
        World world = Minecraft.getMinecraft().world;
        RandoresWorldData data = RandoresWorldData.getSimply(world);
        if(!data.isLoaded() || !data.getId().equals(message.getId())) {
            RandoresNetworking.INSTANCE.sendToServer(new RandoresDataRequest().setId(message.getId()));
            Randores.debug("Sent request for data; an update is required");
        } else {
            Randores.debug("Update not required.");
        }
    });
    return null;
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:17,代码来源:RandoresDataNeededQueryHandler.java

示例15: sendTo

import net.minecraftforge.fml.common.network.simpleimpl.IMessage; //导入依赖的package包/类
public void sendTo(IMessage message, EntityPlayerMP player)
{
    if(useUdp && discriminators.containsKey(message.getClass())) {
    	InetSocketAddress address=TF2weapons.udpServer.outboundTargets.get(player.getCapability(TF2weapons.PLAYER_CAP, null).udpServerId);
    	if (address != null) {
 		ByteBuf buffer = Unpooled.buffer();
 		buffer.writeShort(0);
 		buffer.writeByte(discriminators.get(message.getClass()));
 		message.toBytes(buffer);
 		DatagramPacket packet = new DatagramPacket(buffer, address);
 		TF2weapons.udpServer.channel.writeAndFlush(packet);
    	}
    }
    else {
    	super.sendTo(message, player);
    }
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:18,代码来源:TF2NetworkWrapper.java


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