Jump to content

Recommended Posts

Posted

I am messing around with custom block rendering and such, I have gotten the block to render correctly in world. But the block in my Inventory is a flat square not a block with the wrong texture, not stone overlaid with for now glass.

 

Renderer Code

The things I tried with "renderInventoryBlock" didn't make any difference.

Setting "shouldRender3DInInventory" to true makes the item invisible

 

 

package ShadoTECH;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.init.Blocks;
import net.minecraft.world.IBlockAccess;


public class RendererOreOverlay implements ISimpleBlockRenderingHandler
{
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
    {

    }

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
        if(ClientProxy.renderPass == 0)
        {
        	renderer.renderStandardBlock(Blocks.stone, x, y, z);                                     
        }
        
        else                    
        {
            renderer.renderStandardBlock(sT_Blocks.Obsidian_Glass_Cross, x, y, z);
        }
        return true;
}

@Override
public boolean shouldRender3DInInventory(int modelId)
{
	return false;
}

@Override
public int getRenderId()
{
	return ClientProxy.oreRenderType;
}
}

 

 

Posted

Sorry for bumping the thread but still at a loss on how to fix this. :/

 

It renders nothing when you return true in shouldRender3DInInventory because you don't have anything in your method renderInventoryBlock

You need to return true, but also do your own render inside inventories with renderInventoryBlock

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Sorry for bumping the thread but still at a loss on how to fix this. :/

 

It renders nothing when you return true in shouldRender3DInInventory because you don't have anything in your method renderInventoryBlock

You need to return true, but also do your own render inside inventories with renderInventoryBlock

So just going out on a limb here and ask, is there a simple way to make it render like a vanilla block does in inventory or do I have to go learn about Tessellator and GL11?

Posted

You can reuse your code in renderWorldBlock, but instead of using renderStandardBlock, use renderBlockAsItem (with appropriate parameters, Block, metadata, colorMultiplier)

But please note, if the block which is rendered by that method has a custom render ID as well, you need to render it directly.

Here's an example, where the code needed (except line 25) is marked yellow:

https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/util/client/RenderBlockGlowOverlay.java#L24-L61

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

You can reuse your code in renderWorldBlock, but instead of using renderStandardBlock, use renderBlockAsItem (with appropriate parameters, Block, metadata, colorMultiplier)

But please note, if the block which is rendered by that method has a custom render ID as well, you need to render it directly.

Here's an example, where the code needed (except line 25) is marked yellow:

https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/util/client/RenderBlockGlowOverlay.java#L24-L61

Thanks! I actually understood that easier than I thought, took me a bit to figure out what did what.

Posted

You can reuse your code in renderWorldBlock, but instead of using renderStandardBlock, use renderBlockAsItem (with appropriate parameters, Block, metadata, colorMultiplier)

But please note, if the block which is rendered by that method has a custom render ID as well, you need to render it directly.

Here's an example, where the code needed (except line 25) is marked yellow:

https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/util/client/RenderBlockGlowOverlay.java#L24-L61

Thanks! I actually understood that easier than I thought, took me a bit to figure out what did what.

 

I am not sure why but I am now getting a crash it seems when my overlayed blocks are generated now, it all worked before I changed the blocks.

Spawning them in creative superflat they seem to be working, but default world type crash on world load, and disabling my generation code stopped it.

I am loading the Renderer code before all of the world stuff.

 

Crash report.

 

 

---- Minecraft Crash Report ----
// Uh... Did I do that?

Time: 5/7/14 9:13 AM
Description: Unexpected error

java.lang.IllegalArgumentException
at java.util.PriorityQueue.<init>(Unknown Source)
at net.minecraft.client.renderer.Tessellator.getVertexState(Tessellator.java:203)
at net.minecraft.client.renderer.WorldRenderer.postRenderBlocks(WorldRenderer.java:271)
at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:229)
at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1639)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1259)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1094)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1024)
at net.minecraft.client.Minecraft.run(Minecraft.java:912)
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 java.util.PriorityQueue.<init>(Unknown Source)
at net.minecraft.client.renderer.Tessellator.getVertexState(Tessellator.java:203)
at net.minecraft.client.renderer.WorldRenderer.postRenderBlocks(WorldRenderer.java:271)
at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:229)
at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1639)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1259)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Player979'/130, l='MpServer', x=572.70, y=64.62, z=52.61]]
Chunk stats: MultiplayerChunkCache: 205, 205
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: World: (564,64,55), Chunk: (at 4,4,7 in 35,3; contains blocks 560,0,48 to 575,255,63), Region: (1,0; contains chunks 32,0 to 63,31, blocks 512,0,0 to 1023,255,511)
Level time: 692 game time, 692 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: 247 total; [EntityBat['Bat'/513, l='MpServer', x=523.41, y=14.41, z=123.40], EntityBat['Bat'/514, l='MpServer', x=526.75, y=14.31, z=119.20], EntityBat['Bat'/517, l='MpServer', x=525.93, y=13.85, z=123.46], EntityFallingBlock['Falling Block'/1541, l='MpServer', x=476.50, y=29.12, z=4.50], EntityFallingBlock['Falling Block'/1542, l='MpServer', x=477.50, y=29.12, z=5.50], EntityFallingBlock['Falling Block'/1543, l='MpServer', x=478.50, y=29.12, z=4.50], EntityFallingBlock['Falling Block'/1545, l='MpServer', x=475.50, y=29.12, z=4.50], EntityFallingBlock['Falling Block'/1546, l='MpServer', x=476.50, y=29.12, z=5.50], EntityFallingBlock['Falling Block'/1548, l='MpServer', x=478.50, y=9.78, z=-3.50], EntityCreeper['Creeper'/1037, l='MpServer', x=537.50, y=16.69, z=88.32], EntityFallingBlock['Falling Block'/1549, l='MpServer', x=478.50, y=8.64, z=-2.50], EntityZombie['Zombie'/1038, l='MpServer', x=638.55, y=24.00, z=15.15], EntityFallingBlock['Falling Block'/1550, l='MpServer', x=477.50, y=9.78, z=-2.50], EntityCreeper['Creeper'/527, l='MpServer', x=593.50, y=17.00, z=60.50], EntityFallingBlock['Falling Block'/1551, l='MpServer', x=477.50, y=9.78, z=-1.50], EntityFallingBlock['Falling Block'/1552, l='MpServer', x=477.50, y=10.97, z=-3.50], EntityFallingBlock['Falling Block'/1553, l='MpServer', x=476.50, y=10.97, z=-2.50], EntityPig['Pig'/18, l='MpServer', x=497.50, y=68.00, z=-23.78], EntityFallingBlock['Falling Block'/1554, l='MpServer', x=476.50, y=10.97, z=-1.50], EntityPig['Pig'/19, l='MpServer', x=497.50, y=68.00, z=-19.47], EntityFallingBlock['Falling Block'/1555, l='MpServer', x=477.50, y=8.64, z=-0.50], EntityCreeper['Creeper'/532, l='MpServer', x=556.50, y=16.00, z=77.50], EntityPig['Pig'/20, l='MpServer', x=497.50, y=68.00, z=-20.81], EntityFallingBlock['Falling Block'/1556, l='MpServer', x=476.50, y=9.78, z=-0.50], EntityCreeper['Creeper'/533, l='MpServer', x=557.50, y=16.00, z=77.50], EntityPig['Pig'/21, l='MpServer', x=497.50, y=68.00, z=-22.19], EntityFallingBlock['Falling Block'/1557, l='MpServer', x=475.50, y=9.78, z=-0.50], EntityZombie['Zombie'/534, l='MpServer', x=550.50, y=16.00, z=76.50], EntitySheep['Sheep'/22, l='MpServer', x=508.76, y=64.00, z=-27.88], EntityFallingBlock['Falling Block'/1558, l='MpServer', x=475.50, y=9.78, z=0.50], EntityZombie['Zombie'/535, l='MpServer', x=551.50, y=16.00, z=76.50], EntitySheep['Sheep'/23, l='MpServer', x=506.98, y=64.00, z=-26.98], EntityFallingBlock['Falling Block'/1559, l='MpServer', x=475.50, y=10.97, z=-1.50], EntityFallingBlock['Falling Block'/1560, l='MpServer', x=476.50, y=8.64, z=0.50], EntityFallingBlock['Falling Block'/1561, l='MpServer', x=474.50, y=9.78, z=-0.50], EntityPig['Pig'/26, l='MpServer', x=520.50, y=67.00, z=11.78], EntityFallingBlock['Falling Block'/1562, l='MpServer', x=474.50, y=9.78, z=0.50], EntityPig['Pig'/27, l='MpServer', x=522.22, y=67.00, z=10.22], EntityFallingBlock['Falling Block'/1563, l='MpServer', x=474.50, y=8.67, z=1.50], EntityPig['Pig'/28, l='MpServer', x=520.50, y=67.00, z=10.19], EntityFallingBlock['Falling Block'/1564, l='MpServer', x=473.50, y=9.78, z=-0.50], EntityPig['Pig'/29, l='MpServer', x=523.81, y=67.00, z=11.81], EntityFallingBlock['Falling Block'/1565, l='MpServer', x=473.50, y=9.78, z=0.50], EntityPig['Pig'/30, l='MpServer', x=560.78, y=63.00, z=-5.50], EntityFallingBlock['Falling Block'/1566, l='MpServer', x=473.50, y=8.64, z=1.50], EntityPig['Pig'/31, l='MpServer', x=559.19, y=63.00, z=-5.50], EntityPig['Pig'/32, l='MpServer', x=552.39, y=63.00, z=-4.41], EntityPig['Pig'/33, l='MpServer', x=558.81, y=63.00, z=-3.50], EntitySheep['Sheep'/34, l='MpServer', x=552.22, y=64.00, z=41.50], EntitySheep['Sheep'/35, l='MpServer', x=554.50, y=64.00, z=39.91], EntitySheep['Sheep'/36, l='MpServer', x=553.50, y=64.00, z=41.81], EntitySheep['Sheep'/37, l='MpServer', x=555.81, y=64.00, z=41.81], EntityPig['Pig'/42, l='MpServer', x=583.50, y=63.00, z=-6.50], EntityPig['Pig'/43, l='MpServer', x=580.50, y=74.00, z=-6.50], EntityPig['Pig'/44, l='MpServer', x=578.50, y=73.00, z=-3.50], EntityPig['Pig'/45, l='MpServer', x=580.50, y=73.00, z=-1.50], EntityPig['Pig'/50, l='MpServer', x=594.50, y=64.00, z=44.50], EntityPig['Pig'/51, l='MpServer', x=594.50, y=64.00, z=46.50], EntityPig['Pig'/52, l='MpServer', x=598.50, y=64.00, z=48.50], EntityPig['Pig'/53, l='MpServer', x=599.50, y=64.00, z=46.50], EntityCreeper['Creeper'/572, l='MpServer', x=649.50, y=31.00, z=50.50], EntityItem['item.tile.torch'/61, l='MpServer', x=613.64, y=18.13, z=16.88], EntityCreeper['Creeper'/573, l='MpServer', x=651.50, y=31.00, z=52.50], EntityItem['item.tile.rail'/62, l='MpServer', x=602.44, y=18.13, z=49.80], EntitySkeleton['Skeleton'/574, l='MpServer', x=648.50, y=31.00, z=49.50], EntityItem['item.tile.rail'/63, l='MpServer', x=599.81, y=18.13, z=48.22], EntityItem['item.tile.rail'/64, l='MpServer', x=603.44, y=18.13, z=49.31], EntityPig['Pig'/65, l='MpServer', x=601.50, y=64.00, z=70.50], EntityPig['Pig'/66, l='MpServer', x=605.22, y=64.00, z=70.78], EntityBat['Bat'/578, l='MpServer', x=551.13, y=37.29, z=99.65], EntityPig['Pig'/67, l='MpServer', x=606.84, y=64.00, z=69.53], EntityPig['Pig'/68, l='MpServer', x=606.50, y=64.00, z=68.03], EntityItem['item.tile.torch'/69, l='MpServer', x=607.88, y=24.13, z=76.69], EntityMinecartChest['entity.MinecartChest.name'/70, l='MpServer', x=618.50, y=18.50, z=-15.50], EntityMinecartChest['entity.MinecartChest.name'/71, l='MpServer', x=620.50, y=23.50, z=-10.50], EntityMinecartChest['entity.MinecartChest.name'/72, l='MpServer', x=620.50, y=19.50, z=21.50], EntityBat['Bat'/584, l='MpServer', x=613.81, y=50.00, z=-11.14], EntityMinecartChest['entity.MinecartChest.name'/73, l='MpServer', x=637.50, y=19.50, z=17.50], EntitySheep['Sheep'/74, l='MpServer', x=636.78, y=66.00, z=27.53], EntitySheep['Sheep'/75, l='MpServer', x=632.50, y=65.00, z=28.50], EntityBat['Bat'/587, l='MpServer', x=620.58, y=53.37, z=-7.55], EntitySheep['Sheep'/76, l='MpServer', x=635.18, y=66.00, z=26.49], EntitySheep['Sheep'/77, l='MpServer', x=635.50, y=66.00, z=25.03], EntityPig['Pig'/78, l='MpServer', x=642.50, y=70.00, z=41.50], EntityPig['Pig'/79, l='MpServer', x=643.22, y=70.00, z=43.50], EntityPig['Pig'/80, l='MpServer', x=644.81, y=70.00, z=43.50], EntityPig['Pig'/81, l='MpServer', x=640.50, y=71.00, z=40.50], EntityEnderman['Enderman'/1625, l='MpServer', x=546.50, y=18.00, z=82.50], EntityZombie['Zombie'/1627, l='MpServer', x=552.50, y=18.00, z=84.50], EntitySkeleton['Skeleton'/1120, l='MpServer', x=641.50, y=35.00, z=61.50], EntityZombie['Zombie'/1123, l='MpServer', x=580.50, y=21.00, z=43.50], EntitySkeleton['Skeleton'/1638, l='MpServer', x=591.50, y=12.00, z=76.50], EntityFallingBlock['Falling Block'/1651, l='MpServer', x=476.50, y=47.40, z=87.50], EntityFallingBlock['Falling Block'/1652, l='MpServer', x=474.50, y=48.40, z=86.50], EntityFallingBlock['Falling Block'/1653, l='MpServer', x=474.50, y=48.40, z=87.50], EntityFallingBlock['Falling Block'/1654, l='MpServer', x=475.50, y=48.40, z=85.50], EntityFallingBlock['Falling Block'/1655, l='MpServer', x=475.50, y=48.40, z=86.50], EntityFallingBlock['Falling Block'/1656, l='MpServer', x=475.50, y=48.40, z=87.50], EntityFallingBlock['Falling Block'/1657, l='MpServer', x=475.50, y=48.40, z=88.50], EntityFallingBlock['Falling Block'/1658, l='MpServer', x=476.50, y=47.40, z=88.50], EntityFallingBlock['Falling Block'/1659, l='MpServer', x=476.50, y=48.40, z=85.50], EntityFallingBlock['Falling Block'/1660, l='MpServer', x=474.50, y=48.40, z=88.50], EntityFallingBlock['Falling Block'/1661, l='MpServer', x=476.50, y=13.40, z=112.50], EntityFallingBlock['Falling Block'/1662, l='MpServer', x=477.50, y=13.40, z=112.50], EntityFallingBlock['Falling Block'/1663, l='MpServer', x=475.50, y=13.40, z=112.50], EntityFallingBlock['Falling Block'/1664, l='MpServer', x=476.50, y=13.40, z=113.50], EntityFallingBlock['Falling Block'/1665, l='MpServer', x=474.50, y=13.40, z=112.50], EntityFallingBlock['Falling Block'/1666, l='MpServer', x=475.50, y=12.40, z=111.50], EntityFallingBlock['Falling Block'/1667, l='MpServer', x=475.50, y=13.40, z=113.50], EntityFallingBlock['Falling Block'/1668, l='MpServer', x=476.50, y=12.40, z=111.50], EntityFallingBlock['Falling Block'/1669, l='MpServer', x=473.50, y=13.40, z=112.50], EntityFallingBlock['Falling Block'/1670, l='MpServer', x=474.50, y=12.28, z=111.50], EntityFallingBlock['Falling Block'/1671, l='MpServer', x=474.50, y=13.40, z=113.50], EntityFallingBlock['Falling Block'/1672, l='MpServer', x=473.50, y=12.28, z=111.50], EntityFallingBlock['Falling Block'/1673, l='MpServer', x=472.50, y=12.28, z=111.50], EntityFallingBlock['Falling Block'/1674, l='MpServer', x=471.50, y=12.28, z=111.50], EntityBat['Bat'/147, l='MpServer', x=626.44, y=20.81, z=5.51], EntityBat['Bat'/151, l='MpServer', x=541.51, y=19.97, z=86.36], EntityZombie['Zombie'/664, l='MpServer', x=593.50, y=30.00, z=110.50], EntityBat['Bat'/158, l='MpServer', x=588.84, y=21.00, z=59.52], EntityZombie['Zombie'/1185, l='MpServer', x=517.50, y=14.00, z=128.50], EntityFallingBlock['Falling Block'/1697, l='MpServer', x=477.50, y=28.47, z=145.50], EntityZombie['Zombie'/1186, l='MpServer', x=521.50, y=14.00, z=128.50], EntityFallingBlock['Falling Block'/1698, l='MpServer', x=477.50, y=28.47, z=146.50], EntityZombie['Zombie'/1187, l='MpServer', x=518.34, y=14.00, z=129.34], EntityFallingBlock['Falling Block'/1701, l='MpServer', x=472.50, y=26.47, z=149.50], EntityFallingBlock['Falling Block'/1702, l='MpServer', x=472.50, y=45.47, z=140.50], EntitySkeleton['Skeleton'/679, l='MpServer', x=627.50, y=35.00, z=90.50], EntityFallingBlock['Falling Block'/1703, l='MpServer', x=472.50, y=45.47, z=141.50], EntitySpider['Spider'/680, l='MpServer', x=628.50, y=35.00, z=86.50], EntityFallingBlock['Falling Block'/1704, l='MpServer', x=473.50, y=45.47, z=140.50], EntityFallingBlock['Falling Block'/1705, l='MpServer', x=473.50, y=45.47, z=141.50], EntityFallingBlock['Falling Block'/1706, l='MpServer', x=473.50, y=45.47, z=142.50], EntityFallingBlock['Falling Block'/1707, l='MpServer', x=471.50, y=44.47, z=143.50], EntityFallingBlock['Falling Block'/1708, l='MpServer', x=471.50, y=44.47, z=144.50], EntityFallingBlock['Falling Block'/1709, l='MpServer', x=472.50, y=44.47, z=143.50], EntityFallingBlock['Falling Block'/1710, l='MpServer', x=472.50, y=44.47, z=144.50], EntitySquid['Squid'/175, l='MpServer', x=592.51, y=59.01, z=97.48], EntitySquid['Squid'/176, l='MpServer', x=592.20, y=60.42, z=96.34], EntityFallingBlock['Falling Block'/1712, l='MpServer', x=472.50, y=48.47, z=143.50], EntitySquid['Squid'/177, l='MpServer', x=591.45, y=60.33, z=92.92], EntityFallingBlock['Falling Block'/1713, l='MpServer', x=472.50, y=48.47, z=144.50], EntityFallingBlock['Falling Block'/1714, l='MpServer', x=473.50, y=44.47, z=144.50], EntitySquid['Squid'/179, l='MpServer', x=590.23, y=59.18, z=100.82], EntityFallingBlock['Falling Block'/1715, l='MpServer', x=471.50, y=48.47, z=144.50], EntitySquid['Squid'/180, l='MpServer', x=592.53, y=60.36, z=94.07], EntityFallingBlock['Falling Block'/1716, l='MpServer', x=471.50, y=44.47, z=145.50], EntitySquid['Squid'/181, l='MpServer', x=587.73, y=59.26, z=105.82], EntityCreeper['Creeper'/693, l='MpServer', x=534.50, y=18.00, z=89.50], EntitySquid['Squid'/182, l='MpServer', x=584.97, y=60.38, z=102.60], EntityFallingBlock['Falling Block'/1718, l='MpServer', x=471.50, y=48.47, z=145.50], EntitySquid['Squid'/183, l='MpServer', x=587.87, y=60.45, z=99.44], EntitySquid['Squid'/184, l='MpServer', x=592.77, y=58.83, z=103.25], EntityFallingBlock['Falling Block'/1721, l='MpServer', x=480.50, y=34.02, z=162.50], EntityFallingBlock['Falling Block'/1722, l='MpServer', x=481.50, y=33.02, z=161.50], EntityFallingBlock['Falling Block'/1723, l='MpServer', x=481.50, y=34.02, z=162.50], EntityFallingBlock['Falling Block'/1724, l='MpServer', x=480.50, y=36.43, z=163.50], EntityFallingBlock['Falling Block'/1725, l='MpServer', x=481.50, y=36.43, z=163.50], EntityFallingBlock['Falling Block'/1726, l='MpServer', x=479.50, y=35.42, z=163.50], EntityFallingBlock['Falling Block'/1727, l='MpServer', x=479.50, y=35.42, z=164.50], EntityZombie['Zombie'/193, l='MpServer', x=520.50, y=15.00, z=118.50], EntityZombie['Zombie'/194, l='MpServer', x=521.50, y=15.00, z=116.50], EntityZombie['Zombie'/196, l='MpServer', x=564.50, y=12.00, z=98.50], EntityCreeper['Creeper'/728, l='MpServer', x=638.50, y=19.00, z=57.50], EntityCreeper['Creeper'/730, l='MpServer', x=639.50, y=19.00, z=55.50], EntityCreeper['Creeper'/732, l='MpServer', x=595.50, y=32.00, z=129.50], EntityCreeper['Creeper'/733, l='MpServer', x=594.50, y=32.00, z=131.50], EntitySkeleton['Skeleton'/236, l='MpServer', x=651.50, y=16.00, z=-3.50], EntitySkeleton['Skeleton'/237, l='MpServer', x=652.50, y=16.00, z=-1.50], EntitySkeleton['Skeleton'/238, l='MpServer', x=650.50, y=16.00, z=-4.50], EntitySpider['Spider'/240, l='MpServer', x=549.50, y=19.00, z=82.50], EntityEnderman['Enderman'/754, l='MpServer', x=611.50, y=21.00, z=-23.50], EntityEnderman['Enderman'/755, l='MpServer', x=610.50, y=21.00, z=-22.50], EntityCreeper['Creeper'/756, l='MpServer', x=611.50, y=21.00, z=-22.50], EntityCreeper['Creeper'/757, l='MpServer', x=610.50, y=21.00, z=-17.50], EntityBat['Bat'/247, l='MpServer', x=592.33, y=30.00, z=114.72], EntityBat['Bat'/248, l='MpServer', x=608.49, y=41.89, z=-3.65], EntityBat['Bat'/249, l='MpServer', x=600.98, y=40.02, z=-6.22], EntityBat['Bat'/250, l='MpServer', x=613.45, y=41.00, z=-3.47], EntityClientPlayerMP['Player979'/130, l='MpServer', x=572.70, y=64.62, z=52.61], EntityZombie['Zombie'/289, l='MpServer', x=538.50, y=28.00, z=-11.50], EntityZombie['Zombie'/290, l='MpServer', x=537.50, y=28.00, z=-9.50], EntitySkeleton['Skeleton'/291, l='MpServer', x=645.50, y=34.00, z=58.50], EntityCreeper['Creeper'/1327, l='MpServer', x=640.50, y=34.00, z=28.50], EntityCreeper['Creeper'/1339, l='MpServer', x=602.50, y=24.00, z=85.50], EntityFallingBlock['Falling Block'/1863, l='MpServer', x=494.50, y=9.88, z=-43.50], EntityFallingBlock['Falling Block'/1864, l='MpServer', x=493.50, y=8.88, z=-44.50], EntityFallingBlock['Falling Block'/1865, l='MpServer', x=493.50, y=9.88, z=-43.50], EntityFallingBlock['Falling Block'/1866, l='MpServer', x=491.50, y=9.88, z=-44.50], EntityFallingBlock['Falling Block'/1867, l='MpServer', x=492.50, y=9.88, z=-44.50], EntityFallingBlock['Falling Block'/1868, l='MpServer', x=490.50, y=8.88, z=-45.50], EntityFallingBlock['Falling Block'/1869, l='MpServer', x=490.50, y=9.88, z=-44.50], EntityFallingBlock['Falling Block'/1870, l='MpServer', x=489.50, y=8.88, z=-45.50], EntityFallingBlock['Falling Block'/1882, l='MpServer', x=497.50, y=43.17, z=18.50], EntityFallingBlock['Falling Block'/1883, l='MpServer', x=494.50, y=33.17, z=6.50], EntityFallingBlock['Falling Block'/1884, l='MpServer', x=495.50, y=32.17, z=6.50], EntityFallingBlock['Falling Block'/1885, l='MpServer', x=495.50, y=33.17, z=7.50], EntityFallingBlock['Falling Block'/1886, l='MpServer', x=493.50, y=33.17, z=6.50], EntityFallingBlock['Falling Block'/1888, l='MpServer', x=491.50, y=33.17, z=8.50], EntityFallingBlock['Falling Block'/1889, l='MpServer', x=486.50, y=34.17, z=3.50], EntityZombie['Zombie'/363, l='MpServer', x=546.50, y=23.00, z=-19.50], EntityZombie['Zombie'/364, l='MpServer', x=546.19, y=24.00, z=-18.50], EntityFallingBlock['Falling Block'/1909, l='MpServer', x=491.50, y=48.73, z=141.50], EntityFallingBlock['Falling Block'/1910, l='MpServer', x=492.50, y=47.73, z=140.50], EntityFallingBlock['Falling Block'/1911, l='MpServer', x=492.50, y=47.73, z=141.50], EntityFallingBlock['Falling Block'/1912, l='MpServer', x=493.50, y=47.73, z=141.50], EntityFallingBlock['Falling Block'/1913, l='MpServer', x=491.50, y=48.73, z=142.50], EntityFallingBlock['Falling Block'/1914, l='MpServer', x=490.50, y=49.73, z=141.50], EntityFallingBlock['Falling Block'/1915, l='MpServer', x=490.50, y=49.73, z=142.50], EntityFallingBlock['Falling Block'/1916, l='MpServer', x=489.50, y=48.73, z=142.50], EntityFallingBlock['Falling Block'/1917, l='MpServer', x=490.50, y=48.73, z=143.50], EntityFallingBlock['Falling Block'/1918, l='MpServer', x=492.50, y=47.73, z=142.50], EntityFallingBlock['Falling Block'/1919, l='MpServer', x=496.50, y=29.73, z=149.50], EntityFallingBlock['Falling Block'/1920, l='MpServer', x=497.50, y=28.73, z=150.50], EntityFallingBlock['Falling Block'/1921, l='MpServer', x=497.50, y=29.73, z=151.50], EntityFallingBlock['Falling Block'/1922, l='MpServer', x=498.50, y=28.73, z=152.50], EntityFallingBlock['Falling Block'/1923, l='MpServer', x=497.50, y=29.73, z=152.50], EntityFallingBlock['Falling Block'/1924, l='MpServer', x=497.50, y=29.73, z=153.50], EntityFallingBlock['Falling Block'/1925, l='MpServer', x=498.50, y=29.73, z=153.50], EntityFallingBlock['Falling Block'/1926, l='MpServer', x=495.50, y=35.90, z=172.50], EntityFallingBlock['Falling Block'/1927, l='MpServer', x=495.50, y=34.90, z=170.50], EntityFallingBlock['Falling Block'/1928, l='MpServer', x=495.50, y=35.90, z=171.50], EntityFallingBlock['Falling Block'/1929, l='MpServer', x=496.50, y=35.90, z=171.50], EntitySpider['Spider'/1457, l='MpServer', x=506.19, y=19.00, z=54.17], EntitySkeleton['Skeleton'/1458, l='MpServer', x=508.50, y=19.00, z=53.50], EntityZombie['Zombie'/1459, l='MpServer', x=559.50, y=15.00, z=76.50], EntityBat['Bat'/436, l='MpServer', x=565.59, y=18.58, z=117.46], EntityZombie['Zombie'/1460, l='MpServer', x=563.48, y=15.00, z=75.52], EntityBat['Bat'/437, l='MpServer', x=567.46, y=15.74, z=106.20], EntityFallingBlock['Falling Block'/1981, l='MpServer', x=504.50, y=19.42, z=22.50], EntityFallingBlock['Falling Block'/1982, l='MpServer', x=503.50, y=20.42, z=22.50], EntityFallingBlock['Falling Block'/1983, l='MpServer', x=504.50, y=20.42, z=23.50], EntityFallingBlock['Falling Block'/1984, l='MpServer', x=504.50, y=20.42, z=24.50], EntityFallingBlock['Falling Block'/1985, l='MpServer', x=518.50, y=20.42, z=106.50], EntityFallingBlock['Falling Block'/1986, l='MpServer', x=517.50, y=20.42, z=104.50], EntityFallingBlock['Falling Block'/1987, l='MpServer', x=515.50, y=20.42, z=103.50], EntityFallingBlock['Falling Block'/1988, l='MpServer', x=516.50, y=21.42, z=103.50], EntitySpider['Spider'/1480, l='MpServer', x=605.50, y=16.00, z=63.50], EntityZombie['Zombie'/461, l='MpServer', x=572.30, y=12.00, z=50.32], EntityZombie['Zombie'/462, l='MpServer', x=571.30, y=12.00, z=50.74], EntityCreeper['Creeper'/981, l='MpServer', x=583.50, y=18.00, z=48.50], EntityCreeper['Creeper'/982, l='MpServer', x=582.50, y=18.00, z=49.50], EntityCreeper['Creeper'/1513, l='MpServer', x=583.66, y=21.00, z=110.89], EntitySkeleton['Skeleton'/491, l='MpServer', x=536.50, y=50.00, z=117.50], EntityFallingBlock['Falling Block'/1518, l='MpServer', x=471.50, y=28.13, z=-45.50], EntityFallingBlock['Falling Block'/1519, l='MpServer', x=471.50, y=28.13, z=-44.50], EntityFallingBlock['Falling Block'/1520, l='MpServer', x=470.50, y=28.13, z=-45.50]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:412)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2523)
at net.minecraft.client.Minecraft.run(Minecraft.java:941)
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.8.0_05, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 710254520 bytes (677 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 19491 (1091496 bytes; 1 MB) allocated, 2130 (119280 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.03 FML v7.2.165.1065 Minecraft Forge 10.12.1.1065 4 mods loaded, 4 mods active
mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.2.165.1065} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.1.1065.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.12.1.1065} [Minecraft Forge] (forgeSrc-1.7.2-10.12.1.1065.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
st{1.0.0} [shadoTECH] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: GeForce GTX 760/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: 5296 (296576 bytes; 0 MB) allocated, 890 (49840 bytes; 0 MB) used
Anisotropic Filtering: Off (1)

 

 

Posted

Can you give us the new code you're using?

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

In your render file, you do

        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, Blocks.stone.getBlockTextureFromSide(0));
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 0));

 

Do not call the method twice at the same time, basically you setup the tessellator, set the normal, add the vertices (that's what renderFaceYNeg and the like do) and then draw.

If you add too many vertices (like you do by calling the method one after another) with the currently selected drawing method it throws this exception.

Basically, what you have to do is a construct like this:

        tess.startDrawingQuads();
        tess.setNormal(0.0F, -1.0F, 0.0F);
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, Blocks.stone.getBlockTextureFromSide(0));
        tess.draw();
        tess.startDrawingQuads();
        // no need to set the normal again if you call the same render face method
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 0));
        tess.draw();

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

In your render file, you do

        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, Blocks.stone.getBlockTextureFromSide(0));
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 0));

 

Do not call the method twice at the same time, basically you setup the tessellator, set the normal, add the vertices (that's what renderFaceYNeg and the like do) and then draw.

If you add too many vertices (like you do by calling the method one after another) with the currently selected drawing method it throws this exception.

Basically, what you have to do is a construct like this:

        tess.startDrawingQuads();
        tess.setNormal(0.0F, -1.0F, 0.0F);
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, Blocks.stone.getBlockTextureFromSide(0));
        tess.draw();
        tess.startDrawingQuads();
        // no need to set the normal again if you call the same render face method
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 0));
        tess.draw();

 

 

So I managed to fix the crash by removing "renderer.renderStandardBlock" and doing all the faces separately.

Now the only last issue is its dark in my hand, and this its real wonky in world.

 

https://dl.dropboxusercontent.com/u/21990361/16d6c8294246cdc5273d0e647d6045f4.gif

https://dl.dropboxusercontent.com/u/21990361/ed7c1ff2defea1f3018a8f1e6419dd94.gif

 

I can fix this by putting "Tessellator.instance.setBrightness(255);" but then that makes the ore stand out in darkness.

Posted

In your renderInventoryBlock, use the tess.setBrightness(240) before rendering

In your renderWorldBlock use tess.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)) before drawing.

For that light-shining-through issue, use block.setLightOpacity(255) when you construct your block.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

In your renderInventoryBlock, use the tess.setBrightness(240) before rendering

In your renderWorldBlock use tess.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)) before drawing.

For that light-shining-through issue, use block.setLightOpacity(255) when you construct your block.

Thanks for that, didn't even notice the LightOpacity in the gif lol. But it turns out setting that made the blocks ignore light and stay dark. So thats not really a issue leaving them were light can pass. Its no were near perfect brightness slightly off still in direct sunlight but I can live with that.

 

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.