Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.6.4]Disabling particles in updateSpawner() based on outside info
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
skullywag

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

By skullywag, January 20, 2014 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

skullywag    0

skullywag

skullywag    0

  • Creeper Killer
  • skullywag
  • Members
  • 0
  • 102 posts
Posted January 20, 2014

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.

  • Quote

Share this post


Link to post
Share on other sites

skullywag    0

skullywag

skullywag    0

  • Creeper Killer
  • skullywag
  • Members
  • 0
  • 102 posts
Posted January 20, 2014

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).

  • Quote

Share this post


Link to post
Share on other sites

skullywag    0

skullywag

skullywag    0

  • Creeper Killer
  • skullywag
  • Members
  • 0
  • 102 posts
Posted January 20, 2014

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...

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • mireyaruff
      my server doens`t work

      By mireyaruff · Posted 1 minute ago

      Thx, appreciate it!
    • Badnews4u
      My forge server won't load all the mods

      By Badnews4u · Posted 16 minutes ago

      Went through all the steps to make forge server hosted from my computer. I was able to successfully launch the server, but after joining the server I noticed not all my mods were working. Most notably it didn't generate a world with biomes o' plenty when I made sure to set the biomes o' plenty default world setting in the configs to true. Also gravestone mod won't give me gravestones. I made sure to update my java and everything and yes, I made sure to create the server using the forge .jar file. Any suggestions on how to fix this?
    • Lellian
      [SOLVED] [1.16.4] Change Block Hitbox/Outline

      By Lellian · Posted 2 hours ago

      Well this is embarrasing. I don't know how I missed this, but it fixed everything.   Thank you very much 🤣🔫
    • Draco18s
      [SOLVED] [1.16.4] Change Block Hitbox/Outline

      By Draco18s · Posted 2 hours ago

      Cough.  
    • Lellian
      [SOLVED] [1.16.4] Change Block Hitbox/Outline

      By Lellian · Posted 2 hours ago

      What do you mean? ExampleBlock is the small stone thing you see in the picture. It gets registered just fine (Via a DeferredRegistry), I can place it and then you see what is in the picture. This is about the hitbox/outline of the block, which I want to be smaller.
  • Topics

    • peermans
      2
      my server doens`t work

      By peermans
      Started January 7

    • Badnews4u
      0
      My forge server won't load all the mods

      By Badnews4u
      Started 16 minutes ago

    • Lellian
      4
      [SOLVED] [1.16.4] Change Block Hitbox/Outline

      By Lellian
      Started 3 hours ago

    • Chicckenprell
      0
      stoneblock 1.12.2 server crashing

      By Chicckenprell
      Started 4 hours ago

    • Veo
      2
      Unable to start LAN server detection: Can't assign requested address [Server][Modded][1.16.4]

      By Veo
      Started 8 hours ago

  • Who's Online (See full list)

    • Choonster
    • LexManos
    • Badnews4u
    • mireyaruff
    • jbredwards
    • P3pp3rF1y
    • Caffeinated Pinkie
    • Klarks
    • Qrani
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.6.4]Disabling particles in updateSpawner() based on outside info
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community