Search in sources :

Example 1 with StatisticsManager

use of net.minecraft.stats.StatisticsManager in project upgrade-aquatic by team-abnormals.

the class RestfulnessEffect method performEffect.

@Override
public void performEffect(LivingEntity entity, int amplifier) {
    if (entity instanceof ServerPlayerEntity) {
        ServerPlayerEntity playerMP = (ServerPlayerEntity) entity;
        StatisticsManager statisticsManager = playerMP.getStats();
        statisticsManager.increment(playerMP, Stats.CUSTOM.get(Stats.TIME_SINCE_REST), -(24000 * (amplifier + 1)));
    } else if (entity instanceof PhantomEntity) {
        entity.attackEntityFrom(DamageSource.MAGIC, Float.MAX_VALUE);
    } else if (entity instanceof FlareEntity) {
        PhantomEntity phantom = EntityType.PHANTOM.create(entity.world);
        phantom.setLocationAndAngles(entity.getPosX(), entity.getPosY(), entity.getPosZ(), entity.rotationYaw, entity.rotationPitch);
        phantom.setNoAI(((MobEntity) entity).isAIDisabled());
        if (entity.hasCustomName()) {
            phantom.setCustomName(entity.getCustomName());
            phantom.setCustomNameVisible(entity.isCustomNameVisible());
        }
        phantom.setHealth(entity.getHealth());
        if (phantom.getHealth() > 0) {
            entity.world.addEntity(phantom);
            entity.remove(true);
        }
        entity.remove(true);
    }
}
Also used : FlareEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.FlareEntity) PhantomEntity(net.minecraft.entity.monster.PhantomEntity) StatisticsManager(net.minecraft.stats.StatisticsManager) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Example 2 with StatisticsManager

use of net.minecraft.stats.StatisticsManager in project upgrade-aquatic by team-abnormals.

the class RenderOverlays method renderOverlays.

@SuppressWarnings("deprecation")
@SubscribeEvent
public static void renderOverlays(RenderGameOverlayEvent event) {
    if (event.getType() == RenderGameOverlayEvent.ElementType.VIGNETTE) {
        int scaledWidth = MC.getMainWindow().getScaledWidth();
        int scaledHeight = MC.getMainWindow().getScaledHeight();
        ClientPlayerEntity player = MC.player;
        StatisticsManager statisticsManager = player.getStats();
        int sleepTime = statisticsManager.getValue(Stats.CUSTOM.get(Stats.TIME_SINCE_REST));
        int configuredTime = Config.CLIENT.daysTillRenderInsomniaOverlay.get();
        float opacity = 0;
        if (sleepTime == 24000 * configuredTime) {
            opacity = 0.25F;
        } else if (sleepTime == 24000 * configuredTime + 100) {
            opacity = 0.45F;
        } else if (sleepTime == 24000 * configuredTime + 200) {
            opacity = 0.65F;
        } else if (sleepTime == 24000 * configuredTime + 300) {
            opacity = 0.85F;
        } else if (sleepTime == 24000 * configuredTime + 400) {
            opacity = 0.90F;
        } else if (sleepTime >= 24000 * configuredTime + 500) {
            opacity = 1F;
        } else if (sleepTime < 24000 * configuredTime) {
            opacity = 0F;
        }
        if (MC.gameSettings.thirdPersonView == 0 && Config.CLIENT.daysTillRenderInsomniaOverlay.get() != 0 && MC.player.getEntityWorld().func_234922_V_() == DimensionType.OVERWORLD) {
            MatrixStack stack = event.getMatrixStack();
            stack.push();
            MC.textureManager.bindTexture(new ResourceLocation(UpgradeAquatic.MODID, "textures/gui/overlay/insomnia.png"));
            RenderSystem.enableBlend();
            RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
            RenderSystem.color3f(1.0F, 1.0F, 1.0F);
            RenderSystem.color4f(1.0F, 1.0F, 1.0F, opacity);
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder bufferbuilder = tessellator.getBuffer();
            bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
            bufferbuilder.pos(0.0D, (double) scaledHeight, -90.0D).tex(0.0F, 1.0F).endVertex();
            bufferbuilder.pos((double) scaledWidth, (double) scaledHeight, -90.0D).tex(1.0F, 1.0F).endVertex();
            bufferbuilder.pos((double) scaledWidth, 0.0D, -90.0D).tex(1.0F, 0.0F).endVertex();
            bufferbuilder.pos(0.0D, 0.0D, -90.0D).tex(0.0F, 0.0F).endVertex();
            tessellator.draw();
            stack.pop();
        }
    }
}
Also used : StatisticsManager(net.minecraft.stats.StatisticsManager) Tessellator(net.minecraft.client.renderer.Tessellator) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) ResourceLocation(net.minecraft.util.ResourceLocation) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 3 with StatisticsManager

use of net.minecraft.stats.StatisticsManager in project CumServerPro by MCUmbrella.

the class Minecraft method loadWorld.

public void loadWorld(@Nullable WorldClient worldClientIn, String loadingMessage) {
    if (world != null)
        net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(world));
    if (worldClientIn == null) {
        NetHandlerPlayClient nethandlerplayclient = this.getConnection();
        if (nethandlerplayclient != null) {
            nethandlerplayclient.cleanup();
        }
        if (this.integratedServer != null && this.integratedServer.isAnvilFileSet()) {
            this.integratedServer.initiateShutdown();
            if (loadingScreen != null && this.running) {
                this.loadingScreen.displayLoadingString(I18n.format("forge.client.shutdown.internal"));
            }
            while (!integratedServer.isServerStopped()) {
                try {
                    Thread.sleep(10);
                } catch (InterruptedException ie) {
                }
            }
        }
        this.integratedServer = null;
        this.entityRenderer.resetData();
        this.playerController = null;
        NarratorChatListener.INSTANCE.clear();
    }
    this.renderViewEntity = null;
    this.myNetworkManager = null;
    if (this.loadingScreen != null) {
        this.loadingScreen.resetProgressAndMessage(loadingMessage);
        this.loadingScreen.displayLoadingString("");
    }
    if (worldClientIn == null && this.world != null) {
        this.mcResourcePackRepository.clearResourcePack();
        this.ingameGUI.resetPlayersOverlayFooterHeader();
        this.setServerData((ServerData) null);
        this.integratedServerIsRunning = false;
        net.minecraftforge.fml.client.FMLClientHandler.instance().handleClientWorldClosing(this.world);
    }
    this.mcSoundHandler.stopSounds();
    this.world = worldClientIn;
    if (this.renderGlobal != null) {
        this.renderGlobal.setWorldAndLoadRenderers(worldClientIn);
    }
    if (this.effectRenderer != null) {
        this.effectRenderer.clearEffects(worldClientIn);
    }
    TileEntityRendererDispatcher.instance.setWorld(worldClientIn);
    net.minecraftforge.client.MinecraftForgeClient.clearRenderCache();
    if (worldClientIn != null) {
        if (!this.integratedServerIsRunning) {
            AuthenticationService authenticationservice = new YggdrasilAuthenticationService(this.proxy, UUID.randomUUID().toString());
            MinecraftSessionService minecraftsessionservice = authenticationservice.createMinecraftSessionService();
            GameProfileRepository gameprofilerepository = authenticationservice.createProfileRepository();
            PlayerProfileCache playerprofilecache = new PlayerProfileCache(gameprofilerepository, new File(this.mcDataDir, MinecraftServer.USER_CACHE_FILE.getName()));
            TileEntitySkull.setProfileCache(playerprofilecache);
            TileEntitySkull.setSessionService(minecraftsessionservice);
            PlayerProfileCache.setOnlineMode(false);
        }
        if (this.player == null) {
            this.player = this.playerController.createPlayer(worldClientIn, new StatisticsManager(), new RecipeBookClient());
            this.playerController.flipPlayer(this.player);
        }
        this.player.preparePlayerToSpawn();
        worldClientIn.spawnEntity(this.player);
        this.player.movementInput = new MovementInputFromOptions(this.gameSettings);
        this.playerController.setPlayerCapabilities(this.player);
        this.renderViewEntity = this.player;
    } else {
        this.saveLoader.flushCache();
        this.player = null;
    }
    System.gc();
    this.systemTime = 0L;
}
Also used : PlayerProfileCache(net.minecraft.server.management.PlayerProfileCache) GameProfileRepository(com.mojang.authlib.GameProfileRepository) MovementInputFromOptions(net.minecraft.util.MovementInputFromOptions) MinecraftSessionService(com.mojang.authlib.minecraft.MinecraftSessionService) RecipeBookClient(net.minecraft.client.util.RecipeBookClient) StatisticsManager(net.minecraft.stats.StatisticsManager) NetHandlerPlayClient(net.minecraft.client.network.NetHandlerPlayClient) YggdrasilAuthenticationService(com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService) YggdrasilAuthenticationService(com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService) AuthenticationService(com.mojang.authlib.AuthenticationService) File(java.io.File)

Example 4 with StatisticsManager

use of net.minecraft.stats.StatisticsManager in project Minecraft-SlientClient-Hack by YouNeverKnow00.

the class Minecraft method loadWorld.

/**
 * par2Str is displayed on the loading screen to the user unloads the current world first
 */
public void loadWorld(@Nullable WorldClient worldClientIn, String loadingMessage) {
    if (worldClientIn == null) {
        NetHandlerPlayClient nethandlerplayclient = this.getConnection();
        if (nethandlerplayclient != null) {
            nethandlerplayclient.cleanup();
        }
        if (this.theIntegratedServer != null && this.theIntegratedServer.isAnvilFileSet()) {
            this.theIntegratedServer.initiateShutdown();
        }
        this.theIntegratedServer = null;
        this.entityRenderer.func_190564_k();
        this.playerController = null;
        NarratorChatListener.field_193643_a.func_193642_b();
    }
    this.renderViewEntity = null;
    this.myNetworkManager = null;
    if (this.loadingScreen != null) {
        this.loadingScreen.resetProgressAndMessage(loadingMessage);
        this.loadingScreen.displayLoadingString("");
    }
    if (worldClientIn == null && this.world != null) {
        this.mcResourcePackRepository.clearResourcePack();
        this.ingameGUI.resetPlayersOverlayFooterHeader();
        this.setServerData((ServerData) null);
        this.integratedServerIsRunning = false;
    }
    this.mcSoundHandler.stopSounds();
    this.world = worldClientIn;
    if (this.renderGlobal != null) {
        this.renderGlobal.setWorldAndLoadRenderers(worldClientIn);
    }
    if (this.effectRenderer != null) {
        this.effectRenderer.clearEffects(worldClientIn);
    }
    TileEntityRendererDispatcher.instance.setWorld(worldClientIn);
    if (worldClientIn != null) {
        if (!this.integratedServerIsRunning) {
            AuthenticationService authenticationservice = new YggdrasilAuthenticationService(this.proxy, UUID.randomUUID().toString());
            MinecraftSessionService minecraftsessionservice = authenticationservice.createMinecraftSessionService();
            GameProfileRepository gameprofilerepository = authenticationservice.createProfileRepository();
            PlayerProfileCache playerprofilecache = new PlayerProfileCache(gameprofilerepository, new File(this.mcDataDir, MinecraftServer.USER_CACHE_FILE.getName()));
            TileEntitySkull.setProfileCache(playerprofilecache);
            TileEntitySkull.setSessionService(minecraftsessionservice);
            PlayerProfileCache.setOnlineMode(false);
        }
        if (this.player == null) {
            this.player = this.playerController.func_192830_a(worldClientIn, new StatisticsManager(), new RecipeBookClient());
            this.playerController.flipPlayer(this.player);
        }
        this.player.preparePlayerToSpawn();
        worldClientIn.spawnEntityInWorld(this.player);
        this.player.movementInput = new MovementInputFromOptions(this.gameSettings);
        this.playerController.setPlayerCapabilities(this.player);
        this.renderViewEntity = this.player;
    } else {
        this.saveLoader.flushCache();
        this.player = null;
    }
    System.gc();
    this.systemTime = 0L;
}
Also used : StatisticsManager(net.minecraft.stats.StatisticsManager) PlayerProfileCache(net.minecraft.server.management.PlayerProfileCache) NetHandlerPlayClient(net.minecraft.client.network.NetHandlerPlayClient) GameProfileRepository(com.mojang.authlib.GameProfileRepository) MovementInputFromOptions(net.minecraft.util.MovementInputFromOptions) YggdrasilAuthenticationService(com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService) MinecraftSessionService(com.mojang.authlib.minecraft.MinecraftSessionService) YggdrasilAuthenticationService(com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService) AuthenticationService(com.mojang.authlib.AuthenticationService) File(java.io.File) RecipeBookClient(net.minecraft.client.util.RecipeBookClient)

Example 5 with StatisticsManager

use of net.minecraft.stats.StatisticsManager in project Minecraft-SlientClient-Hack by YouNeverKnow00.

the class Minecraft method setDimensionAndSpawnPlayer.

public void setDimensionAndSpawnPlayer(int dimension) {
    this.world.setInitialSpawnLocation();
    this.world.removeAllEntities();
    int i = 0;
    String s = null;
    if (this.player != null) {
        i = this.player.getEntityId();
        this.world.removeEntity(this.player);
        s = this.player.getServerBrand();
    }
    this.renderViewEntity = null;
    EntityPlayerSP entityplayersp = this.player;
    this.player = this.playerController.func_192830_a(this.world, this.player == null ? new StatisticsManager() : this.player.getStatFileWriter(), this.player == null ? new RecipeBook() : this.player.func_192035_E());
    this.player.getDataManager().setEntryValues(entityplayersp.getDataManager().getAll());
    this.player.dimension = dimension;
    this.renderViewEntity = this.player;
    this.player.preparePlayerToSpawn();
    this.player.setServerBrand(s);
    this.world.spawnEntityInWorld(this.player);
    this.playerController.flipPlayer(this.player);
    this.player.movementInput = new MovementInputFromOptions(this.gameSettings);
    this.player.setEntityId(i);
    this.playerController.setPlayerCapabilities(this.player);
    this.player.setReducedDebug(entityplayersp.hasReducedDebug());
    if (this.currentScreen instanceof GuiGameOver) {
        this.displayGuiScreen((GuiScreen) null);
    }
}
Also used : RecipeBook(net.minecraft.stats.RecipeBook) StatisticsManager(net.minecraft.stats.StatisticsManager) GuiGameOver(net.minecraft.client.gui.GuiGameOver) MovementInputFromOptions(net.minecraft.util.MovementInputFromOptions) TextComponentString(net.minecraft.util.text.TextComponentString) NBTTagString(net.minecraft.nbt.NBTTagString) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Aggregations

StatisticsManager (net.minecraft.stats.StatisticsManager)10 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)5 MovementInputFromOptions (net.minecraft.util.MovementInputFromOptions)4 PhantomEntity (net.minecraft.entity.monster.PhantomEntity)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)3 FlareEntity (com.minecraftabnormals.upgrade_aquatic.common.entities.FlareEntity)2 AuthenticationService (com.mojang.authlib.AuthenticationService)2 GameProfileRepository (com.mojang.authlib.GameProfileRepository)2 MinecraftSessionService (com.mojang.authlib.minecraft.MinecraftSessionService)2 YggdrasilAuthenticationService (com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService)2 File (java.io.File)2 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)2 GuiGameOver (net.minecraft.client.gui.GuiGameOver)2 NetHandlerPlayClient (net.minecraft.client.network.NetHandlerPlayClient)2 RecipeBookClient (net.minecraft.client.util.RecipeBookClient)2 NBTTagString (net.minecraft.nbt.NBTTagString)2 PlayerProfileCache (net.minecraft.server.management.PlayerProfileCache)2 RecipeBook (net.minecraft.stats.RecipeBook)2 ResourceLocation (net.minecraft.util.ResourceLocation)2