本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}