Jump to content

[1.6.4]Disabling particles in updateSpawner() based on outside info


skullywag

Recommended Posts

Hey all,

 

this seems simple enough but ive tried multiple ways to no avail. In a mob spawners base logic class in the updateSpawner() method there are some particles that are always running:

 

public void updateSpawner()
    {
        if (this.canRun())
        {        	
            double d0;

            if (this.getSpawnerWorld().isRemote)
            {
                double d1 = (double)((float)this.getSpawnerX() + this.getSpawnerWorld().rand.nextFloat());
                double d2 = (double)((float)this.getSpawnerY() + this.getSpawnerWorld().rand.nextFloat());
                d0 = (double)((float)this.getSpawnerZ() + this.getSpawnerWorld().rand.nextFloat());
                this.getSpawnerWorld().spawnParticle("smoke", d1, d2, d0, 0.0D, 0.0D, 0.0D);
                this.getSpawnerWorld().spawnParticle("flame", d1, d2, d0, 0.0D, 0.0D, 0.0D);

 

Ive managed to get spawning to stop on redstone signal but the particles still continue. I want them to stop as well. So far I have:

 

public void onNeighborBlockChange(World world, int par2, int par3, int par4, int par5)
    {
    	TileEntityCustomSpawner te = (TileEntityCustomSpawner)world.getBlockTileEntity(par2, par3, par4);
    if (world.isBlockIndirectlyGettingPowered(par2, par3, par4)) 
    {
    	te.signal = true;
    } 
    else 
    {
    	te.signal = false;
    }
    }

 

in my Block class and my TE class has this:

 

public void updateEntity()
    {
    	if(this.signal == false)
    	{
        this.field_98050_a.updateSpawner();
        super.updateEntity();
    	}

    }

 

As stated this stops spawning but particles still continue, can someone explain how this is the case and what I can do to stop it, ive got code blindness from staring at this problem for hours.

 

Thanks.

Link to comment
Share on other sites

ok, so i think my problem is down to desynch between server and client (ive done some digging and a lot of people hit this snag when first playing with tile entities it seems). Just so im sure this is the case I placed a print statement inside the updateSpawner method and printed the spawnDelay. This is the printout from my mobspawner:

 

2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 20
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 20
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 19
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 19
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 20
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 18
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 19
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 17
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 16
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 18
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 15
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 17
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 14
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 16
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 13
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 15
2014-01-20 21:29:27 [iNFO] [sTDOUT] Delay 12
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 11
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 14
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 10
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 13
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 9
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 12
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 8
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 11
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 7
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 6
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 10
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 5
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 9
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 4
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 8
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 3
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 7
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 2
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 1
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 6
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 0
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 5
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 465
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 4
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 464
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 3
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 463
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 462
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 2
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 461
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 1
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 460
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 0
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 459
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 0
2014-01-20 21:29:28 [iNFO] [sTDOUT] Delay 458

 

now I guessed one of those is client and 1 is server. So I put the print inside the "if (this.getSpawnerWorld().isRemote)", the result was this:

 

2014-01-20 21:31:44 [iNFO] [sTDOUT] Delay 20
2014-01-20 21:31:44 [iNFO] [sTDOUT] Delay 19
2014-01-20 21:31:44 [iNFO] [sTDOUT] Delay 20
2014-01-20 21:31:44 [iNFO] [sTDOUT] Delay 19
2014-01-20 21:31:44 [iNFO] [sTDOUT] Delay 18
2014-01-20 21:31:44 [iNFO] [sTDOUT] Delay 17
2014-01-20 21:31:44 [iNFO] [sTDOUT] Delay 16
2014-01-20 21:31:44 [iNFO] [sTDOUT] Delay 15
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 14
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 13
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 12
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 11
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 10
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 9
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 8
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 7
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 6
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 5
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 4
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 3
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 2
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 1
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 0
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 0
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 0
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 0
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 0
2014-01-20 21:31:45 [iNFO] [sTDOUT] Delay 0
2014-01-20 21:31:46 [iNFO] [sTDOUT] Delay 0

 

and it stayed at 0 even though the mobspawner was still spawning. Now I have:

 

public Packet getDescriptionPacket()
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        this.writeToNBT(nbttagcompound);
        return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound);
    }
    
    public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt)
    {
            NBTTagCompound tag = pkt.data;
            readFromNBT(tag);
    }

 

in my Tile Entity class and I believe they are structured correctly, is there a piece to this puzzle im missing? or something im not understanding (probably the case).

Link to comment
Share on other sites

ok so it turns out that doing the below when it gets a redstone signal:

 

TileEntityCustomSpawner spawner = (TileEntityCustomSpawner)world.getBlockTileEntity(x, y, z);
    		
spawner.getSpawnerLogic().spawnDelay = -1;

 

then, putting this in the canRun of the spawner logic class:

 

if(this.spawnDelay == -1)
    	{
    		return false;
    	}

 

makes everything work perfectly, I just set the spawn delay back to 20 when the redstone signal goes off. Now to test how it holds up on a server, I have a feeling it might not work so well...

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.