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

    • Klarks
      [1.16.4] How i can put my strucnures in to FlatGenerationSettings.STRUCTURES

      By Klarks · Posted 11 minutes ago

      How i can put my structures in to FlatGenerationSettings.STRUCTURES. The structures  var is final so i cant put mine like that FlatGenerationSettings.STRUCTURES.put(MyStructure.RUN_DOWN_HOUSE.get(), CONFIGURED_RUN_DOWN_HOUSE);
    • BobbyLikesCake
      1.16.4 (Heavily decent modded with around 150ish mods) Crash with exit code -1 most of the time and sometimes exit code 0.

      By BobbyLikesCake · Posted 12 minutes ago

      Hi, I need help with a heavily modded world. Whenever I hit a mob I get a crash on the world and then it takes 10 minutes to just get back in. I tried attaching the debug log with this but I couldnt do it either to help. Can anyone help with this? 2021-01-17-13.log.gz
    • The_Raven
      items not extending to java class(1.16)

      By The_Raven · Posted 24 minutes ago

      small question, but how to I make my registry items able to use the code in a java class. or could you tell me how to make the java class into an item. i know extends item, that's not what I'm talking about.
    • Rollng
      Game crashes while loading world

      By Rollng · Posted 27 minutes ago

      So optifine causing this?
    • LexManos
      No file association

      By LexManos · Posted 31 minutes ago

      Some zip managers like to take control of the .jar file extension away from Java. Make sure you have Java installed and try running Jarfix once, then try the installer again.
  • Topics

    • The_Raven
      1
      items not extending to java class(1.16)

      By The_Raven
      Started 25 minutes ago

    • Klarks
      0
      [1.16.4] How i can put my strucnures in to FlatGenerationSettings.STRUCTURES

      By Klarks
      Started 11 minutes ago

    • BobbyLikesCake
      0
      1.16.4 (Heavily decent modded with around 150ish mods) Crash with exit code -1 most of the time and sometimes exit code 0.

      By BobbyLikesCake
      Started 12 minutes ago

    • Rollng
      2
      Game crashes while loading world

      By Rollng
      Started 3 hours ago

    • Ripple
      1
      No file association

      By Ripple
      Started 46 minutes ago

  • Who's Online (See full list)

    • Rollng
    • BobbyLikesCake
    • ChampionAsh5357
    • coalbricks
    • Caffeinated Pinkie
    • FrostyTerror
    • Heinzchen
    • Somonestolemyusername
    • The_Raven
  • 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