Jump to content

Recommended Posts

Posted

So I want to use tile entity data to control what texture the related block uses, a bit like how IndustrialCraft fits so many types of blocks into a single ID, but the problem is that the client stubbornly refuses to store any tile entity data.  How can I make the server send tile entity data?    I've tried using tile entity description packets but I can't seem to make the client process them.

 

EDIT: So I've figured out how to sync server and client data, but on world load/unload the client's tile entity resets.  Is there any way to automatically send a tile entity description packet when the tile entity's chunk is loaded?

Posted

So I want to use tile entity data to control what texture the related block uses, a bit like how IndustrialCraft fits so many types of blocks into a single ID, but the problem is that the client stubbornly refuses to store any tile entity data.  How can I make the server send tile entity data?    I've tried using tile entity description packets but I can't seem to make the client process them.

If it renders as a normal block, you can't use TE data.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted

If it renders as a normal block, you can't use TE data.

 

Isn't there a method (getBlockTexture) that takes IBlockAccess as a parameter and returns an icon to display?  I was under the impression that the method could be used to grab a block's TE and use data from that to choose a texture to display on a certain side.

Posted

Server and Client Tile Entities are synchronized via the Container class.

check out detectAndSaveChanges(), updateProgressBar(), addCraftingToCrafters() methods in the ContainerFurnace class and make you Tile Entity update itself the same way. Otherwise your client and server Tile entities will desync after you log out from the world or unload the chunk it is in.

Posted

Isn't there a method (getBlockTexture) that takes IBlockAccess as a parameter and returns an icon to display?  I was under the impression that the method could be used to grab a block's TE and use data from that to choose a texture to display on a certain side.

That is indeed true. Just make sure you sync your TE fields with Packets, the client version is usually dumb and holds no data.

>.>

Thanks for solving my problem. I thought that method had been removed as of 1.5.2.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted

Server and Client Tile Entities are synchronized via the Container class.

check out detectAndSaveChanges(), updateProgressBar(), addCraftingToCrafters() methods in the ContainerFurnace class and make you Tile Entity update itself the same way. Otherwise your client and server Tile entities will desync after you log out from the world or unload the chunk it is in.

 

Aren't containers designed to be used with GUIs?  I'm trying to use TE data to control what textures a block should be rendered with, similar to how signs use TE data to control what text to display.

 

I've tried using getTileEntityDescriptionPacket(), but I can't make the game process built-in (or custom!) TE description packets.  I'm working on using Forge's packet handling structure, but although I've managed to send xyz coordinates from server to client I have no idea how to send which world the coordinates originate from.

 

(Strangely, neither Packet132TileEntityData nor Packet130UpdateSign seem to have a "world" field, yet both obviously allow minecraft to identify where the described TE is located. . . must look into that.)

 

Posted

You are right about the getDescriptionPacket. What you need to "receive" it on the client side is the onDataPacket method in the tile entity. It will be called when the packet from getDescriptionPacket arrives on the client.

Thanks for that, onDataPacket did the trick. 

(I can't help but wonder why most vanilla TE classes don't override it. . . ah well, the packet must be handled elsewhere in the code)

Posted

So. . . new problem: I've figured out how to sync server and client data, but on world load/unload the client's tile entity resets.  Is there any way to automatically send a tile entity description packet when the tile entity's chunk is loaded?

Posted

It is automatically send on a chunk load (and also on a chunk "refresh"). Are you sure your TE is doing its work on a server side?

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Posted

are you sure you're implementing writeEntitytoNBT and readEntityToNBT (or wtv the f they're called) in your tile entity ?

can we have the code of your tile entity ?

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

So I was double-checking my read/writeFromNBT methods and in the process noticed that the onDataPacket method didn't actually change the tile entity's data. . . thanks for the suggestions, though.  Problem's fixed, for now.

 

God only knows how onDataPacket could somehow not change the tile entity's data while sneakily appearing to.  (Although LexManos would probably know better. . .)

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

    • Hello, I have this same problem. Did you manage to find a solution? Any help would be appreciated. Thanks.
    • log: https://mclo.gs/QJg3wYX as stated in the title, my game freezes upon loading into the server after i used a far-away waystone in it. The modpack i'm using is better minecraft V18. Issue only comes up in this specific server, singleplayer and other servers are A-okay. i've already experimented with removing possible culprits like modernfix and various others to no effect. i've also attempted a full reinstall of the modpack profile. Issue occurs shortly after the 'cancel' button dissapears on the 'loading world' section of the loading screen.   thanks in advance.
    • You would have better results asking a more specific question. What have you done? What exactly do you need help with? Please also read the FAQ regarding posting logs.
    • Hi, this is my second post with the same content as no one answered this and it's been a long time since I made the last post, I want to make a client-only mod, everything is ok, but when I use shaders, none of the textures rendered in RenderLevelStageEvent nor the crow entity model are rendered, I want them to be visible, because it's a horror themed mod I've already tried it with different shaders, but it didn't work with any of them and I really want to add support for shaders Here is how i render the crow model in the CrowEntityRenderer<CrowEntity>, by the time i use this method, i know is not the right method but i don't think this is the cause of the problem, the renderType i'm using is entityCutout @Override public void render(CrowEntity p_entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { super.render(p_entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); ClientEventHandler.getClient().crow.renderToBuffer(poseStack, bufferSource.getBuffer(ClientEventHandler.getClient().crow .renderType(TEXTURE)), packedLight, OverlayTexture.NO_OVERLAY, Utils.rgb(255, 255, 255)); } Here renderLevelStage @Override public void renderWorld(RenderLevelStageEvent e) { horrorEvents.draw(e); } Here is how i render every event public void draw(RenderLevelStageEvent e) { for (HorrorEvent event : currentHorrorEvents) { event.tick(e.getPartialTick()); event.draw(e); } } Here is how i render the crow model on the event @Override public void draw(RenderLevelStageEvent e) { if(e.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { float arcProgress = getArcProgress(0.25f); int alpha = (int) Mth.lerp(arcProgress, 0, 255); int packedLight = LevelRenderer.getLightColor(Minecraft.getInstance().level, blockPos); VertexConsumer builder = ClientEventHandler.bufferSource.getBuffer(crow); Crow<CreepyBirdHorrorEvent> model = ClientEventHandler .getClient().crow; model.setupAnim(this); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, packedLight, OverlayTexture.NO_OVERLAY, alpha); builder = ClientEventHandler.bufferSource.getBuffer(eyes); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, 15728880, OverlayTexture.NO_OVERLAY, alpha); } } How i render the model public static void renderModelInWorld(Model model, Vector3f pos, Vector3f offset, Camera camera, PoseStack matrix, VertexConsumer builder, int light, int overlay, int alpha) { matrix.pushPose(); Vec3 cameraPos = camera.getPosition(); double finalX = pos.x - cameraPos.x + offset.x; double finalY = pos.y - cameraPos.y + offset.y; double finalZ = pos.z - cameraPos.z + offset.z; matrix.pushPose(); matrix.translate(finalX, finalY, finalZ); matrix.mulPose(Axis.XP.rotationDegrees(180f)); model.renderToBuffer(matrix, builder, light, overlay, Utils .rgba(255, 255, 255, alpha)); matrix.popPose(); matrix.popPose(); } Thanks in advance
  • Topics

×
×
  • Create New...

Important Information

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