
charsmud
Members-
Posts
89 -
Joined
-
Last visited
Everything posted by charsmud
-
OK, thanks. I'll see if I can get this to work.
-
What do you mean by coordinates to your nameplate? Do you mean the location of the image relative to the mob?
-
What are the X, Y, and Z coordinates? Are those coordinates in the world?
-
NullPointerException on MinecraftServer crashing game
charsmud replied to charsmud's topic in Modder Support
It happens with I load a world. I tried changing the line to this: But I got the same crash. -
NullPointerException on MinecraftServer crashing game
charsmud replied to charsmud's topic in Modder Support
I know that ms is null, but I don't know why ms is null. It should be passed in through the Server Ticker, but for some reason, it is null. -
NullPointerException on MinecraftServer crashing game
charsmud replied to charsmud's topic in Modder Support
This is line 129: File beginningOfWorld = new File(minecraft.getMinecraftDir() + "/mods/TimeMod/present/" + ms.getWorldName()); I'm fairly confident it's because ms is null, but I have no idea how to fix it. I tried if(ms != null) but that just crashed. -
I am trying to move my client ticker over to a server ticker, as all my code was only being executed by the client. However, I am getting a nullPointerException on a MinecraftServer variable inside of my server ticker. Here's the code and error: And the error report: Any ideas?
-
How would I fix this? I have tried both WorldClient and World to no avail.... do I need a separate ticker for the server?
-
Hello! I am trying to spawn some mobs inside of my TickerClient. I have spawned entities using items before, but for some reason, I cannot get the mobs to spawn! At first, I thought it was because I was using WorldClient and not World, but even after switching to World instead of WorldClient, it still didn't work. Here's the related code: private void onTickInGame(Minecraft mc) { mc.theWorld.getGameRules().setOrCreateGameRule("doMobSpawning", "false"); File allEntityData = new File(mc.getMinecraftDir() + "/mods/TimeMod/past/EntityLocations/" + FMLClientHandler.instance().getServer().getWorldName() + "/" + TimeTraveler.vars.getPastTime() + ".epd"); try { BufferedReader reader = new BufferedReader(new FileReader(allEntityData)); String line; while (((line = reader.readLine()) != null) && nextSet) { if(line.equals("====================")) { nextSet = false; } else { String[] entityData = line.split(","); String entityName = entityData[0]; int entityX = Integer.parseInt(entityData[1]); int entityY = Integer.parseInt(entityData[2]); int entityZ = Integer.parseInt(entityData[3]); //System.out.println(entityName + " " + entityX + " " + entityY + " " + entityZ); Entity pastEntity = EntityList.createEntityByName(entityName, mc.thePlayer.worldObj); if(pastEntity != null) { PathEntity path = ((EntityLiving)pastEntity).getNavigator().getPath(); if(pastEntity != null) { pastEntity.posX = (double)entityX; pastEntity.posY = (double)entityY; pastEntity.posZ = (double)entityZ; System.out.println(pastEntity); mc.thePlayer.worldObj.spawnEntityInWorld(pastEntity); } } else { EntityPlayerPast pastPlayer = new EntityPlayerPast(mc.thePlayer.worldObj); pastPlayer.posX = (double)entityX; pastPlayer.posY = (double)entityY; pastPlayer.posZ = (double)entityZ; System.out.println(pastPlayer); mc.thePlayer.worldObj.spawnEntityInWorld(pastPlayer); } //path = ((EntityLiving)pastEntity).getNavigator().getPathToXYZ((double)entityX, (double)entityY, (double)entityZ); //((EntityLiving)pastEntity).getNavigator().setPath(path, 1.0F); //((EntityLiving)pastEntity).getNavigator().tryMoveToXYZ((double)entityX, (double)entityY, (double)entityZ, 0.5F); } System.out.println(nextSet); } reader.close(); } catch (IOException e) { e.printStackTrace(); } }
-
RenderLivingEvent doesn't seem to be what I want, or I might just not be understanding it. I found this method inside of RenderLiving: /** * Draws the debug or playername text above a living */ protected void renderLivingLabel(EntityLiving par1EntityLiving, String par2Str, double par3, double par5, double par7, int par9) { double d3 = par1EntityLiving.getDistanceSqToEntity(this.renderManager.livingPlayer); if (d3 <= (double)(par9 * par9)) { FontRenderer fontrenderer = this.getFontRendererFromRenderManager(); float f = 1.6F; float f1 = 0.016666668F * f; GL11.glPushMatrix(); GL11.glTranslatef((float)par3 + 0.0F, (float)par5 + par1EntityLiving.height + 0.5F, (float)par7); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GL11.glScalef(-f1, -f1, f1); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Tessellator tessellator = Tessellator.instance; byte b0 = 0; if (par2Str.equals("deadmau5")) { b0 = -10; } GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int j = fontrenderer.getStringWidth(par2Str) / 2; tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); tessellator.addVertex((double)(-j - 1), (double)(-1 + b0), 0.0D); tessellator.addVertex((double)(-j - 1), (double)(8 + b0), 0.0D); tessellator.addVertex((double)(j + 1), (double)(8 + b0), 0.0D); tessellator.addVertex((double)(j + 1), (double)(-1 + b0), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); fontrenderer.drawString(par2Str, -fontrenderer.getStringWidth(par2Str) / 2, b0, 553648127); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); fontrenderer.drawString(par2Str, -fontrenderer.getStringWidth(par2Str) / 2, b0, -1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } } This seems to be how names are rendered above a mob. Is this correct, and how can I adapt it to work with images?
-
Hello! I need to be able to display text or an image over a mob. Is there a way to do this? Text most likely won't be as much of an issue, but I have absolutely no idea of how to render an image over a mob like a nameplate.
-
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.
-
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.
-
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?