Jump to content

ImpTea

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by ImpTea

  1. Ah - where can I go for 1.12 support? And I'm not sure what you mean with your second point, I WANT it to be client side only.
  2. I am working on an extremely simple mod that checks new chunks that are loaded to see if they contain any of a particular set of blocks. It then outputs the results a text file. The mod is working exactly as intended in any single-player world that I load. However, it does not seem to work when I play on a server. It's an anarchy server where client-side hacks are allowed, so I'm not sure why my mod isn't working. Can anyone look over this and tell me where I'm messing up? I would have though that all the code I've written is entirely client-side. Here is the class file where all the action takes place: package com.imptea.basefinder; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import org.apache.commons.lang3.ArrayUtils; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockProperties; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class NewChunkScanner { // List of block types to look for public Block[] blockList = { Blocks.COAL_ORE, Blocks.IRON_ORE, Blocks.GRAVEL }; // Each time a chunk is loaded... @SubscribeEvent public void ChunkLoad(ChunkEvent.Load event) throws IOException { World world = event.getWorld(); Chunk chunk = event.getChunk(); // Grabs the lower X/Z corner of the newly loaded chunk for future use int chunk_x = chunk.getPos().getXStart(); int chunk_z = chunk.getPos().getZStart(); // Opens up the text file to append block coordinates BufferedWriter writer = new BufferedWriter(new FileWriter("C:\\Temp\\BlockCoords.txt", true)); // Scans blocks in new chunk, and looks for blocks that are in blockList (only // scans even coords for speed) beginChunkSearch: for (int x = 0; x < 16; x += 2) { for (int z = 0; z < 16; z += 2) { // Only scans from y=35 to the highest block at that X,Z coord for (int y = 35; y < chunk.getHeightValue(x, z); y += 2) { Block thisBlock = chunk.getBlockState(x, y, z).getBlock(); for (int i = 0; i < blockList.length; ++i) { //If we have a match... if (thisBlock == blockList[i]) { //...writes a report to the txt file writer.write("Chunk_" + Integer.toString(chunk_x / 16) + "_" + Integer.toString(chunk_z / 16) + ": " + thisBlock.toString().substring(16, thisBlock.toString().length() - 1) + ": " + Integer.toString(x + chunk_x) + " " + Integer.toString(y) + " " + Integer.toString(z + chunk_z) + "\n"); //...and skips on the the next chunk. break beginChunkSearch; } } } } } writer.close(); } } ...And here is the Main class, in case I've messed something up there: package com.imptea.basefinder; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import com.imptea.basefinder.proxy.CommonProxy; import com.imptea.basefinder.util.Reference; @Mod(modid = Reference.MOD_ID, name = Reference.NAME, version = Reference.VERSION, clientSideOnly = true) public class Main { @Instance public static Main instance; @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.COMMON_PROXY_CLASS) public static CommonProxy proxy; @EventHandler public static void PreInit(FMLPreInitializationEvent event) { MinecraftForge.EVENT_BUS.register(new NewChunkScanner()); } @EventHandler public static void init(FMLInitializationEvent event) throws IOException { } @EventHandler public static void PostInit(FMLPostInitializationEvent event) { } } So why can't this run on a server? Any help would be greatly appreciated.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.