@Override public IMessage onMessage(MessageGlassJarUpdateStats message, MessageContext ctx) { ItemStack stack = message.stack; BlockPos pos = message.pos; WorldClient world = Minecraft.getMinecraft().world; if (world.isBlockLoaded(pos) && world.getBlockState(pos).getBlock().hasTileEntity(world.getBlockState(pos))) { TileEntity te = world.getTileEntity(pos); if (te instanceof TileFaerieHome) { IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); if (handler != null) { handler.insertItem(0, stack, false); } } } return null; }
@Override public MethodTransformer[] getMethodTransformers() { MethodTransformer loadWorldTransformer = new MethodTransformer() { public String getMethodName() {return CoreLoader.isObfuscated ? "a" : "loadWorld";} public String getDescName() {return "(L" + (CoreLoader.isObfuscated ? "bnq" : Type.getInternalName(WorldClient.class)) + ";Ljava/lang/String;)V";} public void transform(ClassNode classNode, MethodNode method, boolean obfuscated) { CLTLog.info("Found method: " + method.name + " " + method.desc); CLTLog.info("begining at start of method " + getMethodName()); //TransformerUtil.onWorldLoad(WorldClient worldClientIn) InsnList toInsert = new InsnList(); toInsert.add(new VarInsnNode(ALOAD, 1)); //worldClientIn toInsert.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(TransformerUtil.class), "onWorldLoad", "(L" + Type.getInternalName(WorldClient.class) + ";)V", false)); method.instructions.insertBefore(method.instructions.getFirst(), toInsert); } }; return new MethodTransformer[] {loadWorldTransformer}; }
/** * Registers some server properties (gametype,hardcore-mode,terraintype,difficulty,player limit), creates a new * WorldClient and sets the player initial dimension */ public void handleJoinGame(S01PacketJoinGame packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.playerController = new PlayerControllerMP(this.gameController, this); this.clientWorldController = new WorldClient(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(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()))); }
/** * Invoked when disconnecting, the parameter is a ChatComponent describing the reason for termination */ public void onDisconnect(IChatComponent reason) { this.gameController.loadWorld((WorldClient)null); if (this.guiScreenServer != null) { if (this.guiScreenServer instanceof GuiScreenRealmsProxy) { this.gameController.displayGuiScreen((new DisconnectedRealmsScreen(((GuiScreenRealmsProxy)this.guiScreenServer).func_154321_a(), "disconnect.lost", reason)).getProxy()); } else { this.gameController.displayGuiScreen(new GuiDisconnected(this.guiScreenServer, "disconnect.lost", reason)); } } else { this.gameController.displayGuiScreen(new GuiDisconnected(new GuiMultiplayer(new GuiMainMenu()), "disconnect.lost", reason)); } }
public void handleRespawn(S07PacketRespawn packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (packetIn.getDimensionID() != this.gameController.thePlayer.dimension) { this.doneLoadingTerrain = false; Scoreboard scoreboard = this.clientWorldController.getScoreboard(); this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, this.gameController.theWorld.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), this.gameController.mcProfiler); this.clientWorldController.setWorldScoreboard(scoreboard); this.gameController.loadWorld(this.clientWorldController); this.gameController.thePlayer.dimension = packetIn.getDimensionID(); this.gameController.displayGuiScreen(new GuiDownloadTerrain(this)); } this.gameController.setDimensionAndSpawnPlayer(packetIn.getDimensionID()); this.gameController.playerController.setGameType(packetIn.getGameType()); }
/** * set null to clear */ public void setWorldAndLoadRenderers(WorldClient worldClientIn) { if (this.theWorld != null) { this.theWorld.removeWorldAccess(this); } this.frustumUpdatePosX = Double.MIN_VALUE; this.frustumUpdatePosY = Double.MIN_VALUE; this.frustumUpdatePosZ = Double.MIN_VALUE; this.frustumUpdatePosChunkX = Integer.MIN_VALUE; this.frustumUpdatePosChunkY = Integer.MIN_VALUE; this.frustumUpdatePosChunkZ = Integer.MIN_VALUE; this.renderManager.set(worldClientIn); this.theWorld = worldClientIn; if (worldClientIn != null) { worldClientIn.addWorldAccess(this); this.loadRenderers(); } }
public void freeMemory() { try { memoryReserve = new byte[0]; this.renderGlobal.deleteAllDisplayLists(); } catch (Throwable var3) { ; } try { System.gc(); this.loadWorld((WorldClient)null); } catch (Throwable var2) { ; } System.gc(); }
public static Vec3 getWorldFogColor(Vec3 p_getWorldFogColor_0_, WorldClient p_getWorldFogColor_1_, Entity p_getWorldFogColor_2_, float p_getWorldFogColor_3_) { int i = p_getWorldFogColor_1_.provider.getDimensionId(); switch (i) { case -1: p_getWorldFogColor_0_ = getFogColorNether(p_getWorldFogColor_0_); break; case 0: Minecraft minecraft = Minecraft.getMinecraft(); p_getWorldFogColor_0_ = getFogColor(p_getWorldFogColor_0_, minecraft.theWorld, p_getWorldFogColor_2_.posX, p_getWorldFogColor_2_.posY + 1.0D, p_getWorldFogColor_2_.posZ); break; case 1: p_getWorldFogColor_0_ = getFogColorEnd(p_getWorldFogColor_0_); } return p_getWorldFogColor_0_; }
public static Vec3 getWorldSkyColor(Vec3 p_getWorldSkyColor_0_, WorldClient p_getWorldSkyColor_1_, Entity p_getWorldSkyColor_2_, float p_getWorldSkyColor_3_) { int i = p_getWorldSkyColor_1_.provider.getDimensionId(); switch (i) { case 0: Minecraft minecraft = Minecraft.getMinecraft(); p_getWorldSkyColor_0_ = getSkyColor(p_getWorldSkyColor_0_, minecraft.theWorld, p_getWorldSkyColor_2_.posX, p_getWorldSkyColor_2_.posY + 1.0D, p_getWorldSkyColor_2_.posZ); break; case 1: p_getWorldSkyColor_0_ = getSkyColorEnd(p_getWorldSkyColor_0_); } return p_getWorldSkyColor_0_; }
/** * Registers some server properties * (gametype,hardcore-mode,terraintype,difficulty,player limit), creates a new * WorldClient and sets the player initial dimension */ public void handleJoinGame(S01PacketJoinGame packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.playerController = new PlayerControllerMP(this.gameController, this); this.clientWorldController = new WorldClient(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(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()))); }
/** * Invoked when disconnecting, the parameter is a ChatComponent describing the * reason for termination */ public void onDisconnect(IChatComponent reason) { this.gameController.loadWorld((WorldClient) null); if (this.guiScreenServer != null) { if (this.guiScreenServer instanceof GuiScreenRealmsProxy) { this.gameController.displayGuiScreen( (new DisconnectedRealmsScreen(((GuiScreenRealmsProxy) this.guiScreenServer).func_154321_a(), "disconnect.lost", reason)).getProxy()); } else { this.gameController .displayGuiScreen(new GuiDisconnected(this.guiScreenServer, "disconnect.lost", reason)); } } else { this.gameController.displayGuiScreen( new GuiDisconnected(new GuiMultiplayer(new GuiMainMenu()), "disconnect.lost", reason)); } }
/** * Shuts down the minecraft applet by stopping the resource downloads, and * clearing up GL stuff; called when the application (or web page) is exited. */ public void shutdownMinecraftApplet() { try { this.stream.shutdownStream(); logger.info("Stopping!"); Client.getClient().onDisable(); try { this.loadWorld((WorldClient) null); } catch (Throwable var5) { ; } this.mcSoundHandler.unloadSounds(); } finally { Display.destroy(); if (!this.hasCrashed) { System.exit(0); } } System.gc(); }
public void freeMemory() { try { memoryReserve = new byte[0]; this.renderGlobal.deleteAllDisplayLists(); } catch (Throwable var3) { ; } try { System.gc(); this.loadWorld((WorldClient) null); } catch (Throwable var2) { ; } System.gc(); }
@Override @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { for(int i = 0; i <= Math.min(state.getValue(State.POWER), 8); i++) { if(rand.nextFloat() < 0.2F) { Vector3 vec = Vector3.getRandomVec(0.15F); vec.add(BB.getCenter()); vec.add(pos.getX(), pos.getY(), pos.getZ()); ParticleUtil.spawnChargedIce(world, vec, Vector3.ImmutableVector3.NULL, 0xFFFFFF, 45, 0.45F * rand.nextFloat()); } } if(state.getValue(State.POWER) > 0 && world.rand.nextBoolean()) { for(int i = 0; i < 1 + world.rand.nextInt(3); i++) { Vector3 from = Vector3.create(pos).add(0.5D); Vector3 to = Vector3.create(0, 1, 0) .rotate(EnumFacing.Axis.X, world.rand.nextFloat() * 360) .rotate(EnumFacing.Axis.Y, world.rand.nextFloat() * 360) .rotate(EnumFacing.Axis.Z, world.rand.nextFloat() * 360) .add(from); ParticleUtil.spawnBolt(world, from, to, 4, 0.25F, 0x5194FF, true, true); } ((WorldClient) world).playSound(pos, SolarSounds.SPARK, SoundCategory.BLOCKS, 0.05F, 1F, false); } }
/** * Registers some server properties (gametype,hardcore-mode,terraintype,difficulty,player limit), creates a new * WorldClient and sets the player initial dimension */ public void handleJoinGame(SPacketJoinGame packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.playerController = new PlayerControllerMP(this.gameController, this); this.clientWorldController = new WorldClient(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.player.dimension = packetIn.getDimension(); this.gameController.displayGuiScreen(new GuiDownloadTerrain(this)); this.gameController.player.setEntityId(packetIn.getPlayerId()); this.currentServerMaxPlayers = packetIn.getMaxPlayers(); this.gameController.player.setReducedDebug(packetIn.isReducedDebugInfo()); this.gameController.playerController.setGameType(packetIn.getGameType()); this.gameController.gameSettings.sendSettingsToServer(); this.netManager.sendPacket(new CPacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName()))); }
/** * Invoked when disconnecting, the parameter is a ChatComponent describing the reason for termination */ public void onDisconnect(ITextComponent reason) { this.gameController.loadWorld((WorldClient)null); if (this.guiScreenServer != null) { if (this.guiScreenServer instanceof GuiScreenRealmsProxy) { this.gameController.displayGuiScreen((new DisconnectedRealmsScreen(((GuiScreenRealmsProxy)this.guiScreenServer).getProxy(), "disconnect.lost", reason)).getProxy()); } else { this.gameController.displayGuiScreen(new GuiDisconnected(this.guiScreenServer, "disconnect.lost", reason)); } } else { this.gameController.displayGuiScreen(new GuiDisconnected(new GuiMultiplayer(new GuiMainMenu()), "disconnect.lost", reason)); } }
public void handleRespawn(SPacketRespawn packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (packetIn.getDimensionID() != this.gameController.player.dimension) { this.doneLoadingTerrain = false; Scoreboard scoreboard = this.clientWorldController.getScoreboard(); this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, this.gameController.world.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), this.gameController.mcProfiler); this.clientWorldController.setWorldScoreboard(scoreboard); this.gameController.loadWorld(this.clientWorldController); this.gameController.player.dimension = packetIn.getDimensionID(); this.gameController.displayGuiScreen(new GuiDownloadTerrain(this)); } this.gameController.setDimensionAndSpawnPlayer(packetIn.getDimensionID()); this.gameController.playerController.setGameType(packetIn.getGameType()); }
@Override public MethodTransformer[] getMethodTransformers() { MethodTransformer transformLoadWorld = new MethodTransformer() { @Override public MethodName getName() { return Names.Minecraft_loadWorld; } @Override public void transform(ClassNode classNode, MethodNode method, boolean obfuscated) { CLTLog.info("Found method: " + method.name + " " + method.desc); CLTLog.info("begining at start of method " + getName().all()); InsnList toInsert = new InsnList(); toInsert.add(new VarInsnNode(ALOAD, 1)); //worldClientIn toInsert.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(RenderUtil.class), "onWorldLoad", "(L" + Type.getInternalName(WorldClient.class) + ";)V", false)); method.instructions.insertBefore(method.instructions.getFirst(), toInsert); } }; return new MethodTransformer[] {transformLoadWorld}; }
public void confirmClicked(boolean result, int id) { if (result) { if (this.mc.world != null) { this.mc.world.sendQuittingDisconnectingPacket(); } this.mc.loadWorld((WorldClient)null); this.mc.displayGuiScreen(new GuiMainMenu()); } else { this.mc.player.respawnPlayer(); this.mc.displayGuiScreen((GuiScreen)null); } }
private void processMessage(MessageBiomeChange message, MessageContext ctx, WorldClient world) { Biome targetBiome = Biome.getBiomeForId(message.biomeID); if(targetBiome == null) return; byte[] currentArray; for(byte nX = -5; nX <= 5; nX++) { for(byte nZ = -5; nZ <= 5; nZ++) { Chunk c = world.getChunkFromBlockCoords(new BlockPos(message.changeCenter.getX() + nX*16, 0, message.changeCenter.getZ() + nZ*16)); currentArray = c.getBiomeArray(); for(int n = 0; n < currentArray.length; n++) { currentArray[n] = (byte) Biome.getIdForBiome(targetBiome); } c.setBiomeArray(currentArray); c.setModified(true); } } }
/** * Registers some server properties (gametype,hardcore-mode,terraintype,difficulty,player limit), creates a new * WorldClient and sets the player initial dimension */ public void handleJoinGame(SPacketJoinGame packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.playerController = new PlayerControllerMP(this.gameController, this); this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.get(getNetworkManager()).getOverrideDimension(packetIn), 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(this)); this.gameController.thePlayer.setEntityId(packetIn.getPlayerId()); this.currentServerMaxPlayers = packetIn.getMaxPlayers(); this.gameController.thePlayer.setReducedDebug(packetIn.isReducedDebugInfo()); this.gameController.playerController.setGameType(packetIn.getGameType()); this.gameController.gameSettings.sendSettingsToServer(); this.netManager.sendPacket(new CPacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName()))); }
public void handleRespawn(SPacketRespawn packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (packetIn.getDimensionID() != this.gameController.thePlayer.dimension) { this.doneLoadingTerrain = false; Scoreboard scoreboard = this.clientWorldController.getScoreboard(); this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, this.gameController.theWorld.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), this.gameController.mcProfiler); this.clientWorldController.setWorldScoreboard(scoreboard); this.gameController.loadWorld(this.clientWorldController); this.gameController.thePlayer.dimension = packetIn.getDimensionID(); this.gameController.displayGuiScreen(new GuiDownloadTerrain(this)); } this.gameController.setDimensionAndSpawnPlayer(packetIn.getDimensionID()); this.gameController.playerController.setGameType(packetIn.getGameType()); }
@Inject(method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", at = @At("HEAD")) private void loadWorld(@Nullable WorldClient worldClientIn, String loadingMessage, CallbackInfo ci) { // If the world is null, then it must be unloading if (worldClientIn != null) ClientAPI.EVENT_BUS.post(new WorldEvent.Load(worldClientIn)); else ClientAPI.EVENT_BUS.post(new WorldEvent.Unload()); }