Jump to content

Recommended Posts

Posted

good days

 

lets see i wanna update this item to 1.9

 

this suspension de redstone when you hold rigth click it change the texture from this

(estatica)

suspensionderedstone7.png

 

to this

(shaking)

shake.gif

 

and if you hold it shaken for more than 10 sec becomes this

(shaked)

activada.gif

 

but now everithing has change and

ModelResourceLocation getModel(ItemStack, playerIn, useRemaining)

dont works any more

 

i been scavenging in the ItemBow class and made some experimets create a property "shake"  and made a json but i dont understand how to change the value of shake to "1", to change the dispayed item image from the firs (statica) to the second (shaking),  the thirth (shaked) is a diferent item soo here dont gonna do nothing whith it

 

####

soo how do i change the item property value "shake" from "0" to "1"  to change the display texture of the  item ???

 

####

i wass looking here and there and looks like the item properties can only be of (float) type but in the ItemBow.class they declare a property "pull" and other "pulling" the two are aplied as float values but later in bow.json they use it "pulling" like an int and "pull" as float 

           "predicate": {
                "pulling": 1,
                "pull": 0.65
            },

 

wtf ?? and it works!

 

 

####

mi code

https://gist.github.com/anonymous/62db605629488d69bace

 

mi json

https://gist.github.com/anonymous/59aeadfaf19faef41295

 

and the other json

https://gist.github.com/anonymous/a8a6af4ce7ee25a26648

 

 

Thanks for reading

 

 

 

 

 

 

 

 

 

 

 

 

Posted

looks like 

playerIn.setActiveHand(hand);

has replaced

playerIn.setItemInUse(suspencion, this.getMaxItemUseDuration(suspencion));

 

now mi item shake when hold right click and works even if the bottle is in the left hand

but neithers know whats or where is made the change of new ResourceLocation("shake")  to one

 

i need to know this coz later i have to animate mi guns and i do that cicling textures

 

 

i been trying

float shake = (float)  (this.getPropertyGetter(new ResourceLocation("shake")).floatValue)  ;

 

whiout succes looks  like the ItemClass has' no methods to retrive this values, but the json get the changes a change the dispaly model for thi item 

 

 

 

Posted

help mi get this straight

 

what is seting the value of the the property "shake"

is te code in the constructor that define the the property "shake"

and this methosd apply(ItemStack stack, World worldIn, EntityLivingBase entityIn)

its like an onUpdate() but only works client side

 

@SideOnly(Side.CLIENT)
            public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn)
            {
            	
            	
            	if ( (entityIn != null) && (entityIn.isHandActive()) && (entityIn.getActiveItemStack() == stack ) )
            	{
            	
            		//System.out.println(" apply() Mundo="+worldIn.isRemote);
            		
            	return 1.0F;	
            	}else
            	{	
            	return 0.0F;
            	}
                //return   entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F ;
                     
                
            }

 

i try to add a system.out to prove this theory but causes the game to crash whith an error  pointing to the line whith the system.out so i coment it.

 

if this theory is true later i gonna get a hard time sending the values to client world to set the animations and the default texture coz depends on the type of magazine the gun have

 

 

[20:38:41] [Client thread/FATAL]: Reported exception thrown!
net.minecraft.util.ReportedException: Rendering item
at net.minecraft.client.renderer.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:389) ~[RenderItem.class:?]
at net.minecraft.client.gui.GuiIngame.renderHotbarItem(GuiIngame.java:1166) ~[GuiIngame.class:?]
at net.minecraft.client.gui.GuiIngame.renderHotbar(GuiIngame.java:522) ~[GuiIngame.class:?]
at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:308) ~[GuiIngameForge.class:?]
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:121) ~[GuiIngameForge.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1125) ~[EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1135) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:401) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_65]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_65]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.NullPointerException
at mercenarymod.items.materiales.materialesSuspensionderedstone$1.apply(materialesSuspensionderedstone.java:57) ~[materialesSuspensionderedstone$1.class:?]
at net.minecraft.client.renderer.block.model.ItemOverride.matchesItemStack(ItemOverride.java:47) ~[itemOverride.class:?]
at net.minecraft.client.renderer.block.model.ItemOverrideList.applyOverride(ItemOverrideList.java:37) ~[itemOverrideList.class:?]
at net.minecraft.client.renderer.block.model.ItemOverrideList.handleItemState(ItemOverrideList.java:52) ~[itemOverrideList.class:?]
at net.minecraft.client.renderer.RenderItem.getItemModelWithOverrides(RenderItem.java:253) ~[RenderItem.class:?]
at net.minecraft.client.renderer.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:355) ~[RenderItem.class:?]
... 20 more
[20:38:41] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:645]: ---- Minecraft Crash Report ----
// Shall we play a game?

Time: 20/03/16 08:38 PM
Description: Rendering item

java.lang.NullPointerException: Rendering item
at mercenarymod.items.materiales.materialesSuspensionderedstone$1.apply(materialesSuspensionderedstone.java:57)
at net.minecraft.client.renderer.block.model.ItemOverride.matchesItemStack(ItemOverride.java:47)
at net.minecraft.client.renderer.block.model.ItemOverrideList.applyOverride(ItemOverrideList.java:37)
at net.minecraft.client.renderer.block.model.ItemOverrideList.handleItemState(ItemOverrideList.java:52)
at net.minecraft.client.renderer.RenderItem.getItemModelWithOverrides(RenderItem.java:253)
at net.minecraft.client.renderer.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:355)
at net.minecraft.client.gui.GuiIngame.renderHotbarItem(GuiIngame.java:1166)
at net.minecraft.client.gui.GuiIngame.renderHotbar(GuiIngame.java:522)
at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:308)
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:121)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1125)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1135)
at net.minecraft.client.Minecraft.run(Minecraft.java:401)
at net.minecraft.client.main.Main.main(Main.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)


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

-- Head --
Stacktrace:
at mercenarymod.items.materiales.materialesSuspensionderedstone$1.apply(materialesSuspensionderedstone.java:57)
at net.minecraft.client.renderer.block.model.ItemOverride.matchesItemStack(ItemOverride.java:47)
at net.minecraft.client.renderer.block.model.ItemOverrideList.applyOverride(ItemOverrideList.java:37)
at net.minecraft.client.renderer.block.model.ItemOverrideList.handleItemState(ItemOverrideList.java:52)
at net.minecraft.client.renderer.RenderItem.getItemModelWithOverrides(RenderItem.java:253)

-- Item being rendered --
Details:
Item Type: mercenarymod.items.materiales.materialesSuspensionderedstone@1fae388c
Item Aux: 0
Item NBT: null
Item Foil: false
Stacktrace:
at net.minecraft.client.renderer.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:355)
at net.minecraft.client.gui.GuiIngame.renderHotbarItem(GuiIngame.java:1166)
at net.minecraft.client.gui.GuiIngame.renderHotbar(GuiIngame.java:522)
at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:308)
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:121)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityPlayerSP['Player903'/193, l='MpServer', x=93,57, y=70,00, z=-329,43]]
Chunk stats: MultiplayerChunkCache: 251, 251
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: World: (-116,64,52), Chunk: (at 12,4,4 in -8,3; contains blocks -128,0,48 to -113,255,63), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Level time: 156251 game time, 8321 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: 77 total; [EntitySpider['Araña'/384, l='MpServer', x=136,50, y=25,00, z=-324,50], EntitySpider['Araña'/385, l='MpServer', x=137,50, y=25,00, z=-326,50], EntitySkeleton['Esqueleto'/257, l='MpServer', x=15,50, y=51,00, z=-396,50], EntityBat['Murciélago'/386, l='MpServer', x=141,53, y=26,52, z=-308,03], EntityChicken['Gallina'/387, l='MpServer', x=141,85, y=75,00, z=-316,56], EntityBat['Murciélago'/388, l='MpServer', x=141,79, y=61,18, z=-267,31], EntityBat['Murciélago'/389, l='MpServer', x=135,44, y=50,10, z=-256,74], EntityBat['Murciélago'/392, l='MpServer', x=135,86, y=55,07, z=-251,33], EntityItem['item.item.seeds'/395, l='MpServer', x=157,20, y=63,00, z=-390,75], EntityZombie['Zombi'/396, l='MpServer', x=159,50, y=27,00, z=-348,50], EntityZombie['Zombi'/397, l='MpServer', x=158,50, y=27,00, z=-349,50], EntityZombie['Zombi'/398, l='MpServer', x=159,50, y=27,00, z=-349,50], EntityChicken['Gallina'/270, l='MpServer', x=13,81, y=70,00, z=-253,85], EntityChicken['Gallina'/399, l='MpServer', x=150,55, y=72,00, z=-323,86], EntityCreeper['Creeper'/400, l='MpServer', x=148,50, y=24,00, z=-307,50], EntityChicken['Gallina'/401, l='MpServer', x=149,50, y=72,00, z=-318,50], EntityChicken['Gallina'/402, l='MpServer', x=153,54, y=72,00, z=-318,39], EntityCreeper['Creeper'/403, l='MpServer', x=145,50, y=26,00, z=-264,50], EntityZombie['Zombi'/281, l='MpServer', x=16,50, y=51,00, z=-397,50], EntitySheep['Oveja'/282, l='MpServer', x=22,39, y=70,00, z=-369,71], EntitySheep['Oveja'/283, l='MpServer', x=29,36, y=71,00, z=-370,01], EntitySkeleton['Esqueleto'/412, l='MpServer', x=161,50, y=18,00, z=-303,50], EntitySheep['Oveja'/284, l='MpServer', x=22,73, y=70,00, z=-368,47], EntitySheep['Oveja'/285, l='MpServer', x=28,99, y=71,00, z=-372,65], EntitySkeleton['Esqueleto'/286, l='MpServer', x=30,50, y=40,00, z=-351,50], EntityHorse['Caballo'/414, l='MpServer', x=165,70, y=70,00, z=-288,37], EntityHorse['Caballo'/418, l='MpServer', x=166,11, y=69,00, z=-285,98], EntityItem['item.item.seeds'/291, l='MpServer', x=31,29, y=62,00, z=-317,29], EntitySkeleton['Esqueleto'/419, l='MpServer', x=167,50, y=22,00, z=-268,50], EntityChicken['Gallina'/292, l='MpServer', x=30,57, y=67,00, z=-297,60], EntityChicken['Gallina'/293, l='MpServer', x=28,55, y=68,00, z=-287,79], EntityChicken['Gallina'/294, l='MpServer', x=22,46, y=70,00, z=-251,54], EntityChicken['Gallina'/295, l='MpServer', x=25,14, y=69,00, z=-252,48], EntityChicken['Gallina'/297, l='MpServer', x=23,39, y=68,00, z=-254,94], EntityZombie['Zombi'/301, l='MpServer', x=46,80, y=50,00, z=-369,52], EntityItem['item.item.seeds'/302, l='MpServer', x=39,78, y=63,00, z=-350,46], EntityChicken['Gallina'/303, l='MpServer', x=38,84, y=68,00, z=-304,29], EntityChicken['Gallina'/304, l='MpServer', x=37,87, y=66,00, z=-314,41], EntityChicken['Gallina'/305, l='MpServer', x=47,29, y=66,65, z=-296,05], EntityChicken['Gallina'/306, l='MpServer', x=47,18, y=68,00, z=-302,45], EntityChicken['Gallina'/307, l='MpServer', x=39,50, y=68,00, z=-297,21], EntityItem['item.item.seeds'/308, l='MpServer', x=45,28, y=65,00, z=-294,48], EntityChicken['Gallina'/309, l='MpServer', x=41,63, y=68,00, z=-290,19], EntityItem['item.item.seeds'/316, l='MpServer', x=48,70, y=62,00, z=-359,26], EntityChicken['Gallina'/317, l='MpServer', x=49,89, y=63,00, z=-360,51], EntityItem['item.tile.flower1.dandelion'/318, l='MpServer', x=48,59, y=62,00, z=-359,58], EntityChicken['Gallina'/319, l='MpServer', x=59,87, y=69,00, z=-323,86], EntityChicken['Gallina'/320, l='MpServer', x=61,85, y=69,00, z=-313,63], EntityChicken['Gallina'/321, l='MpServer', x=50,07, y=68,00, z=-288,45], EntityChicken['Gallina'/322, l='MpServer', x=60,16, y=68,00, z=-294,39], EntityChicken['Gallina'/323, l='MpServer', x=58,85, y=68,00, z=-286,48], EntityChicken['Gallina'/330, l='MpServer', x=71,10, y=68,00, z=-304,68], EntityChicken['Gallina'/331, l='MpServer', x=65,18, y=67,00, z=-288,59], EntityZombie['Zombi'/332, l='MpServer', x=74,08, y=19,00, z=-261,92], EntityZombie['Zombi'/333, l='MpServer', x=74,65, y=19,00, z=-261,35], EntitySkeleton['Esqueleto'/334, l='MpServer', x=70,50, y=49,00, z=-264,50], EntityZombie['Zombi'/341, l='MpServer', x=85,45, y=16,00, z=-317,75], EntityChicken['Gallina'/342, l='MpServer', x=83,77, y=69,00, z=-312,84], EntityPlayerSP['Player903'/193, l='MpServer', x=93,57, y=70,00, z=-329,43], EntityZombie['Zombi'/344, l='MpServer', x=87,56, y=23,00, z=-263,75], EntityItem['item.item.seeds'/352, l='MpServer', x=103,44, y=62,00, z=-391,98], EntityCreeper['Creeper'/353, l='MpServer', x=101,50, y=22,00, z=-263,50], EntityBat['Murciélago'/354, l='MpServer', x=108,76, y=45,96, z=-257,34], EntityChicken['Gallina'/366, l='MpServer', x=115,51, y=70,00, z=-364,16], EntityChicken['Gallina'/367, l='MpServer', x=114,90, y=72,00, z=-353,74], EntityChicken['Gallina'/368, l='MpServer', x=113,36, y=71,00, z=-330,84], EntitySkeleton['Esqueleto'/369, l='MpServer', x=112,50, y=25,00, z=-303,50], EntityBat['Murciélago'/370, l='MpServer', x=114,62, y=42,12, z=-264,02], EntitySkeleton['Esqueleto'/375, l='MpServer', x=130,50, y=33,00, z=-398,50], EntityCreeper['Creeper'/376, l='MpServer', x=131,50, y=60,00, z=-394,50], EntityItem['item.item.seeds'/377, l='MpServer', x=134,13, y=65,00, z=-377,92], EntityItem['item.item.seeds'/378, l='MpServer', x=136,93, y=66,00, z=-380,72], EntityChicken['Gallina'/379, l='MpServer', x=135,51, y=71,00, z=-352,84], EntityChicken['Gallina'/380, l='MpServer', x=130,82, y=70,00, z=-365,16], EntityChicken['Gallina'/381, l='MpServer', x=130,77, y=69,82, z=-357,49], EntityChicken['Gallina'/382, l='MpServer', x=132,44, y=71,00, z=-349,85], EntityChicken['Gallina'/383, l='MpServer', x=129,07, y=71,00, z=-350,87]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:445)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2766)
at net.minecraft.client.Minecraft.run(Minecraft.java:422)
at net.minecraft.client.main.Main.main(Main.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)

-- System Details --
Details:
Minecraft Version: 1.9
Operating System: Linux (amd64) version 3.16.0-4-amd64
Java Version: 1.8.0_65, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 777228792 bytes (741 MB) / 1056309248 bytes (1007 MB) up to 2130051072 bytes (2031 MB)
JVM Flags: 4 total; -Xincgc -Xmx1024M -Xms1024M -Xmx2g
IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
FML: MCP 9.23 Powered by Forge 12.16.0.1767 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJAAAA	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
UCHIJAAAA	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.9-12.16.0.1767-1.9.jar) 
UCHIJAAAA	Forge{12.16.0.1767} [Minecraft Forge] (forgeSrc-1.9-12.16.0.1767-1.9.jar) 
UCHIJAAAA	modmercenario{1.8.9} [modmercenario] (bin) 
Loaded coremods (and transformers): 
GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.4.0 NVIDIA 340.93' Renderer: 'GeForce GT 520/PCIe/SSE2'
Launched Version: 1.9
LWJGL: 2.9.4
OpenGL: GeForce GT 520/PCIe/SSE2 GL version 4.4.0 NVIDIA 340.93, NVIDIA Corporation
GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

Using VBOs: No
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: 
Current Language: Español (España)
Profiler Position: N/A (disabled)
CPU: 2x Intel(R) Celeron(R) CPU G1610 @ 2.60GHz
[20:38:41] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:645]: #@!@# Game crashed! Crash report saved to: #@!@# /home/usuario/Modding/forge-1.9-1767-modmercenario/run/./crash-reports/crash-2016-03-20_20.38.41-client.txt
AL lib: (EE) alc_cleanup: 1 device not closed

 

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 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.