Jump to content

Any good wait methods?


timoteo2000

Recommended Posts

Then every tick cycle through all elements and tick() them. if one of them returns true, remove it. When you want to schedule something, just add a new QueueElement to the set.

P.S.: Please learn java.

Thanks for that, but again, how am I supposed to tell it all of the coordinates of the block?

Since I have exactly 80 times a block needs to be set to fire, it would be rather annoying to use a Set.add() method for all of them, but I'm assuming that is what I'll have to do. I can't do, say "Set.add(x + 0, y + 1, z + 0)" because it only wants one object, or "Set.add(x + 0); [next line] Set.add(y + 1); [next line] Set.add(z + 0);" because it won't see that as one object.

 

I do know it's probably somewhat irritating dealing with my still-learning intelligence level, and I am sorry for that.

EntityHerobrine.setDead();

 

Pwned.

Link to comment
Share on other sites

Don't store all the blocks. Only store the x,y,z of the block clicked. Then when 10 ticks have passed replicate the algorithm you use for placing the fire and place air instead.

And dont put the coordinates directly into the set. You need a wrapper class like I posted.

So what method in Set would I use? I thought .add(Object) was right, but you can't store 3 co-ords at one time (x, y, z) only a single one (x) (y) (z).

I have a wrapper class, and it's pretty much what you showed me with a different name.

package com.lesterhouse.timo;

import net.minecraft.world.World;

public class BlockQueue {

public final World w;
public final int x;
public final int y;
public final int z;
private int ticks;

public BlockQueue(World w, int x, int y, int z) {
	this.w = w;
	this.x = x;
	this.y = y;
	this.z = z;
}

public boolean tick() {
	ticks++;
	if (ticks == 10) {
                        //All 80 instances of w.setBlock that mimics the 80 in ItemFirePowder, but with air
		return true;
	} else {
		return false;
	}
}

}

So I guess all I'm asking is: Where would I implement my new set and how to record the three different set co-ords of the block right clicked, which if the user isn't stupid is right below them.

EntityHerobrine.setDead();

 

Pwned.

Link to comment
Share on other sites

That code is not set in stone, please try to understand it and adjust it for your needs ;)

Okay, so that all helped. But, the code stopped right at the tick() method. I know this, as I put a println() inside of tick() and one inside of if(ticks == 10) and the one in tick responded but not the one in the if statement.

So it doesn't increment the ticks, I guess? Also, I had to change one thing to the thing you wanted me to put in onItemUse. It didn't work, and it threw errors, so I turned it from:

YourMod.getTickHandler().addElement(new BlockQueue(world, x, y, z));

to

ClientTickHandler.addElement(new BlockQueue(world, x, y, z));

And it didn't throw errors, luckily, but still didn't clear the fire, as it never reached the if statement. So either the Set isn't enumerating the object I gave it or the ticks never increment.

EntityHerobrine.setDead();

 

Pwned.

Link to comment
Share on other sites

Why do you make the method addElement static?

Please post your complete TickHandler.

Here it is:

 

package com.lesterhouse.timo.client;

import java.util.EnumSet;
import java.util.Iterator;
import java.util.Set;

import com.google.common.collect.Sets;
import com.lesterhouse.timo.BlockQueue;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;

import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

public class ClientTickHandler implements ITickHandler {


private Set<BlockQueue> queue = Sets.newHashSet();

public void addElement(BlockQueue element) {
    queue.add(element);
}

public void tickStart(EnumSet<TickType> types, Object... tickData) {
    Iterator<BlockQueue> it = queue.iterator();
    while (it.hasNext()) {
        if (it.next().tick()) {
            it.remove();
        }
    }
}

@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
	if (type.equals(EnumSet.of(TickType.RENDER)))
	{
		onRenderTick();
	}
	else if (type.equals(EnumSet.of(TickType.CLIENT)))
	{
		GuiScreen guiscreen = Minecraft.getMinecraft().currentScreen;
		if (guiscreen != null)
		{
			onTickInGUI(guiscreen);
		} else {
			onTickInGame();
		}
	}
}

@Override
public EnumSet<TickType> ticks()
{
	return EnumSet.of(TickType.RENDER, TickType.CLIENT);
	// In my testing only RENDER, CLIENT, & PLAYER did anything on the client side.
	// Read 'cpw.mods.fml.common.TickType.java' for a full list and description of available types
}

@Override
public String getLabel() { return null; }


public void onRenderTick()
{
	//System.out.println("onRenderTick");
	//TODO: Your Code Here
}

public void onTickInGUI(GuiScreen guiscreen)
{
	//System.out.println("onTickInGUI");
	//TODO: Your Code Here
}



public void onTickInGame()
{

}
}

 

 

I had to make the first method just public because the void there gave me errors, saying "volatile expected."

EntityHerobrine.setDead();

 

Pwned.

Link to comment
Share on other sites

Why are you doing this on the Client Side? World modification must only happen server side.

I guess I really didn't think of that >.<

Well, don't I still need to tell the client something?

Edit: Yay! it finally works! So, I changed the first thing that defined Set<BlockQueue> as queue into a public static rather than void and it all works fine. I right click a block with Fire Powder, and believe it or not, 1/2 a second later the fire that appeared went away! Thanks for all your help diesie, and I hope to release this mod before 1.5 comes out. Now to add the items that Fire Powder crafts into :D

EntityHerobrine.setDead();

 

Pwned.

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.