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