Jump to content

Recommended Posts

Posted

Hello!

 

Everytime when I open a Gui and then clicking on the settings button, the game crashs with this error:

 

---- Minecraft Crash Report ----
// Why did you do that?

Time: 24.05.14 19:42
Description: Updating screen events

java.lang.IndexOutOfBoundsException: Index: 6, Size: 5
at java.util.ArrayList.rangeCheckForAdd(Unknown Source)
at java.util.ArrayList.add(Unknown Source)
at com.minecolonies.client.gui.GuiBase.addButton(GuiBase.java:55)
at com.minecolonies.client.gui.GuiBase.addButton(GuiBase.java:47)
at com.minecolonies.client.gui.GuiHutDeliveryMan.addDeliverySettingElements(GuiHutDeliveryMan.java:83)
at com.minecolonies.client.gui.GuiHutDeliveryMan.addElements(GuiHutDeliveryMan.java:110)
at com.minecolonies.client.gui.GuiBase.initGui(GuiBase.java:135)
at net.minecraft.client.gui.GuiScreen.setWorldAndResolution(GuiScreen.java:94)
at net.minecraft.client.Minecraft.displayGuiScreen(Minecraft.java:732)
at cpw.mods.fml.client.FMLClientHandler.showGuiScreen(FMLClientHandler.java:392)
at cpw.mods.fml.common.FMLCommonHandler.showGuiScreen(FMLCommonHandler.java:333)
at cpw.mods.fml.common.network.NetworkRegistry.openLocalGui(NetworkRegistry.java:328)
at cpw.mods.fml.common.network.FMLNetworkHandler.openGui(FMLNetworkHandler.java:357)
at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2480)
at com.minecolonies.client.gui.GuiHutDeliveryMan.actionPerformed(GuiHutDeliveryMan.java:145)
at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:69)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:128)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:107)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1566)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:910)
at net.minecraft.client.Minecraft.run(Minecraft.java:838)
at net.minecraft.client.main.Main.main(Main.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at java.util.ArrayList.rangeCheckForAdd(Unknown Source)
at java.util.ArrayList.add(Unknown Source)
at com.minecolonies.client.gui.GuiBase.addButton(GuiBase.java:55)
at com.minecolonies.client.gui.GuiBase.addButton(GuiBase.java:47)
at com.minecolonies.client.gui.GuiHutDeliveryMan.addDeliverySettingElements(GuiHutDeliveryMan.java:83)
at com.minecolonies.client.gui.GuiHutDeliveryMan.addElements(GuiHutDeliveryMan.java:110)
at com.minecolonies.client.gui.GuiBase.initGui(GuiBase.java:135)
at net.minecraft.client.gui.GuiScreen.setWorldAndResolution(GuiScreen.java:94)
at net.minecraft.client.Minecraft.displayGuiScreen(Minecraft.java:732)
at cpw.mods.fml.client.FMLClientHandler.showGuiScreen(FMLClientHandler.java:392)
at cpw.mods.fml.common.FMLCommonHandler.showGuiScreen(FMLCommonHandler.java:333)
at cpw.mods.fml.common.network.NetworkRegistry.openLocalGui(NetworkRegistry.java:328)
at cpw.mods.fml.common.network.FMLNetworkHandler.openGui(FMLNetworkHandler.java:357)
at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2480)
at com.minecolonies.client.gui.GuiHutDeliveryMan.actionPerformed(GuiHutDeliveryMan.java:145)
at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:69)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:128)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:107)

-- Affected screen --
Details:
Screen name: com.minecolonies.client.gui.GuiHutDeliveryMan

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Gamer_ABC'/265, l='MpServer', x=76,45, y=64,62, z=150,94]]
Chunk stats: MultiplayerChunkCache: 190
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: World: (24,64,156), Chunk: (at 8,4,12 in 1,9; contains blocks 16,0,144 to 31,255,159), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 4939 game time, 4939 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 133 total; [EntityClientPlayerMP['Gamer_ABC'/265, l='MpServer', x=76,45, y=64,62, z=150,94], EntityVillager['Villager'/78, l='MpServer', x=-2,88, y=71,00, z=107,34], EntityVillager['Villager'/80, l='MpServer', x=-3,78, y=72,00, z=100,63], EntityVillager['Villager'/82, l='MpServer', x=-1,94, y=71,00, z=112,50], EntityHorse['Horse'/83, l='MpServer', x=-0,44, y=68,00, z=164,66], EntityZombie['Zombie'/87, l='MpServer', x=6,31, y=31,00, z=93,50], EntityHorse['Horse'/88, l='MpServer', x=13,81, y=73,00, z=89,03], EntityVillager['Villager'/89, l='MpServer', x=7,50, y=73,00, z=93,94], EntityVillager['Villager'/90, l='MpServer', x=8,54, y=71,00, z=99,41], EntityVillager['Villager'/91, l='MpServer', x=3,91, y=71,00, z=106,50], EntityVillager['Villager'/92, l='MpServer', x=13,75, y=66,00, z=108,50], EntityVillager['Villager'/93, l='MpServer', x=1,53, y=71,00, z=104,53], EntityVillager['Villager'/94, l='MpServer', x=15,94, y=68,50, z=105,50], EntityVillager['Villager'/95, l='MpServer', x=1,44, y=72,00, z=98,31], EntityEnderman['Enderman'/96, l='MpServer', x=10,00, y=28,00, z=126,94], EntityVillager['Villager'/98, l='MpServer', x=3,16, y=70,00, z=113,00], EntityBat['Bat'/99, l='MpServer', x=14,69, y=16,10, z=136,75], EntityPig['Pig'/101, l='MpServer', x=6,56, y=69,00, z=128,53], EntityZombie['Zombie'/102, l='MpServer', x=10,13, y=39,00, z=155,31], EntityPig['Pig'/103, l='MpServer', x=13,38, y=64,00, z=146,41], EntityHorse['Horse'/104, l='MpServer', x=12,38, y=64,00, z=158,75], EntityPig['Pig'/105, l='MpServer', x=15,06, y=64,00, z=146,28], EntityChicken['Chicken'/106, l='MpServer', x=12,56, y=66,00, z=167,59], EntityChicken['Chicken'/107, l='MpServer', x=6,47, y=70,00, z=181,47], EntityBat['Bat'/108, l='MpServer', x=9,25, y=32,10, z=219,25], EntityHorse['Horse'/110, l='MpServer', x=20,09, y=67,00, z=104,02], EntityHorse['Horse'/111, l='MpServer', x=18,16, y=68,00, z=99,16], EntityItem['item.item.leather'/112, l='MpServer', x=18,53, y=68,13, z=100,47], EntityEnderman['Enderman'/113, l='MpServer', x=29,28, y=25,00, z=124,47], EntityEnderman['Enderman'/114, l='MpServer', x=20,59, y=20,00, z=141,00], EntityZombie['Zombie'/115, l='MpServer', x=29,34, y=20,00, z=144,97], EntityZombie['Zombie'/116, l='MpServer', x=28,47, y=20,00, z=145,00], EntityItem['item.item.seeds'/117, l='MpServer', x=27,78, y=64,13, z=159,09], EntityPig['Pig'/118, l='MpServer', x=18,06, y=64,00, z=147,03], EntityChicken['Chicken'/119, l='MpServer', x=18,06, y=66,00, z=170,16], EntityChicken['Chicken'/120, l='MpServer', x=31,75, y=69,00, z=165,22], EntityItem['item.item.seeds'/121, l='MpServer', x=25,16, y=67,13, z=186,88], EntityZombie['Zombie'/125, l='MpServer', x=40,62, y=20,00, z=73,50], EntityHorse['Horse'/126, l='MpServer', x=39,00, y=65,00, z=94,84], EntityHorse['Horse'/127, l='MpServer', x=33,88, y=65,00, z=95,28], EntityBat['Bat'/128, l='MpServer', x=30,33, y=23,55, z=96,10], EntityEnderman['Enderman'/129, l='MpServer', x=36,38, y=50,00, z=104,38], EntityHorse['Horse'/130, l='MpServer', x=34,28, y=64,00, z=99,16], EntityHorse['Horse'/131, l='MpServer', x=37,06, y=65,00, z=100,66], EntityHorse['Horse'/132, l='MpServer', x=34,28, y=64,00, z=101,03], EntityBat['Bat'/133, l='MpServer', x=37,43, y=23,09, z=114,82], EntityZombie['Zombie'/134, l='MpServer', x=32,50, y=34,00, z=115,94], EntityCreeper['Creeper'/135, l='MpServer', x=35,50, y=19,00, z=136,00], EntityBat['Bat'/136, l='MpServer', x=46,69, y=12,10, z=190,75], EntityBat['Bat'/137, l='MpServer', x=39,75, y=46,10, z=226,75], EntitySkeleton['Skeleton'/143, l='MpServer', x=63,69, y=48,00, z=72,28], EntityHorse['Horse'/144, l='MpServer', x=56,19, y=65,00, z=100,50], EntityCreeper['Creeper'/145, l='MpServer', x=48,03, y=55,00, z=188,53], EntitySquid['Squid'/146, l='MpServer', x=49,62, y=48,16, z=204,54], EntitySkeleton['Skeleton'/148, l='MpServer', x=66,47, y=24,00, z=76,66], EntitySkeleton['Skeleton'/149, l='MpServer', x=64,53, y=49,00, z=73,00], EntitySkeleton['Skeleton'/150, l='MpServer', x=69,06, y=50,00, z=79,44], EntityHorse['Horse'/151, l='MpServer', x=76,56, y=71,00, z=73,34], EntitySkeleton['Skeleton'/152, l='MpServer', x=72,19, y=12,00, z=84,61], EntityZombie['Zombie'/153, l='MpServer', x=76,50, y=27,00, z=93,25], EntityCreeper['Creeper'/154, l='MpServer', x=72,50, y=27,00, z=89,50], EntityHorse['Horse'/155, l='MpServer', x=70,16, y=63,00, z=107,16], EntityHorse['Horse'/156, l='MpServer', x=65,21, y=65,00, z=101,82], EntityHorse['Horse'/157, l='MpServer', x=67,22, y=64,00, z=103,63], EntityHorse['Horse'/158, l='MpServer', x=64,25, y=64,00, z=108,53], EntitySquid['Squid'/159, l='MpServer', x=72,41, y=47,25, z=128,09], EntityCreeper['Creeper'/160, l='MpServer', x=74,50, y=26,00, z=195,06], EntitySpider['Spider'/161, l='MpServer', x=69,16, y=27,00, z=207,44], EntitySquid['Squid'/162, l='MpServer', x=70,53, y=49,00, z=193,47], EntityZombie['Zombie'/163, l='MpServer', x=64,69, y=42,00, z=208,50], EntityZombie['Zombie'/164, l='MpServer', x=75,66, y=36,00, z=209,72], EntityHorse['Horse'/168, l='MpServer', x=80,41, y=71,00, z=72,16], EntityHorse['Horse'/169, l='MpServer', x=86,75, y=69,00, z=75,56], EntityHorse['Horse'/170, l='MpServer', x=84,38, y=69,00, z=76,44], EntityCreeper['Creeper'/171, l='MpServer', x=82,63, y=18,00, z=82,00], EntityCreeper['Creeper'/172, l='MpServer', x=95,59, y=58,00, z=84,31], EntityHorse['Horse'/173, l='MpServer', x=94,84, y=67,00, z=84,53], EntityHorse['Horse'/174, l='MpServer', x=90,06, y=68,00, z=86,16], EntityHorse['Horse'/175, l='MpServer', x=92,16, y=68,00, z=87,28], EntityHorse['Horse'/176, l='MpServer', x=84,91, y=65,00, z=82,06], EntityZombie['Zombie'/177, l='MpServer', x=81,78, y=24,00, z=96,53], EntityCreeper['Creeper'/178, l='MpServer', x=87,94, y=15,00, z=122,84], EntitySquid['Squid'/179, l='MpServer', x=79,71, y=48,02, z=120,69], EntitySquid['Squid'/180, l='MpServer', x=80,50, y=50,74, z=124,31], EntityCreeper['Creeper'/181, l='MpServer', x=95,31, y=25,00, z=183,31], EntityCreeper['Creeper'/182, l='MpServer', x=94,31, y=25,00, z=183,94], EntityCreeper['Creeper'/183, l='MpServer', x=95,50, y=25,00, z=185,50], EntityBat['Bat'/190, l='MpServer', x=104,25, y=33,10, z=72,53], EntityCreeper['Creeper'/191, l='MpServer', x=105,13, y=34,00, z=77,63], EntityZombie['Zombie'/192, l='MpServer', x=98,97, y=38,00, z=71,53], EntityHorse['Horse'/193, l='MpServer', x=100,38, y=65,00, z=79,03], EntityZombie['Zombie'/194, l='MpServer', x=98,47, y=30,00, z=81,28], EntityZombie['Zombie'/195, l='MpServer', x=101,47, y=30,00, z=87,53], EntityBat['Bat'/196, l='MpServer', x=101,02, y=28,87, z=80,11], EntityCreeper['Creeper'/197, l='MpServer', x=108,56, y=37,00, z=80,44], EntityHorse['Horse'/198, l='MpServer', x=96,13, y=66,00, z=86,19], EntityZombie['Zombie'/199, l='MpServer', x=111,31, y=14,00, z=182,47], EntityZombie['Zombie'/200, l='MpServer', x=104,47, y=25,00, z=182,16], EntitySquid['Squid'/201, l='MpServer', x=105,87, y=52,41, z=174,84], EntitySquid['Squid'/202, l='MpServer', x=105,15, y=57,08, z=200,34], EntityCreeper['Creeper'/203, l='MpServer', x=98,97, y=28,00, z=215,50], EntitySkeleton['Skeleton'/207, l='MpServer', x=115,50, y=14,00, z=75,22], EntityCreeper['Creeper'/208, l='MpServer', x=113,38, y=28,82, z=83,69], EntitySkeleton['Skeleton'/209, l='MpServer', x=120,50, y=25,00, z=103,97], EntityCreeper['Creeper'/210, l='MpServer', x=114,50, y=27,00, z=108,50], EntityZombie['Zombie'/211, l='MpServer', x=125,22, y=26,00, z=124,50], EntitySquid['Squid'/212, l='MpServer', x=124,56, y=48,25, z=157,61], EntityZombie['Zombie'/213, l='MpServer', x=113,27, y=14,00, z=181,48], EntitySquid['Squid'/214, l='MpServer', x=119,47, y=46,39, z=183,89], EntitySquid['Squid'/215, l='MpServer', x=127,11, y=46,00, z=182,53], EntityCreeper['Creeper'/216, l='MpServer', x=115,60, y=17,00, z=228,62], EntityBat['Bat'/221, l='MpServer', x=136,75, y=30,10, z=76,75], EntityZombie['Zombie'/223, l='MpServer', x=130,91, y=25,00, z=127,34], EntitySquid['Squid'/224, l='MpServer', x=128,28, y=50,44, z=136,98], EntitySkeleton['Skeleton'/225, l='MpServer', x=132,30, y=11,00, z=190,44], EntitySkeleton['Skeleton'/226, l='MpServer', x=131,72, y=14,00, z=189,50], EntitySkeleton['Skeleton'/227, l='MpServer', x=134,63, y=17,00, z=189,06], EntitySquid['Squid'/228, l='MpServer', x=141,59, y=46,35, z=188,50], EntityCreeper['Creeper'/229, l='MpServer', x=133,07, y=28,00, z=192,32], EntityCreeper['Creeper'/230, l='MpServer', x=130,88, y=24,00, z=204,09], EntityCreeper['Creeper'/231, l='MpServer', x=132,53, y=25,00, z=201,31], EntitySkeleton['Skeleton'/232, l='MpServer', x=133,38, y=25,00, z=203,13], EntityZombie['Zombie'/233, l='MpServer', x=139,84, y=23,00, z=207,28], EntitySkeleton['Skeleton'/234, l='MpServer', x=135,06, y=20,00, z=229,56], EntityZombie['Zombie'/242, l='MpServer', x=154,41, y=35,00, z=81,03], EntityZombie['Zombie'/243, l='MpServer', x=152,56, y=26,00, z=111,99], EntityCreeper['Creeper'/244, l='MpServer', x=145,50, y=29,00, z=101,50], EntityBat['Bat'/245, l='MpServer', x=155,31, y=35,10, z=101,47], EntityBat['Bat'/247, l='MpServer', x=145,75, y=13,10, z=135,25], EntitySkeleton['Skeleton'/249, l='MpServer', x=145,54, y=27,13, z=133,49], EntityBat['Bat'/250, l='MpServer', x=150,25, y=17,10, z=132,75], EntityBat['Bat'/252, l='MpServer', x=146,47, y=18,10, z=144,25], EntityBat['Bat'/253, l='MpServer', x=152,91, y=16,25, z=144,41]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:440)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2312)
at net.minecraft.client.Minecraft.run(Minecraft.java:856)
at net.minecraft.client.main.Main.main(Main.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

-- System Details --
Details:
Minecraft Version: 1.6.4
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.8.0_05, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 133770256 bytes (127 MB) / 355991552 bytes (339 MB) up to 3810525184 bytes (3634 MB)
JVM Flags: 0 total; 
AABB Pool Size: 15302 (856912 bytes; 0 MB) allocated, 2 (112 bytes; 0 MB) used
Suspicious classes: FML and Forge are installed
IntCache: cache: 18, tcache: 0, allocated: 3, tallocated: 63
FML: MCP v8.11 FML v6.99.19.964 Minecraft Forge 9.11.1.964 4 mods loaded, 4 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{6.99.19.964} [Forge Mod Loader] (forge-1.6.4-9.11.1.964-mcp.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{9.11.1.964} [Minecraft Forge] (forge-1.6.4-9.11.1.964-mcp.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
minecolonies{@VERSION@} [MineColonies] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: GeForce GTX 660/PCIe/SSE2 GL version 4.4.0, NVIDIA Corporation
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Pack: Default
Current Language: Pirate Speak (PIRATE)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 8580 (480480 bytes; 0 MB) allocated, 17 (952 bytes; 0 MB) used

 

Here is the code:

 

GuiHutDeliveryMan

 

package com.minecolonies.client.gui;

 

import net.minecraft.block.Block;

import net.minecraft.client.gui.GuiButton;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

 

import com.minecolonies.MineColonies;

import com.minecolonies.lib.EnumGUI;

import com.minecolonies.util.LanguageHandler;

 

public class GuiHutDeliveryMan extends GuiBase

{

 

    //IDs for Information

    protected final int idSettings = 5;

 

    //IDs for Settings

    protected final int idGoldToBlacksmith = 0, idDiamondToBlacksmith = 1, idStoneToStonemason = 2, idSandToStonemason = 3, idNetherrackToStonemason = 4, idQuartzToStonemason = 5, idArmorToGuards = 6, idWeaponToGuards = 7, idVisitCitizenChests = 8, idInformation = 9;

 

    protected EntityPlayer player;

    protected World        world;

    protected int          x, y, z;

    private int span = 4, page = 0;

 

    public GuiHutDeliveryMan(int page, EntityPlayer player, World world, int x, int y, int z)

    {

        super();

        this.page = page;

        this.player = player;

        this.world = world;

        this.x = x;

        this.y = y;

        this.z = z;

    }

 

    private void addDeliverySettingElements()

    {

        int smallButton = 30;

        int xl = (width - xSize) / 2 + xSize / 3 - 5;

        int xr = xl + xSize / 3;

        int y = middleY + span;

        int textPaddTop = 6, textPaddRight = 3;

 

        String yes = LanguageHandler.format("com.minecolonies.gui.yes");

        String no = LanguageHandler.format("com.minecolonies.gui.no");

        String information = LanguageHandler.format("com.minecolonies.gui.workerHuts.information");

        String toBlacksmith = LanguageHandler.format("com.minecolonies.gui.deliverymanHut.toBlacksmith");

        String toStonemason = LanguageHandler.format("com.minecolonies.gui.deliverymanHut.toStonemason");

        String toGuards = LanguageHandler.format("com.minecolonies.gui.deliverymanHut.toGuards");

        String visitCitizenChests = LanguageHandler.format("com.minecolonies.gui.deliverymanHut.visitCitizenChests");

 

        addLabel(toBlacksmith, middleX - fontRenderer.getStringWidth(toBlacksmith) / 2, y + textPaddTop);

        y += buttonHeight;

 

        addIcon(new ItemStack(Item.ingotGold, 1), xl - 16 - textPaddRight, y + (buttonHeight - 16) / 2);

        addButton(idGoldToBlacksmith, no, xl, y, smallButton, buttonHeight);

        addIcon(new ItemStack(Item.diamond, 1), xr - 16 - textPaddRight, y + (buttonHeight - 16) / 2);

        addButton(idDiamondToBlacksmith, no, xr, y, smallButton, buttonHeight);

        y += buttonHeight + buttonSpan + 1;

 

        addLabel(toStonemason, middleX - fontRenderer.getStringWidth(toStonemason) / 2, y + textPaddTop);

        y += buttonHeight;

 

        addIcon(new ItemStack(Block.cobblestone, 1), xl - 16 - textPaddRight, y + (buttonHeight - 16) / 2);

        addButton(idStoneToStonemason, yes, xl, y, smallButton, buttonHeight);

        addIcon(new ItemStack(Block.sand, 1), xr - 16 - textPaddRight, y + (buttonHeight - 16) / 2);

        addButton(idSandToStonemason, no, xr, y, smallButton, buttonHeight);

        y += buttonHeight + buttonSpan;

 

        addIcon(new ItemStack(Block.netherrack, 1), xl - 16 - textPaddRight, y + (buttonHeight - 16) / 2);

        addButton(idNetherrackToStonemason, yes, xl, y, smallButton, buttonHeight);

        //addIcon(new ItemStack(Item.quartz, 1), xr - 16 - textPaddRight, y + (buttonHeight - 16) / 2);

        //addButton(idQuartzToStonemason, no, xr, y, smallButton, buttonHeight);

        y += buttonHeight + buttonSpan + 1;

 

        addLabel(toGuards, middleX - fontRenderer.getStringWidth(toGuards) / 2, y + textPaddTop);

        y += buttonHeight;

 

        addIcon(new ItemStack(Item.plateIron, 1), xl - 16 - textPaddRight, y + (buttonHeight - 16) / 2);

        addButton(idArmorToGuards, no, xl, y, smallButton, buttonHeight);

        addIcon(new ItemStack(Item.swordIron, 1), xr - 16 - textPaddRight, y + (buttonHeight - 16) / 2);

        addButton(idWeaponToGuards, no, xr, y, smallButton, buttonHeight);

        y += buttonHeight + buttonSpan + 1;

 

        addLabel(visitCitizenChests, middleX - fontRenderer.getStringWidth(visitCitizenChests) / 2, y + textPaddTop);

        y += textPaddTop + 10;

        addButton(idVisitCitizenChests, no, middleX - smallButton / 2, y, smallButton, buttonHeight);

 

        addButton(idInformation, information, middleX - buttonWidth / 2, middleY + ySize - 34, buttonWidth, buttonHeight);

 

    }

 

    @Override

    protected void addElements()

    {

        super.addElements();

 

        switch(page)

        {

            case 0:

                addDefaultWorkerLayout(LanguageHandler.format("com.minecolonies.gui.workerHuts.deliverymansHut"), "John R. Jones", "xx (yy)", "xxxxxxxx", span);

 

                String settings = LanguageHandler.format("com.minecolonies.gui.workerHuts.settings");

                addButton(idSettings, settings, middleX - buttonWidth / 2, middleY + ySize - 34, buttonWidth, buttonHeight);

                break;

            case 1:

                addDeliverySettingElements();

                break;

        }

    }

 

    @Override

    protected void actionPerformed(GuiButton guiButton)

    {

        //Actions for Information Tab

        if(page == 0)

        {

            switch(guiButton.id)

            {

                case idHireWorker:

                    ((GuiButton) buttonList.get(idFireWorker)).enabled = true;

                    break;

                case idFireWorker:

                    GuiButton hireButton = (GuiButton) buttonList.get(idHireWorker);

                    if(hireButton.enabled)

                    {

                        hireButton.enabled = false;

                    }

                    else

                    {

                        guiButton.enabled = false;

                        hireButton.enabled = true;

                    }

                    break;

                case idRecallWorker:

                    break;

                case idBuildBuilding:

                    break;

                case idRepairBuilding:

                    break;

                case idSettings:

                    player.openGui(MineColonies.instance, EnumGUI.WAREHOUSE_SETTINGS.getID(), world, x, y, z);

                    break;

            }

        }

        else if(page == 1)

        {

            switch(guiButton.id)

            {

                case idGoldToBlacksmith:

                    break;

                case idInformation:

                    player.openGui(MineColonies.instance, EnumGUI.WAREHOUSE.getID(), world, x, y, z);

                    break;

            }

        }

    }

}

 

and GuiBase

 

package com.minecolonies.client.gui;

import java.util.ArrayList;

import org.lwjgl.opengl.GL11;

import com.minecolonies.lib.Constants;
import com.minecolonies.util.LanguageHandler;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

public class GuiBase extends GuiScreen
{

    protected final int idHireWorker = 0, //IDs for default layout
            idFireWorker             = 1, idRecallWorker = 2, idBuildBuilding = 3, idRepairBuilding = 4;
    protected final ResourceLocation background                                  = new ResourceLocation(Constants.MODID + ":" + "textures/gui/guiInformatorBackground.png");
    protected       int              middleX, middleY, xSize, ySize, buttonWidth = 116, buttonHeight = 20, buttonSpan = 4;
protected ArrayList<GuiModIcon> iconList;
protected ArrayList<GuiModLabel> labelList;

public GuiBase()
    {
        super();
        xSize = 171;
        ySize = 247;
        iconList = new ArrayList<GuiModIcon>();
        labelList = new ArrayList<GuiModLabel>();
    }

    protected void addElements()
    {
        middleX = (width / 2);
        middleY = (height - ySize) / 2;

        buttonList.clear();
        labelList.clear();
        iconList.clear();
    }

    protected void addButton(int id, String text, int x, int y, int w, int h)
    {
        addButton(id, text, x, y, w, h, true);
    }

    @SuppressWarnings("unchecked")
protected void addButton(int id, String text, int x, int y, int w, int h, boolean visible)
    {
        GuiButton button = new GuiButton(id, x, y, w, h, text);
        button.enabled = visible;
        buttonList.add(id, button);
    }

protected void addLabel(String text, int x, int y)
    {
        labelList.add(new GuiModLabel(text, x, y));
    }

protected void addLabel(String text, int x, int y, int color)
    {
        labelList.add(new GuiModLabel(text, x, y, color));
    }

protected void addIcon(ItemStack is, int x, int y)
    {
        iconList.add(new GuiModIcon(is, x, y));
    }

    protected void addDefaultWorkerLayout(String hutName, String workerName, String level, String type)
    {
        addDefaultWorkerLayout(hutName, workerName, level, type, 0);
    }

    protected void addDefaultWorkerLayout(String hutName, String workerName, String level, String type, int span)
    {
        String workerAssigned = LanguageHandler.format("com.minecolonies.gui.workerHuts.workerAssigned");
        String workerLevel = LanguageHandler.format("com.minecolonies.gui.workerHuts.workerLevel");
        String buildType = LanguageHandler.format("com.minecolonies.gui.workerHuts.buildType");

        addLabel(hutName, middleX - fontRenderer.getStringWidth(hutName) / 2, middleY + span, 0xff0000);
        addLabel(workerAssigned, middleX - fontRenderer.getStringWidth(workerAssigned) / 2, middleY + span + 18);
        addLabel(workerName, middleX - fontRenderer.getStringWidth(workerName) / 2, middleY + span + 28);
        addLabel(workerLevel + " " + level, middleX - fontRenderer.getStringWidth(workerLevel + " " + level) / 2, middleY + span + 44);
        addButton(idHireWorker, LanguageHandler.format("com.minecolonies.gui.workerHuts.hire"), middleX - buttonWidth / 2, middleY + span + 64, buttonWidth, buttonHeight, false);
        addButton(idFireWorker, LanguageHandler.format("com.minecolonies.gui.workerHuts.fire"), middleX - buttonWidth / 2, middleY + span + 64, buttonWidth, buttonHeight);
        addButton(idRecallWorker, LanguageHandler.format("com.minecolonies.gui.workerHuts.recall"), middleX - buttonWidth / 2, middleY + span + 88, buttonWidth, buttonHeight);
        addButton(idBuildBuilding, LanguageHandler.format("com.minecolonies.gui.workerHuts.build"), middleX - buttonWidth / 2, middleY + span + 120, buttonWidth, buttonHeight);
        addButton(idRepairBuilding, LanguageHandler.format("com.minecolonies.gui.workerHuts.repair"), middleX - buttonWidth / 2, middleY + span + 144, buttonWidth, buttonHeight);
        addLabel(buildType, middleX - fontRenderer.getStringWidth(buildType) / 2, middleY + span + 172);
        addLabel(type, middleX - fontRenderer.getStringWidth(type) / 2, middleY + span + 182);
    }

    protected void drawGuiBackground()
    {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        mc.renderEngine.bindTexture(background);
        int xCoord = (width - xSize) / 2;
        int yCoord = (height - ySize - 10) / 2;
        drawTexturedModalRect(xCoord, yCoord, 0, 0, xSize, ySize);
    }

    @Override
    public void drawScreen(int mouseX, int mouseY, float par3)
    {
        drawGuiBackground();
        RenderItem itemRender = new RenderItem();
        int k;
        for(k = 0; k < this.buttonList.size(); k++)
        {
            ((GuiButton) this.buttonList.get(k)).drawButton(this.mc, mouseX, mouseY);
        }
        for(k = 0; k < this.labelList.size(); k++)
        {
            (this.labelList.get(k)).drawLabel(this.mc);
        }
        for(k = 0; k < this.iconList.size(); k++)
        {
            (this.iconList.get(k)).drawIcon(this.mc, itemRender); //itemRender comes from GuiScreen 1.7
        }
    }

    @Override
    public boolean doesGuiPauseGame()
    {
        return false;
    }

    @Override
    public void initGui()
    {
        addElements();
        super.initGui();
    }

    @Override
    protected void keyTyped(char par1, int par2)
    {
        if(par2 == 1 || par2 == this.mc.gameSettings.keyBindInventory.keyCode) // getKeyCode()
        {
            this.mc.thePlayer.closeScreen();
        }
    }
}

 

 

I hope that you can help me!

 

Bektor

Developer of Primeval Forest.

Posted

   buttonList.add(id, button);

That method is not what you think it is. labelList is a simple ArrayList ... if you add a buton with an index (such as id), then the array already has to have enough elements to fill up to that index. Put the ID in the button it self or start your ids at 0.

 

Posted

   buttonList.add(id, button);

That method is not what you think it is. labelList is a simple ArrayList ... if you add a buton with an index (such as id), then the array already has to have enough elements to fill up to that index. Put the ID in the button it self or start your ids at 0.

 

The ids startinb by 0, if you look in my code.

Ok, to put the ids it self to the buttons fixed this problem,  :)

but why works it for every other Gui?  ???

Developer of Primeval Forest.

Posted

Ok, it doen't work really. It works only because there is a button that isn't used currently. If this button is uncomment then it crashs again with the same crash.

 

package com.minecolonies.client.gui;

import net.minecraft.block.Block;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

import com.minecolonies.MineColonies;
import com.minecolonies.lib.EnumGUI;
import com.minecolonies.util.LanguageHandler;

public class GuiHutDeliveryMan extends GuiBase
{

    //IDs for Information
    protected final int idSettings = 5;

    //IDs for Settings
    protected final int idGoldToBlacksmith = 0, idDiamondToBlacksmith = 1, idStoneToStonemason = 2, idSandToStonemason = 3, idNetherrackToStonemason = 4, idQuartzToStonemason = 5, idArmorToGuards = 6, idWeaponToGuards = 7, idVisitCitizenChests = 8, idInformation = 9;

    protected EntityPlayer player;
    protected World        world;
    protected int          x, y, z;
    private int span = 4, page = 0;

    public GuiHutDeliveryMan(int page, EntityPlayer player, World world, int x, int y, int z)
    {
        super();
        this.page = page;
        this.player = player;
        this.world = world;
        this.x = x;
        this.y = y;
        this.z = z;
    }

    private void addDeliverySettingElements()
    {
        int smallButton = 30;
        int xl = (width - xSize) / 2 + xSize / 3 - 5;
        int xr = xl + xSize / 3;
        int y = middleY + span;
        int textPaddTop = 6, textPaddRight = 3;

        String yes = LanguageHandler.format("com.minecolonies.gui.yes");
        String no = LanguageHandler.format("com.minecolonies.gui.no");
        String information = LanguageHandler.format("com.minecolonies.gui.workerHuts.information");
        String toBlacksmith = LanguageHandler.format("com.minecolonies.gui.deliverymanHut.toBlacksmith");
        String toStonemason = LanguageHandler.format("com.minecolonies.gui.deliverymanHut.toStonemason");
        String toGuards = LanguageHandler.format("com.minecolonies.gui.deliverymanHut.toGuards");
        String visitCitizenChests = LanguageHandler.format("com.minecolonies.gui.deliverymanHut.visitCitizenChests");

        addLabel(toBlacksmith, middleX - fontRenderer.getStringWidth(toBlacksmith) / 2, y + textPaddTop);
        y += buttonHeight;

        addIcon(new ItemStack(Item.ingotGold, 1), xl - 16 - textPaddRight, y + (buttonHeight - 16) / 2);
        addButton(0, no, xl, y, smallButton, buttonHeight);
        addIcon(new ItemStack(Item.diamond, 1), xr - 16 - textPaddRight, y + (buttonHeight - 16) / 2);
        addButton(1, no, xr, y, smallButton, buttonHeight);
        y += buttonHeight + buttonSpan + 1;

        addLabel(toStonemason, middleX - fontRenderer.getStringWidth(toStonemason) / 2, y + textPaddTop);
        y += buttonHeight;

        addIcon(new ItemStack(Block.cobblestone, 1), xl - 16 - textPaddRight, y + (buttonHeight - 16) / 2);
        addButton(2, yes, xl, y, smallButton, buttonHeight);
        addIcon(new ItemStack(Block.sand, 1), xr - 16 - textPaddRight, y + (buttonHeight - 16) / 2);
        addButton(3, no, xr, y, smallButton, buttonHeight);
        y += buttonHeight + buttonSpan;

        addIcon(new ItemStack(Block.netherrack, 1), xl - 16 - textPaddRight, y + (buttonHeight - 16) / 2);
        addButton(4, yes, xl, y, smallButton, buttonHeight);
        //addIcon(new ItemStack(Item.quartz, 1), xr - 16 - textPaddRight, y + (buttonHeight - 16) / 2);
        addButton(5, no, xr, y, smallButton, buttonHeight);
        y += buttonHeight + buttonSpan + 1;

        addLabel(toGuards, middleX - fontRenderer.getStringWidth(toGuards) / 2, y + textPaddTop);
        y += buttonHeight;

        addIcon(new ItemStack(Item.plateIron, 1), xl - 16 - textPaddRight, y + (buttonHeight - 16) / 2);
        addButton(6, no, xl, y, smallButton, buttonHeight);
        addIcon(new ItemStack(Item.swordIron, 1), xr - 16 - textPaddRight, y + (buttonHeight - 16) / 2);
        addButton(7, no, xr, y, smallButton, buttonHeight);
        y += buttonHeight + buttonSpan + 1;

        addLabel(visitCitizenChests, middleX - fontRenderer.getStringWidth(visitCitizenChests) / 2, y + textPaddTop);
        y += textPaddTop + 10;
        addButton(8, no, middleX - smallButton / 2, y, smallButton, buttonHeight);

        addButton(9, information, middleX - buttonWidth / 2, middleY + ySize - 34, buttonWidth, buttonHeight);

    }

    @Override
    protected void addElements()
    {
        super.addElements();

        switch(page)
        {
            case 0:
                addDefaultWorkerLayout(LanguageHandler.format("com.minecolonies.gui.workerHuts.deliverymansHut"), "John R. Jones", "xx (yy)", "xxxxxxxx", span);

                String settings = LanguageHandler.format("com.minecolonies.gui.workerHuts.settings");
                addButton(idSettings, settings, middleX - buttonWidth / 2, middleY + ySize - 34, buttonWidth, buttonHeight);
                break;
            case 1:
                addDeliverySettingElements();
                break;
        }
    }

    @Override
    protected void actionPerformed(GuiButton guiButton)
    {
        //Actions for Information Tab
        if(page == 0)
        {
            switch(guiButton.id)
            {
                case idHireWorker:
                    ((GuiButton) buttonList.get(idFireWorker)).enabled = true;
                    break;
                case idFireWorker:
                    GuiButton hireButton = (GuiButton) buttonList.get(idHireWorker);
                    if(hireButton.enabled)
                    {
                        hireButton.enabled = false;
                    }
                    else
                    {
                        guiButton.enabled = false;
                        hireButton.enabled = true;
                    }
                    break;
                case idRecallWorker:
                    break;
                case idBuildBuilding:
                    break;
                case idRepairBuilding:
                    break;
                case idSettings:
                    player.openGui(MineColonies.instance, EnumGUI.WAREHOUSE_SETTINGS.getID(), world, x, y, z);
                    break;
            }
        }
        else if(page == 1)
        {
            switch(guiButton.id)
            {
                case idGoldToBlacksmith:
                    break;
                case idInformation:
                    player.openGui(MineColonies.instance, EnumGUI.WAREHOUSE.getID(), world, x, y, z);
                    break;
            }
        }
    }
}

 

Well, by "readding" this button all ids under this button changes (+1).

Developer of Primeval Forest.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.