Jump to content

[1.7.2][Solved] Mod loading problem after quit to title -> creating new world


Recommended Posts

Posted

Hello again,

 

i recognized a strange problem, which is present in every mod i created! (i'm using Forge 10.12.0.1046)

 

So what happens:

If i create a very simple mod, like 1 item without textures and stuff. One simple useless item. (Adding the item is done, in preinit.)

Now i start minecraft. I create a new world. The item present! *cheer* BUT! I don't like the world, so im going to create a new one!

So i create a new world again! What happens now? Yes, the item is gone!

Now i thought -- its gone from creative tab, lets do a crafting recipe!!

 

The Recipe is working! The item is shown at the slot, but if i take the item:

 

---- Minecraft Crash Report ----
// Ooh. Shiny.

Time: 16.03.14 23:08
Description: Updating screen events

java.lang.ArrayIndexOutOfBoundsException: -1
at net.minecraft.item.ItemStack.onCrafting(ItemStack.java:473)
at net.minecraft.inventory.SlotCrafting.onCrafting(SlotCrafting.java:76)
at net.minecraft.inventory.SlotCrafting.onCrafting(SlotCrafting.java:68)
at net.minecraft.inventory.Slot.onSlotChange(Slot.java:63)
at net.minecraft.inventory.ContainerWorkbench.transferStackInSlot(ContainerWorkbench.java:111)
at net.minecraft.inventory.Container.slotClick(Container.java:285)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:500)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:691)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:434)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:353)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:317)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1730)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039)
at net.minecraft.client.Minecraft.run(Minecraft.java:954)
at net.minecraft.client.main.Main.main(Main.java:112)
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:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)


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

-- Head --
Stacktrace:
at net.minecraft.item.ItemStack.onCrafting(ItemStack.java:473)
at net.minecraft.inventory.SlotCrafting.onCrafting(SlotCrafting.java:76)
at net.minecraft.inventory.SlotCrafting.onCrafting(SlotCrafting.java:68)
at net.minecraft.inventory.Slot.onSlotChange(Slot.java:63)
at net.minecraft.inventory.ContainerWorkbench.transferStackInSlot(ContainerWorkbench.java:111)
at net.minecraft.inventory.Container.slotClick(Container.java:285)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:500)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:691)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:434)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:353)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:317)

-- Affected screen --
Details:
Screen name: net.minecraft.client.gui.inventory.GuiCrafting

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Zzyxzz'/913, l='MpServer', x=-77,50, y=78,62, z=252,50]]
Chunk stats: MultiplayerChunkCache: 225, 225
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: World: (-68,64,256), Chunk: (at 12,4,0 in -5,16; contains blocks -80,0,256 to -65,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Level time: 426 game time, 426 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: 128 total; [EntitySkeleton['Skeleton'/2196, l='MpServer', x=-70,50, y=23,00, z=282,50], EntityCreeper['Creeper'/1121, l='MpServer', x=-106,50, y=30,00, z=282,50], EntitySpider['Spider'/1147, l='MpServer', x=0,50, y=16,00, z=295,78], EntitySkeleton['Skeleton'/2270, l='MpServer', x=-101,50, y=28,00, z=313,50], EntitySkeleton['Skeleton'/1049, l='MpServer', x=-135,50, y=40,00, z=205,94], EntitySkeleton['Skeleton'/1051, l='MpServer', x=-137,97, y=45,00, z=209,69], EntitySkeleton['Skeleton'/1050, l='MpServer', x=-139,06, y=45,00, z=209,44], EntitySkeleton['Skeleton'/1055, l='MpServer', x=-28,50, y=24,00, z=327,50], EntityCreeper['Creeper'/1045, l='MpServer', x=-22,50, y=26,00, z=314,50], EntityCreeper['Creeper'/1044, l='MpServer', x=-23,50, y=26,00, z=315,50], EntitySkeleton['Skeleton'/1047, l='MpServer', x=-20,50, y=26,00, z=312,50], EntitySkeleton['Skeleton'/1046, l='MpServer', x=-22,50, y=26,00, z=315,50], EntityCreeper['Creeper'/1064, l='MpServer', x=-95,50, y=28,00, z=317,50], EntityCreeper['Creeper'/1065, l='MpServer', x=-91,53, y=31,00, z=309,00], EntityWitch['Witch'/1062, l='MpServer', x=-106,50, y=28,00, z=312,50], EntityWitch['Witch'/1063, l='MpServer', x=-105,50, y=28,00, z=313,50], EntityWitch['Witch'/1061, l='MpServer', x=-106,50, y=28,00, z=314,50], EntityBat['Bat'/1078, l='MpServer', x=-140,75, y=48,51, z=297,75], EntityZombie['Zombie'/2273, l='MpServer', x=-105,50, y=28,00, z=312,50], EntityZombie['Zombie'/2272, l='MpServer', x=-104,50, y=28,00, z=312,50], EntityBat['Bat'/1241, l='MpServer', x=-145,77, y=31,90, z=318,68], EntityBat['Bat'/4498, l='MpServer', x=-155,44, y=31,13, z=231,53], EntityZombie['Zombie'/1258, l='MpServer', x=-120,66, y=50,00, z=205,34], EntityCreeper['Creeper'/1257, l='MpServer', x=-17,53, y=16,00, z=284,34], EntityCreeper['Creeper'/2090, l='MpServer', x=-18,50, y=28,00, z=268,50], EntitySkeleton['Skeleton'/2094, l='MpServer', x=-76,50, y=35,00, z=332,50], EntitySkeleton['Skeleton'/2093, l='MpServer', x=-75,50, y=35,00, z=332,50], EntitySkeleton['Skeleton'/2140, l='MpServer', x=-12,50, y=21,00, z=323,50], EntitySkeleton['Skeleton'/2143, l='MpServer', x=-134,50, y=18,00, z=285,50], EntityZombie['Zombie'/2115, l='MpServer', x=-142,50, y=45,00, z=308,50], EntityBat['Bat'/1193, l='MpServer', x=-107,53, y=49,60, z=322,75], EntitySkeleton['Skeleton'/2144, l='MpServer', x=-135,50, y=18,00, z=283,50], EntityCreeper['Creeper'/2446, l='MpServer', x=-100,50, y=26,00, z=307,06], EntityCreeper['Creeper'/2445, l='MpServer', x=-93,50, y=33,00, z=302,50], EntityBat['Bat'/3575, l='MpServer', x=-76,55, y=30,09, z=324,57], EntityZombie['Zombie'/1474, l='MpServer', x=-8,22, y=20,00, z=292,53], EntityZombie['Zombie'/1473, l='MpServer', x=-6,66, y=20,00, z=294,34], EntityZombie['Zombie'/1472, l='MpServer', x=-6,19, y=20,00, z=292,81], EntityCreeper['Creeper'/2357, l='MpServer', x=-100,50, y=50,00, z=323,50], EntityZombie['Zombie'/2385, l='MpServer', x=-104,78, y=37,00, z=322,41], EntityZombie['Zombie'/1466, l='MpServer', x=-7,72, y=20,00, z=291,09], EntityZombie['Zombie'/1467, l='MpServer', x=-3,50, y=20,00, z=300,50], EntityZombie['Zombie'/1468, l='MpServer', x=-10,50, y=20,00, z=293,50], EntityZombie['Zombie'/1469, l='MpServer', x=-2,03, y=17,00, z=296,47], EntityZombie['Zombie'/1470, l='MpServer', x=-9,56, y=20,00, z=296,00], EntityZombie['Zombie'/1471, l='MpServer', x=-11,50, y=20,00, z=292,50], EntityItem['item.item.string'/6000, l='MpServer', x=-117,25, y=14,13, z=236,31], EntitySpider['Spider'/1627, l='MpServer', x=-94,50, y=40,00, z=320,50], EntitySkeleton['Skeleton'/1628, l='MpServer', x=-94,50, y=40,17, z=320,50], EntitySkeleton['Skeleton'/1621, l='MpServer', x=-114,50, y=46,00, z=314,50], EntitySkeleton['Skeleton'/1623, l='MpServer', x=-110,50, y=46,00, z=308,50], EntitySkeleton['Skeleton'/1622, l='MpServer', x=-109,50, y=46,00, z=311,50], EntityBat['Bat'/1549, l='MpServer', x=-97,59, y=19,20, z=282,74], EntityBat['Bat'/1545, l='MpServer', x=-13,28, y=21,23, z=286,75], EntityZombie['Zombie'/1747, l='MpServer', x=-118,97, y=15,00, z=234,47], EntitySkeleton['Skeleton'/1748, l='MpServer', x=-119,50, y=15,00, z=231,50], EntitySkeleton['Skeleton'/1755, l='MpServer', x=-103,63, y=28,00, z=280,91], EntitySpider['Spider'/1757, l='MpServer', x=-102,50, y=30,00, z=285,50], EntitySheep['Sheep'/751, l='MpServer', x=-96,06, y=67,00, z=266,34], EntitySheep['Sheep'/750, l='MpServer', x=-99,91, y=64,00, z=255,28], EntitySheep['Sheep'/749, l='MpServer', x=-92,47, y=73,46, z=255,67], EntitySheep['Sheep'/739, l='MpServer', x=-110,50, y=70,00, z=291,38], EntitySheep['Sheep'/738, l='MpServer', x=-110,50, y=71,00, z=292,53], EntitySheep['Sheep'/737, l='MpServer', x=-114,19, y=70,00, z=268,47], EntitySheep['Sheep'/736, l='MpServer', x=-117,50, y=70,00, z=267,50], EntitySheep['Sheep'/741, l='MpServer', x=-111,50, y=72,00, z=289,50], EntitySheep['Sheep'/740, l='MpServer', x=-110,50, y=70,00, z=290,03], EntityWolf['Wolf'/760, l='MpServer', x=-94,50, y=73,00, z=325,50], EntitySheep['Sheep'/766, l='MpServer', x=-81,50, y=81,00, z=208,50], EntitySheep['Sheep'/767, l='MpServer', x=-83,50, y=82,00, z=211,50], EntitySheep['Sheep'/765, l='MpServer', x=-85,50, y=82,00, z=206,50], EntitySheep['Sheep'/754, l='MpServer', x=-103,97, y=81,00, z=324,19], EntitySheep['Sheep'/755, l='MpServer', x=-101,50, y=80,00, z=322,50], EntitySheep['Sheep'/752, l='MpServer', x=-93,53, y=71,00, z=261,78], EntitySheep['Sheep'/753, l='MpServer', x=-102,47, y=80,00, z=326,09], EntityWolf['Wolf'/758, l='MpServer', x=-83,03, y=70,00, z=328,97], EntitySheep['Sheep'/756, l='MpServer', x=-102,34, y=80,00, z=324,47], EntityWolf['Wolf'/757, l='MpServer', x=-80,21, y=68,00, z=323,64], EntitySheep['Sheep'/734, l='MpServer', x=-116,09, y=71,00, z=269,50], EntitySheep['Sheep'/735, l='MpServer', x=-114,19, y=70,00, z=270,53], EntitySheep['Sheep'/821, l='MpServer', x=-36,50, y=69,00, z=312,50], EntitySheep['Sheep'/820, l='MpServer', x=-36,50, y=76,00, z=254,50], EntitySheep['Sheep'/823, l='MpServer', x=-38,50, y=69,00, z=314,50], EntitySheep['Sheep'/822, l='MpServer', x=-45,31, y=72,00, z=304,53], EntitySheep['Sheep'/817, l='MpServer', x=-34,53, y=75,00, z=254,47], EntitySheep['Sheep'/819, l='MpServer', x=-33,13, y=74,00, z=255,53], EntitySheep['Sheep'/818, l='MpServer', x=-34,53, y=77,00, z=247,88], EntitySheep['Sheep'/829, l='MpServer', x=-11,53, y=70,00, z=234,88], EntitySheep['Sheep'/828, l='MpServer', x=-19,47, y=72,00, z=207,38], EntitySheep['Sheep'/831, l='MpServer', x=-11,53, y=70,00, z=232,47], EntitySheep['Sheep'/830, l='MpServer', x=-10,47, y=70,00, z=232,47], EntitySheep['Sheep'/825, l='MpServer', x=-13,50, y=70,00, z=207,50], EntitySheep['Sheep'/824, l='MpServer', x=-35,50, y=64,00, z=314,50], EntitySheep['Sheep'/827, l='MpServer', x=-29,13, y=73,00, z=205,19], EntitySheep['Sheep'/826, l='MpServer', x=-16,50, y=71,00, z=208,50], EntitySheep['Sheep'/784, l='MpServer', x=-74,47, y=75,00, z=260,38], EntityPig['Pig'/797, l='MpServer', x=-53,50, y=64,00, z=330,50], EntitySheep['Sheep'/796, l='MpServer', x=-45,19, y=84,00, z=233,38], EntitySheep['Sheep'/795, l='MpServer', x=-60,76, y=81,00, z=245,56], EntitySheep['Sheep'/794, l='MpServer', x=-56,53, y=84,00, z=234,53], EntitySheep['Sheep'/793, l='MpServer', x=-55,50, y=84,00, z=232,50], EntitySheep['Sheep'/775, l='MpServer', x=-81,28, y=69,00, z=330,19], EntitySheep['Sheep'/772, l='MpServer', x=-79,31, y=80,00, z=234,53], EntitySheep['Sheep'/770, l='MpServer', x=-85,38, y=79,00, z=235,38], EntitySheep['Sheep'/771, l='MpServer', x=-86,88, y=79,00, z=242,13], EntitySheep['Sheep'/768, l='MpServer', x=-81,38, y=81,00, z=219,47], EntitySheep['Sheep'/769, l='MpServer', x=-84,47, y=79,92, z=240,50], EntitySheep['Sheep'/782, l='MpServer', x=-66,46, y=74,00, z=264,36], EntitySheep['Sheep'/783, l='MpServer', x=-68,19, y=72,00, z=272,91], EntitySheep['Sheep'/780, l='MpServer', x=-69,50, y=74,00, z=176,50], EntitySheep['Sheep'/781, l='MpServer', x=-64,50, y=74,00, z=264,50], EntityCreeper['Creeper'/1862, l='MpServer', x=-77,50, y=45,00, z=307,50], EntityCreeper['Creeper'/1863, l='MpServer', x=-72,50, y=44,00, z=324,50], EntityZombie['Zombie'/1841, l='MpServer', x=-25,50, y=30,00, z=254,50], EntitySheep['Sheep'/834, l='MpServer', x=-3,78, y=64,00, z=261,78], EntitySheep['Sheep'/835, l='MpServer', x=-2,19, y=64,00, z=260,19], EntitySheep['Sheep'/832, l='MpServer', x=-11,53, y=70,00, z=233,66], EntitySheep['Sheep'/833, l='MpServer', x=-5,50, y=64,00, z=260,50], EntitySheep['Sheep'/836, l='MpServer', x=-4,50, y=64,00, z=263,50], EntitySkeleton['Skeleton'/1969, l='MpServer', x=-97,06, y=36,00, z=248,47], EntitySkeleton['Skeleton'/1970, l='MpServer', x=-95,50, y=35,00, z=249,91], EntitySkeleton['Skeleton'/995, l='MpServer', x=-71,50, y=35,00, z=329,50], EntityZombie['Zombie'/2939, l='MpServer', x=-44,50, y=44,00, z=301,50], EntityZombie['Zombie'/2938, l='MpServer', x=-44,50, y=44,00, z=302,50], EntitySkeleton['Skeleton'/996, l='MpServer', x=-74,50, y=34,00, z=330,06], EntityZombie['Zombie'/2940, l='MpServer', x=-42,50, y=44,00, z=301,50], EntityClientPlayerMP['Zzyxzz'/913, l='MpServer', x=-77,50, y=78,62, z=252,50], EntitySquid['Squid'/967, l='MpServer', x=-140,25, y=57,75, z=194,63]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:418)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2560)
at net.minecraft.client.Minecraft.run(Minecraft.java:975)
at net.minecraft.client.main.Main.main(Main.java:112)
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:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Windows 8 (amd64) version 6.2
Java Version: 1.7.0_51, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 627026920 bytes (597 MB) / 837812224 bytes (799 MB) up to 1899495424 bytes (1811 MB)
JVM Flags: 0 total; 
AABB Pool Size: 9187 (514472 bytes; 0 MB) allocated, 2 (112 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.01-pre FML v7.2.129.1046 Minecraft Forge 10.12.0.1046 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->Available->Available->Available->Available->Available
FML{7.2.129.1046} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.0.1046.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available
Forge{10.12.0.1046} [Minecraft Forge] (forgeSrc-1.7.2-10.12.0.1046.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available
BetterFurnaceEnhancedMod{1.0} [betterFurnaceEnhancedMod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: GeForce GTX 760 (192-bit)/PCIe/SSE2 GL version 4.4.0, NVIDIA Corporation
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 2418 (135408 bytes; 0 MB) allocated, 18 (1008 bytes; 0 MB) used
Anisotropic Filtering: Off (1)

 

When i now shutdown minecraft and start it again. -> enter the world where the mod has not loaded -> still not loading (corrupted i guess)

When i now shutdown minecraft and start it again. -> Create new world -> mod works again!

 

 

Can please someone try that out. Would be good to know, if its only me.

*********************************

**  Always remember you are unique,  **

**  just like everyone else                   **     

**********************************

Was my post helpful? Say thanks and

press the thank you button, on my post!!

God, damn it!

Posted

Main class from my furnace. which i was using for this test.

 

package com.zzyxz.betterFurnaceEnhancedMod;


import com.zzyxz.betterFurnaceEnhanced.BetterFurnace;
import com.zzyxz.betterFurnaceEnhanced.BetterFurnaceGuiHandler;
import com.zzyxz.betterFurnaceEnhanced.TileEntityBetterFurnace;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;

@Mod(modid = BetterFurnaceMain.MODID, version = BetterFurnaceMain.VERSION)
public class BetterFurnaceMain
{
    public static final String MODID = "BetterFurnaceEnhancedMod";
    public static final String VERSION = "1.0";
    
    @Instance(MODID)
    public static BetterFurnaceMain instance;
    private BetterFurnaceGuiHandler guihandler;
    public static	Block betterFurnaceIdle;
    public static	Block betterFurnaceActive;
    
    public static final int guiIdBetterFurnace = 0; 
    
    
    
    @EventHandler
    public void preinit(FMLInitializationEvent event)
    {
    	FMLClientHandler.instance().setDefaultMissingAction(FMLMissingMappingsEvent.Action.IGNORE);

    	
    	betterFurnaceIdle = new BetterFurnace(false).setCreativeTab(CreativeTabs.tabMisc).setBlockName("betterFurnaceIdle").setHardness(3.5f).setBlockTextureName("Minecraft"+":"+"textures/items/");
    	betterFurnaceActive = new BetterFurnace(true).setBlockName("betterFurnaceActive").setHardness(3.5f).setLightLevel(0.9f);  
    	GameRegistry.registerBlock(betterFurnaceIdle, betterFurnaceIdle.getUnlocalizedName().substring(5));
    	GameRegistry.registerBlock(betterFurnaceActive, betterFurnaceActive.getUnlocalizedName().substring(5));
    	GameRegistry.registerTileEntity(TileEntityBetterFurnace.class, "BetterFurnaceTileEntityID"); 
    	guihandler = new BetterFurnaceGuiHandler();
    	NetworkRegistry.INSTANCE.registerGuiHandler(this, guihandler); 
    	
    	
    	//Shaped Recipe
    	GameRegistry.addRecipe(new ItemStack(betterFurnaceIdle,1), new Object[] {"###","# #","###",'#',new ItemStack(Blocks.cobblestone, 1)});

    	


        if (event.getSide() == Side.CLIENT)
        Minecraft.getMinecraft().refreshResources();
    	
    }
}

*********************************

**  Always remember you are unique,  **

**  just like everyone else                   **     

**********************************

Was my post helpful? Say thanks and

press the thank you button, on my post!!

God, damn it!

Posted

Thank you very much.... incredible..what  dumb mistakes i make... i can not see the wood for the trees.

*********************************

**  Always remember you are unique,  **

**  just like everyone else                   **     

**********************************

Was my post helpful? Say thanks and

press the thank you button, on my post!!

God, damn it!

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

    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
    • Okay, but does the modpack works with 1.12 or just with 1.12.2, because I need the Forge client specifically for Minecraft 1.12, not 1.12.2
    • 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() ); } }  
  • Topics

×
×
  • Create New...

Important Information

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