private void redrawWhenSettingsChange() { IResourceManagerReloadListener redrawFlats = new IResourceManagerReloadListener() { @Override public void onResourceManagerReload(IResourceManager resourceManager) { if (mc.theWorld == null) return; IChunkProvider cp = mc.theWorld.getChunkProvider(); if (cp instanceof ChunkProviderClient) { ChunkProviderClient cpc = (ChunkProviderClient) cp; for (Chunk chunk : cpc.chunkListing) { FlatChunkLayer fcl = ((IExtraChunkData) chunk).getFlatLayer(); fcl.renderInfo.markDirty(null); } } } }; ((SimpleReloadableResourceManager) mc.getResourceManager()).registerReloadListener(redrawFlats); }
public HookedClientWorld(WorldClient originalWorld) throws IllegalAccessException { super(InjectionHandler.readFieldOfType(originalWorld, NetHandlerPlayClient.class), new WorldSettings(originalWorld.getWorldInfo()), originalWorld.provider.getDimension(), originalWorld.getDifficulty(), originalWorld.profiler); HookedChunkProviderClient chunkProvider = new HookedChunkProviderClient(this); // replace the chunk provider with our own! InjectionHandler.writeFieldOfType(this, chunkProvider, ChunkProviderClient.class); InjectionHandler.writeFieldOfType(this, chunkProvider, IChunkProvider.class); SetupWorldProviderProxy(); }
@Override protected IChunkProvider createChunkProvider() { if(this.isRemote) return new ChunkProviderClient(this); else return null; }
public static void loadWorld() { worldName = ""; // The new (multi-)world name is unknown at the moment wc = mc.theWorld; tp = mc.thePlayer; windowContainer = tp.openContainer; // Is this a different server? INetworkManager newNM = tp.sendQueue.getNetManager(); if( nm != newNM ) { // Different server, different world! chatDebug( "onWorldLoad: different server!" ); nm = newNM; loadBaseProps(); if( baseProps.getProperty( "AutoStart" ).equals( "true" ) ) start(); else startOnChange = false; } else { // Same server, different world! chatDebug( "onWorldLoad: same server!" ); if( startOnChange ) start(); } // Hacking the LongHashMap to keep a list of loaded chunks visible // Using reflexion is not possible because the LongHashMapEntry class is private Reflexion.StolenField longHashMapField = Reflexion.stealField( ChunkProviderClient.class, LongHashMap.class ); LongHashMap lhm = (LongHashMap) longHashMapField.get(wc.getChunkProvider()); longHashMapField.set(wc.getChunkProvider(), new WDLLongHashMapWrapper(lhm)); }
/** Calls saveChunk for all currently loaded chunks */ public static void saveChunks( ) { chatDebug( "Saving chunks..."); WDLLongHashMapWrapper chunkMapping = (WDLLongHashMapWrapper) Reflexion.stealField( ChunkProviderClient.class, LongHashMap.class ).get(wc.getChunkProvider()); //LongHashMapEntry[] hashArray = (LongHashMapEntry[]) Reflexion.stealField( LongHashMap.class, LongHashMapEntry[].class ).get(chunkMapping); WDLSaveProgressReporter progressReporter = new WDLSaveProgressReporter(); progressReporter.start(); /*// Now that we have the HashMap, lets start iterating over it: for( LongHashMapEntry lhme : hashArray ) { while( lhme != null ) { Chunk c = (Chunk) lhme.getValue();*/ for (Chunk c:chunkMapping.getChunks()) { if( c != null /*&& c.isModified*/ ) // only save filled chunks { saveChunk( c ); } //else // chatMsg( "Didn't save chunk " + c.xPosition + " " + c.zPosition + " because it is null!"); /* lhme = lhme.nextEntry; // Get next Entry in this linked list } }*/ } try { ThreadedFileIOBase.threadedIOInstance.waitForFinish(); } catch(Exception e) { chatMsg( "Threw exception waiting for asynchronous IO to finish. Hmmm."); } chatDebug( "Chunk data saved."); }
protected IChunkProvider func_72970_h() { this.field_73033_b = new ChunkProviderClient(this); return this.field_73033_b; }
public HookedClientWorld(NetHandlerPlayClient netHandler, WorldSettings settings, int dimension, EnumDifficulty difficulty, Profiler profilerIn) throws IllegalAccessException { super(netHandler, settings, dimension, difficulty, profilerIn); HookedChunkProviderClient chunkProvider = new HookedChunkProviderClient(this); // replace the chunk provider with our own! InjectionHandler.writeFieldOfType(this, chunkProvider, ChunkProviderClient.class); InjectionHandler.writeFieldOfType(this, chunkProvider, IChunkProvider.class); SetupWorldProviderProxy(); }