net.minecraft.client.multiplayer.WorldClient Java Examples
The following examples show how to use
net.minecraft.client.multiplayer.WorldClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayerChunkViewer.java From ChickenChunks with MIT License | 6 votes |
public void loadDimension(PacketCustom packet, WorldClient world) { synchronized(dimensionChunks) { DimensionChunkInfo dimInfo = new DimensionChunkInfo(packet.readInt()); int numChunks = packet.readInt(); for(int i = 0; i < numChunks; i++) dimInfo.allchunks.add(new ChunkCoordIntPair(packet.readInt(), packet.readInt())); int numTickets = packet.readInt(); for(int i = 0; i < numTickets; i++) { TicketInfo ticket = new TicketInfo(packet, world); dimInfo.tickets.put(ticket.ID, ticket); } dimensionChunks.put(dimInfo.dimension, dimInfo); } }
Example #2
Source File: SchematicVerifier.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
public void startVerification(WorldClient worldClient, WorldSchematic worldSchematic, SchematicPlacement schematicPlacement, ICompletionListener completionListener) { this.reset(); this.worldClient = worldClient; this.worldSchematic = worldSchematic; this.schematicPlacement = schematicPlacement; this.setCompletionListener(completionListener); this.requiredChunks.addAll(schematicPlacement.getTouchedChunks()); this.totalRequiredChunks = this.requiredChunks.size(); this.verificationStarted = true; TaskScheduler.getInstanceClient().scheduleTask(this, 10); InfoHud.getInstance().addInfoHudRenderer(this, true); ACTIVE_VERIFIERS.add(this); this.verificationActive = true; this.updateRequiredChunksStringList(); }
Example #3
Source File: WorldUtils.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
public static void loadChunksClientWorld(WorldClient world, BlockPos origin, Vec3i areaSize) { BlockPos posEnd = origin.add(PositionUtils.getRelativeEndPositionFromAreaSize(areaSize)); BlockPos posMin = fi.dy.masa.malilib.util.PositionUtils.getMinCorner(origin, posEnd); BlockPos posMax = fi.dy.masa.malilib.util.PositionUtils.getMaxCorner(origin, posEnd); final int cxMin = posMin.getX() >> 4; final int czMin = posMin.getZ() >> 4; final int cxMax = posMax.getX() >> 4; final int czMax = posMax.getZ() >> 4; for (int cz = czMin; cz <= czMax; ++cz) { for (int cx = cxMin; cx <= cxMax; ++cx) { world.getChunkProvider().loadChunk(cx, cz); } } }
Example #4
Source File: TaskBase.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
protected boolean areSurroundingChunksLoaded(ChunkPos pos, WorldClient world, int radius) { if (radius <= 0) { return world.getChunkProvider().isChunkGeneratedAt(pos.x, pos.z); } int chunkX = pos.x; int chunkZ = pos.z; for (int cx = chunkX - radius; cx <= chunkX + radius; ++cx) { for (int cz = chunkZ - radius; cz <= chunkZ + radius; ++cz) { if (world.getChunkProvider().isChunkGeneratedAt(cx, cz) == false) { return false; } } } return true; }
Example #5
Source File: HamsterCompanion.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
@InvokeEvent public void onTick(TickEvent e) { WorldClient theWorld = Minecraft.getMinecraft().theWorld; if (theWorld == null) return; toAdd.forEach(this::spawnHamster); toAdd.clear(); Iterator<Map.Entry<UUID, EntityHamster>> ite = hamsters.entrySet().iterator(); while (ite.hasNext()) { Map.Entry<UUID, EntityHamster> next = ite.next(); if (!worldHasEntityWithUUID(theWorld, next.getKey())) { theWorld.unloadEntities(Collections.singletonList(next.getValue())); ite.remove(); } } }
Example #6
Source File: ProxyWorldManager.java From LookingGlass with GNU General Public License v3.0 | 6 votes |
public static WorldView createWorldView(int dimid, ChunkCoordinates spawn, int width, int height) { if (ModConfigs.disabled) return null; if (!DimensionManager.isDimensionRegistered(dimid)) return null; WorldClient proxyworld = ProxyWorldManager.getProxyworld(dimid); if (proxyworld == null) return null; Collection<WorldView> worldviews = worldviewsets.get(dimid); if (worldviews == null) return null; WorldView view = new WorldView(proxyworld, spawn, width, height); // Initialize the view rendering system Minecraft mc = Minecraft.getMinecraft(); EntityLivingBase backup = mc.renderViewEntity; mc.renderViewEntity = view.camera; view.getRenderGlobal().setWorldAndLoadRenderers(proxyworld); mc.renderViewEntity = backup; // Inform the server of the new view LookingGlassPacketManager.bus.sendToServer(PacketCreateView.createPacket(view)); worldviews.add(view); return view; }
Example #7
Source File: ClientStateMachine.java From malmo with MIT License | 6 votes |
@Override protected void execute() { totalTicks = 0; if (Minecraft.getMinecraft().world != null) { // If the Minecraft server isn't paused at this point, // then the following line will cause the server thread to exit... Minecraft.getMinecraft().world.sendQuittingDisconnectingPacket(); // ...in which case the next line will hang. Minecraft.getMinecraft().loadWorld((WorldClient) null); // Must display the GUI or Minecraft will attempt to access a non-existent player in the client tick. Minecraft.getMinecraft().displayGuiScreen(new GuiMainMenu()); // Allow shutdown messages to flow through. try { Thread.sleep(10000); } catch (InterruptedException ie) { } } }
Example #8
Source File: MixinNetHandlerPlayClient.java From LiquidBounce with GNU General Public License v3.0 | 6 votes |
@Inject(method = "handleJoinGame", at = @At("HEAD"), cancellable = true) private void handleJoinGameWithAntiForge(S01PacketJoinGame packetIn, final CallbackInfo callbackInfo) { if(!AntiForge.enabled || !AntiForge.blockFML || Minecraft.getMinecraft().isIntegratedServerRunning()) return; PacketThreadUtil.checkThreadAndEnqueue(packetIn, (NetHandlerPlayClient) (Object) this, gameController); this.gameController.playerController = new PlayerControllerMP(gameController, (NetHandlerPlayClient) (Object) this); this.clientWorldController = new WorldClient((NetHandlerPlayClient) (Object) this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), packetIn.getDimension(), packetIn.getDifficulty(), this.gameController.mcProfiler); this.gameController.gameSettings.difficulty = packetIn.getDifficulty(); this.gameController.loadWorld(this.clientWorldController); this.gameController.thePlayer.dimension = packetIn.getDimension(); this.gameController.displayGuiScreen(new GuiDownloadTerrain((NetHandlerPlayClient) (Object) this)); this.gameController.thePlayer.setEntityId(packetIn.getEntityId()); this.currentServerMaxPlayers = packetIn.getMaxPlayers(); this.gameController.thePlayer.setReducedDebug(packetIn.isReducedDebugInfo()); this.gameController.playerController.setGameType(packetIn.getGameType()); this.gameController.gameSettings.sendSettingsToServer(); this.netManager.sendPacket(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName()))); callbackInfo.cancel(); }
Example #9
Source File: BufferSpeed.java From LiquidBounce with GNU General Public License v3.0 | 6 votes |
private boolean isNearBlock() { final EntityPlayerSP thePlayer = mc.thePlayer; final WorldClient theWorld = mc.theWorld; final List<BlockPos> blocks = new ArrayList<>(); blocks.add(new BlockPos(thePlayer.posX, thePlayer.posY + 1, thePlayer.posZ - 0.7)); blocks.add(new BlockPos(thePlayer.posX + 0.7, thePlayer.posY + 1, thePlayer.posZ)); blocks.add(new BlockPos(thePlayer.posX, thePlayer.posY + 1, thePlayer.posZ + 0.7)); blocks.add(new BlockPos(thePlayer.posX - 0.7, thePlayer.posY + 1, thePlayer.posZ)); for(final BlockPos blockPos : blocks) if((theWorld.getBlockState(blockPos).getBlock().getBlockBoundsMaxY() == theWorld.getBlockState(blockPos).getBlock().getBlockBoundsMinY() + 1 && !theWorld.getBlockState(blockPos).getBlock().isTranslucent() && theWorld.getBlockState(blockPos).getBlock() != Blocks.water && !(theWorld.getBlockState(blockPos).getBlock() instanceof BlockSlab)) || theWorld.getBlockState(blockPos).getBlock() == Blocks.barrier) return true; return false; }
Example #10
Source File: PlayerChunkViewer.java From ChickenChunks with MIT License | 6 votes |
public TicketInfo(PacketCustom packet, WorldClient world) { ID = packet.readInt(); modId = packet.readString(); if(packet.readBoolean()) player = packet.readString(); type = net.minecraftforge.common.ForgeChunkManager.Type.values()[packet.readUByte()]; if(type == net.minecraftforge.common.ForgeChunkManager.Type.ENTITY) entity = world.getEntityByID(packet.readInt()); int chunks = packet.readUShort(); chunkSet = new HashSet<ChunkCoordIntPair>(chunks); for(int i = 0; i < chunks; i++) { chunkSet.add(new ChunkCoordIntPair(packet.readInt(), packet.readInt())); } }
Example #11
Source File: MixinNetHandlerPlayClient.java From LiquidBounce with GNU General Public License v3.0 | 6 votes |
@Inject(method = "handleJoinGame", at = @At("HEAD"), cancellable = true) private void handleJoinGameWithAntiForge(S01PacketJoinGame packetIn, final CallbackInfo callbackInfo) { if(!AntiForge.enabled || !AntiForge.blockFML || Minecraft.getMinecraft().isIntegratedServerRunning()) return; PacketThreadUtil.checkThreadAndEnqueue(packetIn, (NetHandlerPlayClient) (Object) this, gameController); this.gameController.playerController = new PlayerControllerMP(gameController, (NetHandlerPlayClient) (Object) this); this.clientWorldController = new WorldClient((NetHandlerPlayClient) (Object) this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), packetIn.getDimension(), packetIn.getDifficulty(), this.gameController.mcProfiler); this.gameController.gameSettings.difficulty = packetIn.getDifficulty(); this.gameController.loadWorld(this.clientWorldController); this.gameController.thePlayer.dimension = packetIn.getDimension(); this.gameController.displayGuiScreen(new GuiDownloadTerrain((NetHandlerPlayClient) (Object) this)); this.gameController.thePlayer.setEntityId(packetIn.getEntityId()); this.currentServerMaxPlayers = packetIn.getMaxPlayers(); this.gameController.thePlayer.setReducedDebug(packetIn.isReducedDebugInfo()); this.gameController.playerController.setGameType(packetIn.getGameType()); this.gameController.gameSettings.sendSettingsToServer(); this.netManager.sendPacket(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName()))); callbackInfo.cancel(); }
Example #12
Source File: WorldView.java From LookingGlass with GNU General Public License v3.0 | 5 votes |
/** * This is a really complex bit. As we want to reuse the current client world when rendering, if possible, we need to handle when that world changes. We * could simply destroy all the views pointing to the existing proxy world, but that would be annoying to mods using the API. Instead, we replace our proxy * world with the new client world. This should only be called by LookingGlass, and only from the handling of the client world change detection. * @param world The new world */ public void replaceWorldObject(WorldClient world) { this.worldObj = world; this.camera.worldObj = world; this.effectRenderer.clearEffects(world); this.renderGlobal.setWorldAndLoadRenderers(world); }
Example #13
Source File: WorldLoadListener.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onWorldLoadPre(@Nullable WorldClient worldBefore, @Nullable WorldClient worldAfter, Minecraft mc) { // Save the settings before the integrated server gets shut down if (worldBefore != null) { boolean isDimensionChange = worldAfter != null; DataManager.save(isDimensionChange); } }
Example #14
Source File: WorldLoadListener.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onWorldLoadPost(@Nullable WorldClient worldBefore, @Nullable WorldClient worldAfter, Minecraft mc) { SchematicWorldHandler.recreateSchematicWorld(worldAfter == null); if (worldAfter != null) { boolean isDimensionChange = worldBefore != null; DataManager.load(isDimensionChange); } else { DataManager.clear(); } }
Example #15
Source File: MixinMinecraft.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@Inject(method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", at = @At("HEAD")) private void loadWorld(WorldClient p_loadWorld_1_, String p_loadWorld_2_, final CallbackInfo callbackInfo) { if (theWorld != null) { MiniMapRegister.INSTANCE.unloadAllChunks(); } LiquidBounce.eventManager.callEvent(new WorldEvent(p_loadWorld_1_)); }
Example #16
Source File: HyperiumMinecraft.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
public void loop(boolean inGameHasFocus, WorldClient theWorld, EntityPlayerSP thePlayer, RenderManager renderManager, Timer timer) { if (inGameHasFocus && theWorld != null) { HyperiumHandlers handlers = Hyperium.INSTANCE.getHandlers(); RenderPlayerEvent event = new RenderPlayerEvent(thePlayer, renderManager, renderManager.viewerPosZ, renderManager.viewerPosY, renderManager.viewerPosZ, timer.renderPartialTicks); if (handlers != null && Settings.SHOW_PART_1ST_PERSON) { handlers.getParticleAuraHandler().renderPlayer(event); } } }
Example #17
Source File: TaskPasteSchematicPerChunkBase.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
protected boolean canProcessChunk(ChunkPos pos, World worldSchematic, WorldClient worldClient) { if (worldSchematic.getChunkProvider().isChunkGeneratedAt(pos.x, pos.z) == false || DataManager.getSchematicPlacementManager().hasPendingRebuildFor(pos)) { return false; } // Chunk exists in the schematic world, and all the surrounding chunks are loaded in the client world, good to go return this.areSurroundingChunksLoaded(pos, worldClient, 1); }
Example #18
Source File: HamsterCompanion.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
public void spawnHamster(EntityPlayer player) { WorldClient theWorld = Minecraft.getMinecraft().theWorld; EntityHamster hamster = new EntityHamster(theWorld); hamster.setPosition(player.posX, player.posY, player.posZ); hamster.setOwnerId(player.getUniqueID().toString()); theWorld.spawnEntityInWorld(hamster); hamsters.put(player.getUniqueID(), hamster); }
Example #19
Source File: PurchaseApi.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
public UUID nameToUUID(String name) { UUID uuid = nameToUuid.get(name.toLowerCase()); if (uuid != null) return uuid; WorldClient theWorld = Minecraft.getMinecraft().theWorld; if (theWorld == null) return null; for (EntityPlayer playerEntity : theWorld.playerEntities) { if (playerEntity.getName().equalsIgnoreCase(name) || EnumChatFormatting.getTextWithoutFormattingCodes(playerEntity.getName()).equalsIgnoreCase(name)) { nameToUuid.put(name.toLowerCase(), playerEntity.getUniqueID()); return playerEntity.getUniqueID(); } } return null; }
Example #20
Source File: MessageBlockDisplayState.java From Production-Line with MIT License | 5 votes |
@Override @SideOnly(Side.CLIENT) protected IMessage handlerMessage(MessageBase message, MessageContext ctx) { WorldClient world = Minecraft.getMinecraft().world; BlockPos pos = BlockPos.fromLong(message.nbt.getLong("pos")); TileFacing tilePL = (TileFacing) world.getTileEntity(pos); if (tilePL != null) { tilePL.active = message.nbt.getBoolean("active"); tilePL.facing = EnumFacing.getFront(message.nbt.getShort("facing")); world.scheduleUpdate(pos, world.getBlockState(pos).getBlock(), 0); } return null; }
Example #21
Source File: QCraftProxyClient.java From qcraft-mod with Apache License 2.0 | 5 votes |
@Override public void travelToServer( LostLuggage.Address address ) { // Disconnect from current server Minecraft minecraft = Minecraft.getMinecraft(); minecraft.theWorld.sendQuittingDisconnectingPacket(); minecraft.loadWorld((WorldClient)null); minecraft.displayGuiScreen( new GuiTravelStandby( address ) ); }
Example #22
Source File: ProxyWorldManager.java From LookingGlass with GNU General Public License v3.0 | 5 votes |
private static void unloadProxyWorld(int dimId) { Collection<WorldView> set = worldviewsets.remove(dimId); if (set != null && set.size() > 0) LoggerUtils.warn("Unloading ProxyWorld with live views"); WorldClient proxyworld = proxyworlds.remove(dimId); WorldClient theWorld = Minecraft.getMinecraft().theWorld; if (theWorld != null && theWorld == proxyworld) return; if (proxyworld != null) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(proxyworld)); }
Example #23
Source File: WorldView.java From LookingGlass with GNU General Public License v3.0 | 5 votes |
public WorldView(WorldClient worldObj, ChunkCoordinates coords, int width, int height) { this.width = width; this.height = height; this.worldObj = worldObj; this.coords = coords; this.camera = new EntityCamera(worldObj, coords); this.camerawrapper = new ViewCameraImpl(camera); this.renderGlobal = new RenderGlobal(Minecraft.getMinecraft()); this.effectRenderer = new EffectRenderer(worldObj, Minecraft.getMinecraft().getTextureManager()); // Technically speaking, this is poor practice as it leaks a reference to the view before it's done constructing. this.fbo = FrameBufferContainer.createNewFramebuffer(this, width, height); }
Example #24
Source File: LookingGlassEventHandler.java From LookingGlass with GNU General Public License v3.0 | 5 votes |
@SideOnly(Side.CLIENT) @SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent event) { Minecraft mc = Minecraft.getMinecraft(); // If no client world we're not playing. Abort. if (mc.theWorld == null) return; // We don't want to tick twice per tick loop. Just once. We chose to tick at the start of the tick loop. if (event.phase != TickEvent.Phase.START) return; // Every now and then we want to check to see if there are frame buffers we could free if (++this.tickcounter % 200 == 0) ProxyWorldManager.detectFreedWorldViews(); // Handle whenever the client world has changed since we last looked if (mc.theWorld != previousWorld) { // We need to handle the removal of the old world. Particularly, the player will still be visible in it. // We may consider replacing the old client world with a new proxy world. if (previousWorld != null) previousWorld.removeAllEntities(); //TODO: This is hardly an ideal solution (It also doesn't seem to work well) previousWorld = mc.theWorld; // At this point we can safely assert that the client world has changed // We let our local world manager know that the client world changed. ProxyWorldManager.handleWorldChange(mc.theWorld); } // Tick loop for our own worlds. WorldClient worldBackup = mc.theWorld; for (WorldClient proxyworld : ProxyWorldManager.getProxyworlds()) { if (proxyworld.lastLightningBolt > 0) --proxyworld.lastLightningBolt; if (worldBackup == proxyworld) continue; // This prevents us from double ticking the client world. try { mc.theWorld = proxyworld; //TODO: relays for views (renderGlobal and effectRenderer) (See ProxyWorld.makeFireworks ln23) proxyworld.tick(); } catch (Exception e) { LoggerUtils.error("Client Proxy Dim had error while ticking: %s", e.getLocalizedMessage()); e.printStackTrace(printstream); } } mc.theWorld = worldBackup; }
Example #25
Source File: PacketWorldInfo.java From LookingGlass with GNU General Public License v3.0 | 5 votes |
@Override public void handle(ByteBuf in, EntityPlayer player) { int dimension = in.readInt(); int posX = in.readInt(); int posY = in.readInt(); int posZ = in.readInt(); int skylightSubtracted = in.readInt(); float thunderingStrength = in.readFloat(); float rainingStrength = in.readFloat(); long worldTime = in.readLong(); WorldClient proxyworld = ProxyWorldManager.getProxyworld(dimension); if (proxyworld == null) return; if (proxyworld.provider.dimensionId != dimension) return; ChunkCoordinates cc = new ChunkCoordinates(); cc.set(posX, posY, posZ); Collection<WorldView> views = ProxyWorldManager.getWorldViews(dimension); for (WorldView view : views) { view.updateWorldSpawn(cc); } proxyworld.setSpawnLocation(posX, posY, posZ); proxyworld.skylightSubtracted = skylightSubtracted; proxyworld.thunderingStrength = thunderingStrength; proxyworld.setRainStrength(rainingStrength); proxyworld.setWorldTime(worldTime); }
Example #26
Source File: PacketChunkInfo.java From LookingGlass with GNU General Public License v3.0 | 5 votes |
public void handle(EntityPlayer player, byte[] chunkData, int dim, int xPos, int zPos, boolean reqinit, short yPos, short yMSBPos) { WorldClient proxyworld = ProxyWorldManager.getProxyworld(dim); if (proxyworld == null) return; if (proxyworld.provider.dimensionId != dim) return; //TODO: Test to see if this first part is even necessary Chunk chunk = proxyworld.getChunkProvider().provideChunk(xPos, zPos); if (reqinit && (chunk == null || chunk.isEmpty())) { if (yPos == 0) { proxyworld.doPreChunk(xPos, zPos, false); return; } proxyworld.doPreChunk(xPos, zPos, true); } // End possible removal section proxyworld.invalidateBlockReceiveRegion(xPos << 4, 0, zPos << 4, (xPos << 4) + 15, 256, (zPos << 4) + 15); chunk = proxyworld.getChunkFromChunkCoords(xPos, zPos); if (reqinit && (chunk == null || chunk.isEmpty())) { proxyworld.doPreChunk(xPos, zPos, true); chunk = proxyworld.getChunkFromChunkCoords(xPos, zPos); } if (chunk != null) { chunk.fillChunk(chunkData, yPos, yMSBPos, reqinit); receivedChunk(proxyworld, xPos, zPos); if (!reqinit || !(proxyworld.provider instanceof WorldProviderSurface)) { chunk.resetRelightChecks(); } } }
Example #27
Source File: PacketChunkInfo.java From LookingGlass with GNU General Public License v3.0 | 5 votes |
public void receivedChunk(WorldClient worldObj, int cx, int cz) { worldObj.markBlockRangeForRenderUpdate(cx << 4, 0, cz << 4, (cx << 4) + 15, 256, (cz << 4) + 15); Chunk c = worldObj.getChunkFromChunkCoords(cx, cz); if (c == null || c.isEmpty()) return; for (WorldView activeview : ProxyWorldManager.getWorldViews(worldObj.provider.dimensionId)) { activeview.onChunkReceived(cx, cz); } int x = (cx << 4); int z = (cz << 4); for (int y = 0; y < worldObj.getActualHeight(); y += 16) { if (c.getAreLevelsEmpty(y, y)) continue; for (int x2 = 0; x2 < 16; ++x2) { for (int z2 = 0; z2 < 16; ++z2) { for (int y2 = 0; y2 < 16; ++y2) { int lx = x + x2; int ly = y + y2; int lz = z + z2; if (worldObj.getBlock(lx, ly, lz).hasTileEntity(worldObj.getBlockMetadata(lx, ly, lz))) { LookingGlassPacketManager.bus.sendToServer(PacketRequestTE.createPacket(lx, ly, lz, worldObj.provider.dimensionId)); } } } } } }
Example #28
Source File: PacketTileEntityNBT.java From LookingGlass with GNU General Public License v3.0 | 5 votes |
@Override public void handle(ByteBuf data, EntityPlayer player) { int dimension = data.readInt(); int xPos = data.readInt(); int yPos = data.readInt(); int zPos = data.readInt(); NBTTagCompound nbt = ByteBufUtils.readTag(data); WorldClient proxyworld = ProxyWorldManager.getProxyworld(dimension); if (proxyworld == null) return; if (proxyworld.provider.dimensionId != dimension) return; if (proxyworld.blockExists(xPos, yPos, zPos)) { TileEntity tileentity = proxyworld.getTileEntity(xPos, yPos, zPos); if (tileentity != null) { tileentity.readFromNBT(nbt); } else { //Create tile entity from data tileentity = TileEntity.createAndLoadEntity(nbt); if (tileentity != null) { proxyworld.addTileEntity(tileentity); } } proxyworld.markTileEntityChunkModified(xPos, yPos, zPos, tileentity); proxyworld.setTileEntity(xPos, yPos, zPos, tileentity); proxyworld.markBlockForUpdate(xPos, yPos, zPos); } }
Example #29
Source File: ProxyWorldManager.java From LookingGlass with GNU General Public License v3.0 | 5 votes |
/** * This is a complex bit. As we want to reuse the current client world when rendering, if possible, we need to handle when that world changes. We could * simply destroy all the views pointing to the existing proxy world, but that would be annoying to mods using the API. Instead, we replace our proxy world * with the new client world. This should only be called by LookingGlass, and only from the handling of the client world change detection. * @param world The new client world */ public static void handleWorldChange(WorldClient world) { if (ModConfigs.disabled) return; if (world == null) return; int dimid = world.provider.dimensionId; if (!proxyworlds.containsKey(dimid)) return; //BEST CASE! We don't have to do anything! proxyworlds.put(dimid, world); Collection<WorldView> worldviews = worldviewsets.get(dimid); for (WorldView view : worldviews) { // Handle the change on the view object view.replaceWorldObject(world); } }
Example #30
Source File: ProxyWorldManager.java From LookingGlass with GNU General Public License v3.0 | 5 votes |
public static synchronized WorldClient getProxyworld(int dimid) { if (ModConfigs.disabled) return null; WorldClient proxyworld = proxyworlds.get(dimid); if (proxyworld == null) { if (!DimensionManager.isDimensionRegistered(dimid)) return null; // We really don't want to be doing this during a render cycle if (Minecraft.getMinecraft().thePlayer instanceof EntityCamera) return null; //TODO: This check probably needs to be altered WorldClient theWorld = Minecraft.getMinecraft().theWorld; if (theWorld != null && theWorld.provider.dimensionId == dimid) proxyworld = theWorld; if (proxyworld == null) proxyworld = new ProxyWorld(dimid); proxyworlds.put(dimid, proxyworld); worldviewsets.put(dimid, Collections.newSetFromMap(new WeakHashMap<WorldView, Boolean>())); } return proxyworld; }