Jump to content

[SOLVED][1.10.2]Sign doesn't update


JimiIT92

Recommended Posts

I made a sign that will act as a leaderboard, so the text in it should be set automatically. If i set the text when placing down the sign everyhting works correctly, however, if i do in the "update" method of the tile entity nothing is displayed on the sign. This is the TileEntity i'm using

	package com.cf.entities;
	import java.util.ArrayList;
	import com.cf.guild.Guild;
import com.cf.utils.GuildUtils;
	import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.ITickable;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
	public class TileEntityLeaderboardSign extends TileEntitySign implements ITickable {
	    @Override
    public void update() {
        if (!this.worldObj.isRemote) {
            ArrayList<Guild> guilds = GuildUtils.getGuildsOrderedByBank();
            if (!guilds.isEmpty()) {
                this.signText[0] = new TextComponentTranslation("guild.leaderboard.top", new Object[0]);
                this.signText[1] = new TextComponentString("#1");
                this.signText[2] = new TextComponentString(guilds.get(0).getName());
                this.signText[3] = new TextComponentString(
                        new TextComponentTranslation("guild.leaderboard.golds", new Object[0]) + " "
                                + String.valueOf(guilds.get(0).getBank().getGold()));
            } else
                this.signText[0] = new TextComponentTranslation("guild.leaderboard.noguilds", new Object[0]);
        }
    }
}
	



So i just extend the TileEntitySign and implement the ITickable interface to make the TileEntity update. But as i said on the sign no text is displayed at all. What should i do to solve this issue? :)

EDIT: I solved this by using 2 messages. The first is sent to the server from the tile entity like this

if (this.worldObj.isRemote) {
            CoreGuild.NETWORK.sendToServer(new LeaderboardServerMessage(this.pos.getX(), this.pos.getY(), this.pos.getZ()));
        }



In wich i do this

TileEntity te = CoreGuild.PROXY.getPlayer(ctx).worldObj.getTileEntity(message.pos);
                    if(te != null && te instanceof TileEntityLeaderboardSign) {
                        TileEntityLeaderboardSign sign = (TileEntityLeaderboardSign)te;
                        ArrayList<Guild> guilds = GuildUtils.getGuildsOrderedByBank();
                        String text = "No guilds";
                        if (!guilds.isEmpty()) {
                            text = guilds.get(0).getName();
                        }
                        CoreGuild.NETWORK.sendTo(new LeaderboardClientMessage(text, message.pos.getX(), message.pos.getY(), message.pos.getZ()), (EntityPlayerMP) CoreGuild.PROXY.getPlayer(ctx));
                    }



So i send a message to the client with what i want to display. Then on the client i set the texts :)

TileEntity te = CoreGuild.PROXY.getPlayer(ctx).worldObj.getTileEntity(message.pos);
                    if(te != null && te instanceof TileEntityLeaderboardSign) {
                        TileEntityLeaderboardSign sign = (TileEntityLeaderboardSign)te;
                        sign.signText[0] = new TextComponentString(message.name);
                    }

Edited by JimiIT92

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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