net.minecraft.client.Minecraft.getConnection()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中net.minecraft.client.Minecraft.getConnection()方法的一些代码示例,展示了Minecraft.getConnection()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Minecraft.getConnection()方法的具体详情如下:
包路径:net.minecraft.client.Minecraft
类名称:Minecraft
方法名:getConnection

Minecraft.getConnection介绍

暂无

代码示例

代码示例来源:origin: Lunatrius/Schematica

public final <T extends INetHandler> boolean sendPacket(final Packet<T> packet) {
    final NetHandlerPlayClient connection = this.minecraft.getConnection();
    if (connection == null) {
      return false;
    }

    connection.sendPacket(packet);
    return true;
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

@SideOnly(Side.CLIENT)
  public static void sendToServer(IForestryPacketServer packet) {
    NetHandlerPlayClient netHandler = Minecraft.getMinecraft().getConnection();
    Preconditions.checkNotNull(netHandler, "Tried to send packet before netHandler (client world) exists.");
    netHandler.sendPacket(packet.getPacket());
  }
}

代码示例来源:origin: ExtraCells/ExtraCells2

@SideOnly(Side.CLIENT)
  public static void sendToServer(IPacket packet) {
    NetHandlerPlayClient netHandler = Minecraft.getMinecraft().getConnection();
    Preconditions.checkNotNull(netHandler, "Tried to send packet before netHandler (client world) exists.");
    netHandler.sendPacket(packet.getPacket());
  }
}

代码示例来源:origin: Ellpeck/ActuallyAdditions

@Override
  public void sendBreakPacket(BlockPos pos) {
    NetHandlerPlayClient netHandlerPlayClient = Minecraft.getMinecraft().getConnection();
    assert netHandlerPlayClient != null;
    netHandlerPlayClient.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, Minecraft
      .getMinecraft().objectMouseOver.sideHit));
  }
}

代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation

private void setController(Minecraft minecraft) {
  PlayerControllerMP controller = minecraft.playerController;
  World world = minecraft.world;
  if (!(controller instanceof PlayerController)) {
    GameType type = world.getWorldInfo().getGameType();
    NetHandlerPlayClient net = minecraft.getConnection();
    PlayerController ourController = new PlayerController(minecraft, net);
    ourController.setGameType(type);
    minecraft.playerController = ourController;
  }
}

代码示例来源:origin: Vazkii/Quark

@Override
public void onGuiClosed() {
  Keyboard.enableRepeatEvents(false);
  NetHandlerPlayClient nethandlerplayclient = this.mc.getConnection();
  if(nethandlerplayclient != null)
    nethandlerplayclient.sendPacket(new CPacketUpdateSign(sign.getPos(), sign.signText));
  sign.setEditable(true);
}

代码示例来源:origin: Glitchfiend/ToughAsNails

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onWorldUnload(WorldEvent.Unload event)
{
  if (event.getWorld().isRemote && !Minecraft.getMinecraft().getConnection().getNetworkManager().isChannelOpen())
  {
    SyncedConfig.restoreDefaults();
    ToughAsNails.logger.info("TAN configuration restored to local values");
  }
}

代码示例来源:origin: mezz/JustEnoughItems

@Override
public void sendPacketToServer(PacketJei packet) {
  NetHandlerPlayClient netHandler = FMLClientHandler.instance().getClient().getConnection();
  if (netHandler != null && ServerInfo.isJeiOnServer()) {
    netHandler.sendPacket(packet.getPacket());
  }
}

代码示例来源:origin: CyclopsMC/EvilCraft

Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging(
    CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos,
    Minecraft.getMinecraft().objectMouseOver.sideHit));

代码示例来源:origin: CoFH/CoFHCore

block.onBlockDestroyedByPlayer(world, pos, state);
  Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, pos, Minecraft.getMinecraft().objectMouseOver.sideHit));
  block.onBlockDestroyedByPlayer(world, pos, state);
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, pos, Minecraft.getMinecraft().objectMouseOver.sideHit));

代码示例来源:origin: CoFH/CoFHCore

block.onBlockDestroyedByPlayer(world, pos, state);
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, pos, Minecraft.getMinecraft().objectMouseOver.sideHit));

代码示例来源:origin: PrinceOfAmber/Cyclic

player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, posCurrent, Minecraft.getMinecraft().objectMouseOver.sideHit));

相关文章