• Recently Browsing

    No registered users viewing this page.

  • Posts

    • public static void handle(PlayerMentalCapabilityMessage msg, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> { }); ctx.get().setPacketHandled(true); } Is this all right? public static void handle(MyMessage msg, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> { // Work that needs to be threadsafe (most work) EntityPlayerMP sender = ctx.get().getSender(); // the client that sent this packet // do stuff }); ctx.get().setPacketHandled(true); } This is what the forge docs say, but if I'm right, EntityPlayerMP sender = ctx.get (). GetSender (); is for sending from client to server. I don't know how to send from server to client instead. public class MentalOverlayHander { public static final ResourceLocation MENTALICON = new ResourceLocation("depressionmod:textures/gui/overlay.png"); private final Minecraft mc = Minecraft.getInstance(); public int _currentMental; @SubscribeEvent public void onPreRenderOverlay(RenderGameOverlayEvent.Post event) { if (event.getType() == ElementType.ALL && mc.playerController.gameIsSurvivalOrAdventure()) { int scaledWidth = this.mc.getMainWindow().getScaledWidth(); int scaledHeight = this.mc.getMainWindow().getScaledHeight(); int left_height = ForgeIngameGui.left_height; int left = scaledWidth / 2 - 91; int top = scaledHeight - left_height; int level = _currentMental; RenderSystem.enableBlend(); RenderSystem.enableAlphaTest(); RenderSystem.color4f(1F, 1F, 1F, 1F); mc.getTextureManager().bindTexture(MENTALICON); for (int i = 0; i < 10; ++i) { //iが10未満のとき繰り返す。iは繰り返しごとに1増える。 int idx = i * 2 + 1; if (idx < level) { //iがMPより小さいとき普通の薬を描画。 //mc.getTextureManager().bindTexture(MENTALICON); mc.ingameGUI.blit(left, top, 0, 0, 9, 9); } else if (idx == level) { //iがMPと同じとき半分の薬を描画。 //mc.getTextureManager().bindTexture(MENTALICON); mc.ingameGUI.blit(left, top, 9, 0, 9, 9); } else if (idx > level) { //iがMPより大きいとき黒の薬を描画。 //mc.getTextureManager().bindTexture(MENTALICON); mc.ingameGUI.blit(left, top, 18, 0, 9, 9); } left += 8; //アイコンを描画する位置を右に一つ分ずらす } RenderSystem.disableBlend(); mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION); } } } I want to put the currentMental value of PlayerMentalCapabilityMessage in _currentMental of MentalOverlayHander.
    • Handle is called when the client has received the packet, so there should be where you sync the data (what you've done in the previous post is correct), which you should get the client player and its capability to sync in here. Also:  You can get the context from the supplier (given in the second parameter of handle(...), then call Context#setPacketHandled)
    • public class PlayerMentalCapabilityMessage { ClientPlayerEntity player = Minecraft.getInstance().player; LazyOptional<PlayerMentalInterface> playermentalinterface = player.getCapability(PlayerMentalCapabilityRegistry.PLAYER_MENTAL_CAPABILITY); int currentMental = ((PlayerMentalInterface) playermentalinterface).getMental(); public PlayerMentalCapabilityMessage(int currentMental) { this.currentMental = currentMental; } public static void encode(PlayerMentalCapabilityMessage message, PacketBuffer buf) { buf.writeInt(message.currentMental); } public static PlayerMentalCapabilityMessage decode(PacketBuffer buf) { int currentMental = buf.readInt(); return new PlayerMentalCapabilityMessage(currentMental); } public static void handle(PlayerMentalCapabilityMessage msg, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> { }); } } Is it like this? I'm still not sure about Context.setPacketHandled () so please tell me more.
    • Hello, I prepared a mod package for myself from twitch, when entering the game, it gives the following error: logs / fml-client-latest.log 1.7.10  details:http://www.mediafire.com/file/flpav855frvj2a1/latest.log/file
    • I cannot seem to download the forge launcher because the universal link says I have no application to launch it in. Is there a windows installer of the newer versions?
  • Topics

  • Who's Online (See full list)