Jump to content

@ServerStarted annotation not working?


charsmud

Recommended Posts

Hello!  I have been trying to use the @ServerStarted annotation, but for some reason, it is not working.  Here's my main class and the related classes:

 

package timeTraveler.core;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.ModLoader;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import timeTraveler.blocks.BlockTimeTraveler;
import timeTraveler.entities.EntityPlayerPast;
import timeTraveler.items.ItemParadoximer;
import timeTraveler.mechanics.FutureTravelMechanics;
import timeTraveler.proxies.CommonProxy;
import timeTraveler.structures.StructureGenerator;
import timeTraveler.ticker.TickerClient;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.Mod.ServerStarted;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;


@Mod(modid = "Charsmud_TimeTraveler", name = "Time Traveler", version = "0.1")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
/**
* Main laucher for TimeTraveler
* @author Charsmud
*
*/
public class TimeTraveler
{
@SidedProxy(clientSide = "timeTraveler.proxies.ClientProxy", serverSide = "timeTraveler.proxies.CommonProxy")


public static CommonProxy proxy;

public static Block travelTime;
public static Item paradoximer;

public static final String modid = "Charsmud_TimeTraveler";

FutureTravelMechanics ftm;

/**
 * Initializes DeveloperCapes
 * @param event
 */
@PreInit
public void preInit(FMLPreInitializationEvent event)
{
	proxy.initCapes();
}
/**
 * Initiates mod, registers block and item for use.  Generates the necessary folders.
 */
@Init
public void load(FMLInitializationEvent event)
{  	
	proxy.registerRenderThings();

	TickRegistry.registerTickHandler(new TickerClient(), Side.CLIENT);

	Minecraft m = FMLClientHandler.instance().getClient();
	MinecraftServer ms = m.getIntegratedServer();

	mkDirs();

	paradoximer = new ItemParadoximer(2330).setUnlocalizedName("ItemParadoximer");	
	travelTime = new BlockTimeTraveler(255).setUnlocalizedName("BlockTimeTraveler");
	GameRegistry.registerBlock(travelTime, "travelTime");

	LanguageRegistry.addName(travelTime, "Paradox Cube");
	LanguageRegistry.addName(paradoximer, "Paradoximer");

	GameRegistry.registerWorldGenerator(new StructureGenerator());

	GameRegistry.addRecipe(new ItemStack(travelTime,  13), new Object[] 
			{
		//
		"x", Character.valueOf('x'), Block.dirt
			});
	GameRegistry.addRecipe(new ItemStack(paradoximer,  13), new Object[] 
			{
		"x", "s", Character.valueOf('x'), Block.wood, Character.valueOf('s'), Block.dirt
			});
	ModLoader.registerEntityID(EntityPlayerPast.class, "PlayerPast", 100);//registers the mobs name and id
	// ModLoader.addSpawn(EntityPlayerPast.class, 25, 25, 25, EnumCreatureType.creature);

ftm = new FutureTravelMechanics();
}
/**
 * Makes the Directories needed
 */
public void mkDirs()
{
	File pastCreation = new File(FMLClientHandler.instance().getClient().getMinecraftDir() + "/mods/TimeMod/past");
	pastCreation.mkdirs();
	File presentCreation = new File(FMLClientHandler.instance().getClient().getMinecraftDir() + "/mods/TimeMod/present");
	presentCreation.mkdirs();
	File futureCreation = new File(FMLClientHandler.instance().getClient().getMinecraftDir() + "/mods/TimeMod/future");

}
/**
 * Runs when server starts.  Contains information about new packets and data about what to do with them.
 * @param event
 */
    @ServerStarted
    public void onServerStarted(FMLServerStartedEvent event) {
    	System.out.println("Z");
            NetworkRegistry.instance().registerChannel(new IPacketHandler() {
                    @Override
                    public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
                            DataInputStream datainputstream = new DataInputStream(new ByteArrayInputStream(packet.data));
                            try
                            {
                            	System.out.println("A");
                                    int run = datainputstream.readInt();
                                    World world = DimensionManager.getWorld(0);
                                    if (world != null) {
                                    	System.out.println("B");
                                            for (int i = 0; i < run; i++)
                                            {
                                                    ftm.expandOres(world, 1, 1, 1, 1, 1, 1, 1);
                                                    ftm.expandForests(world, 2);
                                            }
                                    }

                            }
                            catch (IOException ioexception)
                            {
                                    ioexception.printStackTrace();
                            }
                    }
            }, "futuretravel", Side.SERVER);
    }

}

package timeTraveler.gui;
//
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.util.StringTranslate;

import org.lwjgl.input.Keyboard;

import timeTraveler.mechanics.FutureTravelMechanics;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.network.PacketDispatcher;

/**
* GUI for the paradoximer
* @author Charsmud
*
*/
public class GuiFutureTravel extends GuiScreen{

    private GuiScreen parentGuiScreen;
    private GuiTextField theGuiTextField;
    private final String yearsIntoFuture;


    
    public GuiFutureTravel(GuiScreen par1GuiScreen, String par2Str)
    {
        this.parentGuiScreen = par1GuiScreen;
        this.yearsIntoFuture = par2Str;  
    }

    /**
     * Called from the main game loop to update the screen.
     */
    public void updateScreen()
    {
        this.theGuiTextField.updateCursorCounter();
    }

    /**
     * Adds the buttons (and other controls) to the screen in question.
     */
    public void initGui()
    {
        StringTranslate var1 = StringTranslate.getInstance();
        Keyboard.enableRepeatEvents(true);
        this.buttonList.clear();
        this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, var1.translateKey("Travel Into the Future!")));
        this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, var1.translateKey("gui.cancel")));
        this.theGuiTextField = new GuiTextField(this.fontRenderer, this.width / 2 - 100, 60, 200, 20);
        this.theGuiTextField.setFocused(true);
        this.theGuiTextField.setText(yearsIntoFuture);
    }

    /**
     * Called when the screen is unloaded. Used to disable keyboard repeat events
     */
    public void onGuiClosed()
    {
        Keyboard.enableRepeatEvents(false);
    }

    /**
     * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
     */
    protected void actionPerformed(GuiButton par1GuiButton)
    {
        if (par1GuiButton.enabled)
        {
            if (par1GuiButton.id == 1)
            {
                this.mc.displayGuiScreen(null);
            }
            else if (par1GuiButton.id == 0)
            {
            	if(theGuiTextField.getText() != "")
            	{
                	int run = Integer.parseInt(theGuiTextField.getText());
                	
            		FutureTravelMechanics ftm = new FutureTravelMechanics();
            	
            		WorldClient world = FMLClientHandler.instance().getClient().theWorld;
                	System.out.println(run);
            		/*for (int i = 0; i < run; i++)
                	{
                		ftm.expandOres(world, 1, 1, 1, 1, 1, 1, 1);
                		ftm.expandForests(world, 2);
                	}*/
                    ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
                    DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
                    try
                    {
                    	System.out.println(dataoutputstream + " ");
                            dataoutputstream.writeInt(run);
                            System.out.println(" :)");
                            PacketDispatcher.sendPacketToServer(new Packet250CustomPayload("futuretravel", bytearrayoutputstream.toByteArray()));
                            System.out.println(" :) ");
                    }
                    
                    catch (Exception exception)
                    {
                            exception.printStackTrace();
                    }

            	}
            }
        }
    }

    /**
     * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
     */
    protected void keyTyped(char par1, int par2)
    {
    	Character c = par1;
    		if(c.isDigit(c))
    		{
            this.theGuiTextField.textboxKeyTyped(par1, par2);
    		}
        ((GuiButton)this.buttonList.get(0)).enabled = this.theGuiTextField.getText().trim().length() > 0;
        if (par1 == 13)
        {
            this.actionPerformed((GuiButton)this.buttonList.get(0));
        }
    }

    /**
     * Called when the mouse is clicked.
     */
    protected void mouseClicked(int par1, int par2, int par3)
    {
        super.mouseClicked(par1, par2, par3);
        this.theGuiTextField.mouseClicked(par1, par2, par3);
    }

    /**
     * Draws the screen and all the components in it.
     */
    public void drawScreen(int par1, int par2, float par3)
    {
        StringTranslate var4 = StringTranslate.getInstance();
        this.drawDefaultBackground();
        this.drawCenteredString(this.fontRenderer, var4.translateKey("Future Travel"), this.width / 2, this.height / 4 - 60 + 20, 16777215);
        this.drawString(this.fontRenderer, var4.translateKey("Years"), this.width / 2 - 100, 47, 10526880);
        this.theGuiTextField.drawTextBox();
        super.drawScreen(par1, par2, par3);
    }
}

Any ideas as to why this isn't working?

Link to comment
Share on other sites

Annotations are little more than comments that induce extra error checking.  They don't actually get compiled.

(There may be some exceptions, such as @Mod and @NetworkMod)

 

My guess is that you never registered onServerStarted as an event handler.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Yea, that would be it... How would I register it as an event handler?  I've never actually done much with event handlers, so I'm sort of a beginner at that.

 

Hooray a wiki!  It even has a link to a nice tutorial.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Hm.... I've managed to get it to print inside of the method, meaning I was able to register the new packet.  However, the stuff does not expand anymore!  :(  Here's my changed code:

 

package timeTraveler.core;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.ModLoader;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
import timeTraveler.blocks.BlockTimeTraveler;
import timeTraveler.entities.EntityPlayerPast;
import timeTraveler.items.ItemParadoximer;
import timeTraveler.mechanics.FutureTravelMechanics;
import timeTraveler.proxies.CommonProxy;
import timeTraveler.structures.StructureGenerator;
import timeTraveler.ticker.TickerClient;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.Mod.ServerStarted;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;


@Mod(modid = "Charsmud_TimeTraveler", name = "Time Traveler", version = "0.1")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
/**
* Main laucher for TimeTraveler
* @author Charsmud
*
*/
public class TimeTraveler
{
@SidedProxy(clientSide = "timeTraveler.proxies.ClientProxy", serverSide = "timeTraveler.proxies.CommonProxy")


public static CommonProxy proxy;

public static Block travelTime;
public static Item paradoximer;

public static final String modid = "Charsmud_TimeTraveler";

FutureTravelMechanics ftm;

/**
 * Initializes DeveloperCapes
 * @param event
 */
@PreInit
public void preInit(FMLPreInitializationEvent event)
{
	proxy.initCapes();
}
/**
 * Initiates mod, registers block and item for use.  Generates the necessary folders.
 */
@Init
public void load(FMLInitializationEvent event)
{  	
	proxy.registerRenderThings();

	TickRegistry.registerTickHandler(new TickerClient(), Side.CLIENT);

	Minecraft m = FMLClientHandler.instance().getClient();
	MinecraftServer ms = m.getIntegratedServer();

	mkDirs();

	paradoximer = new ItemParadoximer(2330).setUnlocalizedName("ItemParadoximer");	
	travelTime = new BlockTimeTraveler(255).setUnlocalizedName("BlockTimeTraveler");
	GameRegistry.registerBlock(travelTime, "travelTime");

	LanguageRegistry.addName(travelTime, "Paradox Cube");
	LanguageRegistry.addName(paradoximer, "Paradoximer");

	GameRegistry.registerWorldGenerator(new StructureGenerator());

	GameRegistry.addRecipe(new ItemStack(travelTime,  13), new Object[] 
			{
		//
		"x", Character.valueOf('x'), Block.dirt
			});
	GameRegistry.addRecipe(new ItemStack(paradoximer,  13), new Object[] 
			{
		"x", "s", Character.valueOf('x'), Block.wood, Character.valueOf('s'), Block.dirt
			});
	ModLoader.registerEntityID(EntityPlayerPast.class, "PlayerPast", 100);//registers the mobs name and id
	// ModLoader.addSpawn(EntityPlayerPast.class, 25, 25, 25, EnumCreatureType.creature);

	ftm = new FutureTravelMechanics();
	//MinecraftForge.EVENT_BUS.register(new EventHookContainer());

	registerPackets();

}
/**
 * Makes the Directories needed
 */
public void mkDirs()
{
	File pastCreation = new File(FMLClientHandler.instance().getClient().getMinecraftDir() + "/mods/TimeMod/past");
	pastCreation.mkdirs();
	File presentCreation = new File(FMLClientHandler.instance().getClient().getMinecraftDir() + "/mods/TimeMod/present");
	presentCreation.mkdirs();
	File futureCreation = new File(FMLClientHandler.instance().getClient().getMinecraftDir() + "/mods/TimeMod/future");

}
public void registerPackets()
{
        NetworkRegistry.instance().registerChannel(new IPacketHandler() {
            @Override
            public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
                    DataInputStream datainputstream = new DataInputStream(new ByteArrayInputStream(packet.data));
                    try
                    {
                    	System.out.println("A");
                            int run = datainputstream.readInt();
                            World world = DimensionManager.getWorld(0);
                            if (world != null) {
                            	System.out.println("B");
                                    for (int i = 0; i < run; i++)
                                    {
                                            ftm.expandOres(world, 1, 1, 1, 1, 1, 1, 1);
                                            ftm.expandForests(world, 2);
                                    }
                            }

                    }
                    catch (IOException ioexception)
                    {
                            ioexception.printStackTrace();
                    }
            }
    }, "futuretravel", Side.SERVER);

}
}

package timeTraveler.mechanics;

import java.util.Iterator;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockSapling;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import cpw.mods.fml.client.FMLClientHandler;
/**
* Contains information about the future mechanics
* @author Charsmud
*
*/
public class FutureTravelMechanics
{
EntityPlayer ep;
World world;

/**
 * Constructor
 */
public FutureTravelMechanics()
{
	ep = FMLClientHandler.instance().getClient().thePlayer;
	world = FMLClientHandler.instance().getClient().theWorld;
}
/**
 * Main expanding ores method
 * @param world
 * @param coal
 * @param diamond
 * @param emerald
 * @param gold
 * @param iron
 * @param lapis
 * @param redstone
 */
public void expandOres(World world, int coal, int diamond, int emerald, int gold, int iron, int lapis, int redstone)
{
	Iterator<ChunkCoordIntPair> iterator = world.activeChunkSet.iterator();
	System.out.println("EXPANDORES");
	while(iterator.hasNext())
	{
		ChunkCoordIntPair coords = iterator.next();
		//Chunk currentScanningChunk = world.getChunkFromBlockCoords((int)ep.posX, (int) ep.posZ);
		Chunk currentScanningChunk = world.getChunkFromChunkCoords(coords.chunkXPos, coords.chunkZPos);
		expandRedstone(world, currentScanningChunk, redstone);
		expandDiamond(world, currentScanningChunk, diamond);
		expandCoal(world, currentScanningChunk, coal);
		expandEmerald(world, currentScanningChunk, emerald);
		expandGold(world, currentScanningChunk, gold);
		expandIron(world, currentScanningChunk, iron);
		expandLapis(world, currentScanningChunk, lapis);

		/*ISaveHandler save = world.getSaveHandler();
		IChunkLoader saver = save.getChunkLoader(world.provider);
		try
		{
			System.out.println(world);
			System.out.println(currentScanningChunk);
			saver.saveChunk(world, currentScanningChunk);
		}
		catch(MinecraftException ex)
		{
			ex.printStackTrace();
			System.out.println("FAILED TO SAVE MINE");
		}
		catch(IOException ex)
		{
			ex.printStackTrace();
			System.out.println("FAILED TO SAVE IO");
		}*/

	}
}
/**
 * Main expanding forests method
 * @param world
 * @param size
 */
public void expandForests(World world, int size)
{
	Iterator<ChunkCoordIntPair> iterator = world.activeChunkSet.iterator();
	System.out.println("EXPANDFORESTS");
	while(iterator.hasNext())
	{
		ChunkCoordIntPair coords = iterator.next();

		Chunk currentScanningChunk = world.getChunkFromChunkCoords(coords.chunkXPos, coords.chunkZPos);
		expandForest(world, currentScanningChunk, size);
		/*
		ISaveHandler save = world.getSaveHandler();
		IChunkLoader saver = save.getChunkLoader(world.provider);
		try
		{
			saver.saveChunk(world, currentScanningChunk);
		}
		catch(MinecraftException ex)
		{
			ex.printStackTrace();
			System.out.println("FAILED TO SAVE MINE");
		}
		catch(IOException ex)
		{
			ex.printStackTrace();
			System.out.println("FAILED TO SAVE IO");
		}*/
	}
}
//BELOW ARE HELPER METHODS

/**
 * Coal ore expansion helper method
 * @param world
 * @param currentScanningChunk
 * @param size
 */
public void expandCoal(World world, Chunk currentScanningChunk, int size)
{
	for(int i = 0; i < size; i++)
	{
		for(int x = 0; x < 15; x++)
		{
			for(int y = 0; y < 255; y++)
			{
				for(int z = 0; z < 15; z++)
				{
					if(world.blockExists(x, y, z))
					{
						if(currentScanningChunk.getBlockID(x, y, z) == Block.oreCoal.blockID)
						{
							Random rand = new Random();
							int expandX = rand.nextInt(3)-1;
							int expandY = rand.nextInt(3)-1;
							int expandZ = rand.nextInt(3)-1;
							System.out.println(x*16 + " " + y + " " + z*16);
							if(currentScanningChunk.getBlockID(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ)) != 0)
							{
								currentScanningChunk.setBlockIDWithMetadata(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ), Block.oreCoal.blockID, 0);
							}
						}
					}
				}
			}
		}
	}
}
/**
 * Diamond ore expansion helper method
 * @param world
 * @param currentScanningChunk
 * @param size
 */
public void expandDiamond(World world, Chunk currentScanningChunk, int size)
{
	for(int i = 0; i < size; i++)
	{
		for(int x = 0; x < 15; x++)
		{
			for(int y = 0; y < 255; y++)
			{
				for(int z = 0; z < 15; z++)
				{
					if(world.blockExists(x, y, z))
					{
						if(currentScanningChunk.getBlockID(x, y, z) == Block.oreDiamond.blockID)
						{
							Random rand = new Random();
							int expandX = rand.nextInt(3)-1;
							int expandY = rand.nextInt(3)-1;
							int expandZ = rand.nextInt(3)-1;
							System.out.println(x*16 + " " + y + " " + z*16);
							if(currentScanningChunk.getBlockID(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ)) != 0)
							{
								currentScanningChunk.setBlockIDWithMetadata(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ), Block.oreDiamond.blockID, 0);
							}
						}
					}
				}
			}
		}
	}
}
/**
 * Emerald ore expansion helper method
 * @param world
 * @param currentScanningChunk
 * @param size
 */
public void expandEmerald(World world, Chunk currentScanningChunk, int size)
{
	for(int i = 0; i < size; i++)
	{
		for(int x = 0; x < 15; x++)
		{
			for(int y = 0; y < 255; y++)
			{
				for(int z = 0; z < 15; z++)
				{
					if(world.blockExists(x, y, z))
					{
						if(currentScanningChunk.getBlockID(x, y, z) == Block.oreEmerald.blockID)
						{
							Random rand = new Random();
							int expandX = rand.nextInt(3) - 1;
							int expandY = rand.nextInt(3)-1;
							int expandZ = rand.nextInt(3)-1;
							System.out.println(x*16 + " " + y + " " + z*16);
							if(currentScanningChunk.getBlockID(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ)) != 0)
							{
								currentScanningChunk.setBlockIDWithMetadata(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ), Block.oreEmerald.blockID, 0);
							}
						}
					}
				}
			}
		}
	}
}
/**
 * Gold ore expansion helper method
 * @param world
 * @param currentScanningChunk
 * @param size
 */
public void expandGold(World world, Chunk currentScanningChunk, int size)
{
	for(int i = 0; i < size; i++)
	{
		for(int x = 0; x < 15; x++)
		{
			for(int y = 0; y < 255; y++)
			{
				for(int z = 0; z < 15; z++)
				{
					if(world.blockExists(x, y, z))
					{
						if(currentScanningChunk.getBlockID(x, y, z) == Block.oreGold.blockID)
						{
							Random rand = new Random();
							int expandX = rand.nextInt(3)-1;
							int expandY = rand.nextInt(3)-1;
							int expandZ = rand.nextInt(3)-1;
							System.out.println(x*16 + " " + y + " " + z*16);
							if(currentScanningChunk.getBlockID(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ)) != 0)
							{
								currentScanningChunk.setBlockIDWithMetadata(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ), Block.oreGold.blockID, 0);
							}
						}
					}
				}
			}
		}
	}
}
/**
 * Iron ore expansion helper method
 * @param world
 * @param currentScanningChunk
 * @param size
 */
public void expandIron(World world, Chunk currentScanningChunk, int size)
{
	for(int i = 0; i < size; i++)
	{
		for(int x = 0; x < 15; x++)
		{
			for(int y = 0; y < 255; y++)
			{
				for(int z = 0; z < 15; z++)
				{
					if(world.blockExists(x, y, z))
					{
						if(currentScanningChunk.getBlockID(x, y, z) == Block.oreIron.blockID)
						{
							Random rand = new Random();
							int expandX = rand.nextInt(3)-1;
							int expandY = rand.nextInt(3)-1;
							int expandZ = rand.nextInt(3)-1;
							System.out.println(x*16 + " " + y + " " + z*16);
							if(currentScanningChunk.getBlockID(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ)) != 0)
							{
								currentScanningChunk.setBlockIDWithMetadata(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ), Block.oreIron.blockID, 0);
							}
						}

					}
				}
			}
		}
	}
}
/**
 * Lapis ore expansion helper method
 * @param world
 * @param currentScanningChunk
 * @param size
 */
public void expandLapis(World world, Chunk currentScanningChunk, int size)
{
	for(int i = 0; i < size; i++)
	{
		for(int x = 0; x < 15; x++)
		{
			for(int y = 0; y < 255; y++)
			{
				for(int z = 0; z < 15; z++)
				{
					if(world.blockExists(x, y, z))
					{
						if(currentScanningChunk.getBlockID(x, y, z) == Block.oreLapis.blockID)
						{
							Random rand = new Random();
							int expandX = rand.nextInt(3)-1;
							int expandY = rand.nextInt(3)-1;
							int expandZ = rand.nextInt(3)-1;
							System.out.println(x*16 + " " + y + " " + z*16);
							if(currentScanningChunk.getBlockID(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ)) != 0)
							{
								currentScanningChunk.setBlockIDWithMetadata(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ), Block.oreLapis.blockID, 0);
							}
						}

					}
				}
			}
		}
	}
}
/**
 * Redstone ore expansion helper method
 * @param world
 * @param currentScanningChunk
 * @param size
 */
public void expandRedstone(World world, Chunk currentScanningChunk, int size)
{
	for(int i = 0; i < size; i++)
	{
		for(int x = 0; x < 15; x++)
		{
			for(int y = 0; y < 255; y++)
			{
				for(int z = 0; z < 15; z++)
				{
					if(world.blockExists(x, y, z))
					{
						if(currentScanningChunk.getBlockID(x, y, z) == Block.oreRedstone.blockID)
						{
							Random rand = new Random();
							int expandX = rand.nextInt(3)-1;
							int expandY = rand.nextInt(3)-1;
							int expandZ = rand.nextInt(3)-1;
							System.out.println(x*16 + " " + y + " " + z*16);
							if(currentScanningChunk.getBlockID(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ)) != 0)
							{
								currentScanningChunk.setBlockIDWithMetadata(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ), Block.oreRedstone.blockID, 0);
							}
						}
						if(currentScanningChunk.getBlockID(x, y, z) == Block.oreRedstoneGlowing.blockID)
						{
							Random rand = new Random();
							int expandX = rand.nextInt(3)-1;
							int expandY = rand.nextInt(3)-1;
							int expandZ = rand.nextInt(3)-1;
							System.out.println(x*16 + " " + y + " " + z*16);
							if(currentScanningChunk.getBlockID(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ)) != 0)
							{
								currentScanningChunk.setBlockIDWithMetadata(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ), Block.oreRedstone.blockID, 0);
							}
						}
					}
				}
			}
		}
	}
}
/**
 * Forest expansion helper method
 * @param world
 * @param currentScanningChunk
 * @param size
 */
public void expandForest(World world, Chunk currentScanningChunk, int size)
{
	for(int i = 0; i < size; i++)
	{
		for(int x = 0; x < 15; x++)
		{
			for(int y = 0; y < 250; y++)
			{
				for(int z = 0; z < 15; z++)
				{
					if(world.blockExists(x, y, z))
					{
						if(currentScanningChunk.getBlockID(x, y, z) == Block.leaves.blockID)
						{
							Random rand = new Random();
							int expandX = rand.nextInt(5) - 5;
							int expandY = rand.nextInt(5) - 5;
							int expandZ = rand.nextInt(5) - 5;
							System.out.println(expandY);
							if(currentScanningChunk.getBlockID(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ)) == Block.grass.blockID)
							{
								//if(currentScanningChunk.canBlockSeeTheSky(Math.abs(x + expandX), Math.abs(y + expandY), Math.abs(z + expandZ)))
								//{
									currentScanningChunk.setBlockIDWithMetadata(Math.abs(x + expandX), Math.abs(y + expandY + 1), Math.abs(z + expandZ), Block.sapling.blockID, 0);
									//}
									((BlockSapling)Block.sapling).growTree(world, Math.abs(x + expandX), Math.abs(y + expandY + 1), Math.abs(z + expandZ), rand);
							}

						}
					}
				}
			}
		}
	}
}
}

 

This works (as in the prints print), but nothing actually happens. 

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.