Jump to content

[solved]Blocks not saving meta data on server shutdown/ player logout?


Jade_Knightblazer

Recommended Posts

I use this following code to adjust the metadata for surrounding blocks

 

 

public static boolean soulDrain(int soulcost) //, int x, int y, int z)
{
	World world = worldPointer;
	int x = posX;
	int y = posY;
	int z = posZ;
	int cost = soulcost;

	soulCountTotal = (soulCountTotal - (cost * 5));

	 for (int var6 = x - 2; var6 <= x + 2; ++var6)
        {
            for (int var7 = z - 2; var7 <= z + 2; ++var7)
            {
                if (var6 > x - 2 && var6 < x + 2 && var7 == z - 1)
                {
                    var7 = z + 2;
                }
                    for (int var8 = y - 1; var8 <= y + 1; ++var8)
                    {
                        if (world.getBlockId(var6, var8, var7) == mod_HarkenScythe.HSSoulCrucible.blockID) //&& soulCountTotal > 0)
                        {
                        	int var11 = world.getBlockMetadata(var6, var8, var7);
                        	
                            if (!world.isAirBlock((var6 - x) / 2 + x, var8 + 1, (var7 - z) / 2 + z))
                            {
                                break;
                            }
                            
                            if (var11 > cost)
                            {
                            	world.setBlockMetadataWithNotify(var6, var8, var7, var11 - cost);
                            	cost = 0;
                            }
                            if (cost >= var11)
                            {
                            	world.setBlockMetadataWithNotify(var6, var8, var7, 0);
                            	cost -= var11;
                            }
                        }
                    }
            }
        }
	 System.out.println(cost);
	return true;
}

 

 

 

Now this works 100% while playing SP however while playing on servers the following happens.

 

First the BlockSoulCrucible in the area are affected by the method - works correct.

On server Log out, all BlockSoulCrucible's reset back their old Metadata- not correct.

 

Wondering why the Metadata is not saving or updating/saving upon logout.

Link to comment
Share on other sites

Are you sure you call it only on server-side? Sounds to me you call this only client-side.

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.

Link to comment
Share on other sites

Correct, I had it calling from my Gui button action.

 

I now enabled the metadata change method on a Side.SERVER , which works great... however now my Gui does not update with the new Metadata info.

 

If I leave my Gui metadata change in tack and enable the new Side.SERVER method in my tileEntityCustom.class, it works great for servers.... however if you play single player, then the action is done twice T_T.

 

Gained SMP but lost SP =/

 

Any suggestions?

 

This is the code I use for my Gui Display text of Total Soul Count. I use a static variable that is on my BlockSoulAltar.

Which I force an update when the block is activated.

 

 

********************
//AutoCenters Numbers
int ws = 0;
if (BlockSoulAltar.soulCountTotal > 999)
{
	ws = -4;
}

//SoulCountTotal Display
fontRenderer.drawString(""+ BlockSoulAltar.soulCountTotal, 150 + ws, 24, 0xffffff);
***************************


@Override
protected void drawGuiContainerForegroundLayer()
{
// Draws The title of the Gui like "Furnace" for the furnace,
// It has 4 params
// @param "Tutorial Gui" this is the Name in String format
// @param int 6, this is the xCoord on the screen
// @param int 6, this is the yCoord on the screen
// @param 0xffffff, this is the color in hex, 0xffffff, is white, 0x000000 is black BTW
fontRenderer.drawString("Soul Altar", 6, 6, 4210752);
fontRenderer.drawString("Captured Souls", 94, 6, 4210752);

//AutoCenters Numbers
int ws = 0;
if (BlockSoulAltar.soulCountTotal > 999)
{
	ws = -4;
}

//SoulCountTotal Display
fontRenderer.drawString(""+ BlockSoulAltar.soulCountTotal, 150 + ws, 24, 0xffffff);

//SoulCostTotal Display
if (this.inventorySlots.getSlot(0).getStack() != null)
{
	fontRenderer.drawString(""+ this.SARL[1] * this.inventorySlots.getSlot(0).getStack().stackSize, 150, 51, 0xffffff);
}

// This draws the caption for the players inventory this is not needed as the above but is sometimes nice
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 6, ySize - 96 + 2, 4210752);
}

 

 

 

Link to comment
Share on other sites

Nvm, figured it out.

 

Placed this on my gui Button action method.

 

if (this.mc.isIntegratedServerRunning() == false)

{

this.containerSoulAltar.soulDrain(soulCostTotal / 5);

},

 

This way the extra method is disabled when not needed xD.

 

Thanks, helped me look in the right direction.

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.



×
×
  • Create New...

Important Information

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