本文整理汇总了Java中cpw.mods.fml.common.network.simpleimpl.MessageContext.getServerHandler方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.getServerHandler方法的具体用法?Java MessageContext.getServerHandler怎么用?Java MessageContext.getServerHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cpw.mods.fml.common.network.simpleimpl.MessageContext
的用法示例。
在下文中一共展示了MessageContext.getServerHandler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMessage
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(LobbyBeginGamePacket packet, MessageContext ctx) {
int x = packet.x;
int y = packet.y;
int z = packet.z;
World w = ctx.getServerHandler().playerEntity.worldObj;
TileEntity te = w.getTileEntity(x, y, z);
if (te != null && te instanceof LobbyTileEntity) {
LobbyTileEntity tile = (LobbyTileEntity) te;
tile.setGameLive(true);
for (EntityPlayer p : UUIDUtil.getPlayersFromProfileUUIDs(w, tile.players))
p.travelToDimension(PAYDAY.dimensionID);
}
return null;
}
示例2: onMessage
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(LobbyPlayerOpenedGuiPacket packet, MessageContext ctx) {
// SERVER
int x = packet.x;
int y = packet.y;
int z = packet.z;
EntityPlayerMP p = ctx.getServerHandler().playerEntity;
World w = p.worldObj;
if (w == null)
return null;
LobbyTileEntity tile = (LobbyTileEntity) w.getTileEntity(x, y, z);
if (tile == null)
return null;
PAYDAY.INSTANCE.sendTo(new PacketSyncTileEntityClient(tile), p);
return null;
}
示例3: getPlayerFromMessageContext
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public EntityPlayer getPlayerFromMessageContext(MessageContext ctx)
{
switch (ctx.side)
{
case CLIENT:
{
EntityPlayer entityClientPlayerMP = Minecraft.getMinecraft().thePlayer;
return entityClientPlayerMP;
}
case SERVER:
{
EntityPlayer entityPlayerMP = ctx.getServerHandler().playerEntity;
return entityPlayerMP;
}
default:
{
break;
}
}
return null;
}
示例4: getPlayerFromMessageContext
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
public EntityPlayer getPlayerFromMessageContext(MessageContext ctx)
{
switch (ctx.side)
{
case SERVER:
{
EntityPlayer entityPlayerMP = ctx.getServerHandler().playerEntity;
return entityPlayerMP;
}
default:
{
break;
}
}
return null;
}
示例5: onMessage
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(PacketDialerChangeMode message, MessageContext ctx)
{
ItemStack dialer = null;
InventoryPlayer inv = ctx.getServerHandler().playerEntity.inventory;
for (int i = 0; i < inv.getSizeInventory(); i++)
{
if (inv.getStackInSlot(i) != null && inv.getStackInSlot(i).getItem() instanceof ItemDialer)
{
dialer = inv.getStackInSlot(i);
dialer.stackTagCompound.setBoolean("modeDial", !dialer.stackTagCompound.getBoolean("modeDial"));
break;
}
}
return null;
}
示例6: onMessage
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public InfinityChestConfirmation onMessage(final InfinityChestConfirmation message, final MessageContext ctx)
{
final EntityPlayer entityPlayer = ctx.side == Side.SERVER ? ctx.getServerHandler().playerEntity : Avaritiaddons.proxy.getEntityPlayerFromContext(ctx);
switch (ctx.side) {
case CLIENT:
Container container = null;
if (message.windowID == 0)
container = entityPlayer.inventoryContainer;
else if (message.windowID == entityPlayer.openContainer.windowId)
container = entityPlayer.openContainer;
return container != null && !message.confirmed ? new InfinityChestConfirmation(message.windowID, message.transactionID, true) : null;
case SERVER:
final short transactionId = transactionMap.get(message.windowID);
if (transactionId != -1 && message.transactionID == transactionId && entityPlayer.openContainer.windowId == message.windowID && !entityPlayer.openContainer.isPlayerNotUsingContainer(entityPlayer))
entityPlayer.openContainer.setPlayerIsPresent(entityPlayer, true);
return new InfinityChestConfirmation(message.windowID, message.transactionID, true);
default:
return null;
}
}
示例7: onMessage
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(StaffUpdateDestroyBlock message, MessageContext ctx) {
EntityPlayer player = ctx.getServerHandler().playerEntity;
if (player != null) {
Block block = player.worldObj.getBlock(message.x, message.y, message.z);
if (block != null) {
float amplifier = DragonPlayer.get(player).getLevel() / 2.0F;
float minHardness = Math.max(1.0F, 1.0F + amplifier);
float hardness = block.getBlockHardness(player.worldObj, message.x, message.y, message.z);
LogHelper.info("Block hardness is " + hardness);
if (hardness >= 0 && hardness < minHardness) {
player.worldObj.setBlock(message.x, message.y, message.z, Blocks.air, 0, 3);
player.worldObj.playSoundEffect(message.x + 0.5D, message.y + 0.5D, message.z + 0.5D,
REFERENCE.MODID + ":" + "soundWaveImpact", 1.8F, 1.0F);
LogHelper.info("Destroyed a block!");
}
else {
player.addChatMessage(new ChatComponentText(
StatCollector.translateToLocal("chat.wildbill22_draco.blockIsTooHard")));
}
}
}
return null;
}
示例8: onMessage
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public PacketReturnProtectedBlocks onMessage(PacketGetProtectedBlocks message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
World world = player.worldObj;
ItemStack heldItem = player.getHeldItem();
if (heldItem == null || !(heldItem.getItem() instanceof ProtectionWand)) {
// Cannot happen normally
return null;
}
ProtectionWand protectionWand = (ProtectionWand) heldItem.getItem();
int id = protectionWand.getId(heldItem);
ProtectedBlocks protectedBlocks = ProtectedBlocks.getProtectedBlocks(world);
Set<Coordinate> blocks = new HashSet<Coordinate>();
protectedBlocks.fetchProtectedBlocks(blocks, world, (int)player.posX, (int)player.posY, (int)player.posZ, protectionWand.blockShowRadius, id);
Set<Coordinate> childBlocks = new HashSet<Coordinate>();
if (id == -1) {
// Master wand:
protectedBlocks.fetchProtectedBlocks(childBlocks, world, (int)player.posX, (int)player.posY, (int)player.posZ, protectionWand.blockShowRadius, -2);
}
return new PacketReturnProtectedBlocks(blocks, childBlocks);
}
示例9: getPlayerFromMessageContext
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public EntityPlayer getPlayerFromMessageContext(MessageContext ctx)
{
switch (ctx.side)
{
case CLIENT:
{
return Minecraft.getMinecraft().thePlayer;
}
case SERVER:
{
return ctx.getServerHandler().playerEntity;
}
default:
LogUtil.log(Level.ERROR, "Invalid side in TestMsgHandler: " + ctx.side);
}
return null;
}
示例10: onMessage
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(PacketSetClasse message, MessageContext ctx)
{
EntityPlayerMP player;
ServerPlayerBaseMagic pm;
player = ctx.getServerHandler().playerEntity;
pm = Main.getPlayerServer(player);
pm.init(message.classe);
return null;
}
示例11: onMessage
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(PacketSetRace message, MessageContext ctx)
{
EntityPlayerMP player;
ServerPlayerBaseMagic pm;
player = ctx.getServerHandler().playerEntity;
pm = Main.getPlayerServer(player);
pm.init(message.race);
return null;
}
示例12: onMessage
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(PacketWantThroughput message, MessageContext ctx)
{
World world = ctx.getServerHandler().playerEntity.worldObj;
if (message.update)
{
((TileEntityResistor)world.getTileEntity(message.x, message.y, message.z)).sendThroughputToClient(ctx.getServerHandler().playerEntity);
}
return null;
}
示例13: onMessage
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(PacketSetThroughput message, MessageContext ctx)
{
World world = ctx.getServerHandler().playerEntity.worldObj;
((TileEntityResistor)world.getTileEntity(message.x, message.y, message.z)).setThroughput(message.throughtput);
return null;
}
示例14: onMessage
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public IMessage onMessage(final InfinityChestClick message, final MessageContext ctx)
{
final EntityPlayerMP entityPlayer = ctx.getServerHandler().playerEntity;
entityPlayer.func_143004_u();
if (entityPlayer.openContainer == null)
return null;
if (entityPlayer.openContainer.windowId == message.windowId && entityPlayer.openContainer.isPlayerNotUsingContainer(entityPlayer)) {
final ItemStack itemstack = entityPlayer.openContainer.slotClick(message.slotNumber, message.mouseButton, message.modifier, entityPlayer);
if (ItemStack.areItemStacksEqual(message.itemStack, itemstack)) {
Avaritiaddons.networkWrapper.sendTo(new InfinityChestConfirmation(message.windowId, message.transactionID, true), entityPlayer);
entityPlayer.isChangingQuantityOnly = true;
entityPlayer.openContainer.detectAndSendChanges();
entityPlayer.updateHeldItem();
entityPlayer.isChangingQuantityOnly = false;
} else {
InfinityChestConfirmation.Handler.transactionMap.put(entityPlayer.openContainer.windowId, message.transactionID);
Avaritiaddons.networkWrapper.sendTo(new InfinityChestConfirmation(message.windowId, message.transactionID, false), entityPlayer);
entityPlayer.openContainer.setPlayerIsPresent(entityPlayer, false);
final ItemStack[] itemStacks = new ItemStack[entityPlayer.openContainer.inventorySlots.size()];
for (int i = 0; i < entityPlayer.openContainer.inventorySlots.size(); ++i)
itemStacks[i] = (((Slot) entityPlayer.openContainer.inventorySlots.get(i)).getStack());
Avaritiaddons.networkWrapper.sendTo(new InfinityChestSyncAllSlots(itemStacks), entityPlayer);
}
}
return null;
}
示例15: onMessage
import cpw.mods.fml.common.network.simpleimpl.MessageContext; //导入方法依赖的package包/类
@Override
public IMessage onMessage(NGTPacket packet, MessageContext context) {
EntityPlayerMP serverPlayer = context.getServerHandler().playerEntity;
NBTTagCompound tagCompound = packet.stack.getTagCompound();
if (serverPlayer.getCurrentEquippedItem() != null)
serverPlayer.getCurrentEquippedItem().setTagCompound(tagCompound);
return null;
}