Search in sources :

Example 31 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project MorePlanets by SteveKunG.

the class ClientProxyMP method handleCustomSpawning.

private static void handleCustomSpawning() {
    EntityRegistration entityRegistration = EntityRegistry.instance().lookupModSpawn(EntitySpaceFishHook.class, false);
    Function<FMLMessage.EntitySpawnMessage, Entity> handler = input -> {
        WorldClient world = FMLClientHandler.instance().getWorldClient();
        int entityID = 0;
        double posX = 0;
        double posY = 0;
        double posZ = 0;
        try {
            entityID = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "throwerId").getInt(input);
            posX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawX").getDouble(input);
            posY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawY").getDouble(input);
            posZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawZ").getDouble(input);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Entity angler = world.getEntityByID(entityID);
        if (angler instanceof EntityPlayer) {
            Entity entity = new EntitySpaceFishHook(world, (EntityPlayer) angler, posX, posY, posZ);
            return entity;
        }
        return null;
    };
    entityRegistration.setCustomSpawning(handler, false);
    entityRegistration = EntityRegistry.instance().lookupModSpawn(EntityCheeseSpore.class, false);
    handler = input -> {
        WorldClient world = FMLClientHandler.instance().getWorldClient();
        double posX = 0;
        double posY = 0;
        double posZ = 0;
        double speedScaledX = 0;
        double speedScaledY = 0;
        double speedScaledZ = 0;
        try {
            posX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawX").getDouble(input);
            posY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawY").getDouble(input);
            posZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawZ").getDouble(input);
            speedScaledX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledX").getDouble(input);
            speedScaledY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledY").getDouble(input);
            speedScaledZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledZ").getDouble(input);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Entity entity = new EntityCheeseSpore(world, posX, posY, posZ, speedScaledX, speedScaledY, speedScaledZ);
        return entity;
    };
    entityRegistration.setCustomSpawning(handler, false);
    entityRegistration = EntityRegistry.instance().lookupModSpawn(EntitySmallCheeseSpore.class, false);
    handler = input -> {
        WorldClient world = FMLClientHandler.instance().getWorldClient();
        double posX = 0;
        double posY = 0;
        double posZ = 0;
        double speedScaledX = 0;
        double speedScaledY = 0;
        double speedScaledZ = 0;
        try {
            posX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawX").getDouble(input);
            posY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawY").getDouble(input);
            posZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawZ").getDouble(input);
            speedScaledX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledX").getDouble(input);
            speedScaledY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledY").getDouble(input);
            speedScaledZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledZ").getDouble(input);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Entity entity = new EntitySmallCheeseSpore(world, posX, posY, posZ, speedScaledX, speedScaledY, speedScaledZ);
        return entity;
    };
    entityRegistration.setCustomSpawning(handler, false);
    entityRegistration = EntityRegistry.instance().lookupModSpawn(EntityVeinBall.class, false);
    handler = input -> {
        WorldClient world = FMLClientHandler.instance().getWorldClient();
        double posX = 0;
        double posY = 0;
        double posZ = 0;
        double speedScaledX = 0;
        double speedScaledY = 0;
        double speedScaledZ = 0;
        try {
            posX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawX").getDouble(input);
            posY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawY").getDouble(input);
            posZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawZ").getDouble(input);
            speedScaledX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledX").getDouble(input);
            speedScaledY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledY").getDouble(input);
            speedScaledZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledZ").getDouble(input);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Entity entity = new EntityVeinBall(world, posX, posY, posZ, speedScaledX, speedScaledY, speedScaledZ);
        return entity;
    };
    entityRegistration.setCustomSpawning(handler, false);
}
Also used : BiomeColorHelper(net.minecraft.world.biome.BiomeColorHelper) ModelBakeEvent(net.minecraftforge.client.event.ModelBakeEvent) Item(net.minecraft.item.Item) ParticleGravityHarvester(stevekung.mods.moreplanets.moons.koentus.client.particle.ParticleGravityHarvester) ModelRegistryEvent(net.minecraftforge.client.event.ModelRegistryEvent) MPBlocks(stevekung.mods.moreplanets.init.MPBlocks) ParticleDarkPortal(stevekung.mods.moreplanets.planets.diona.client.particle.ParticleDarkPortal) FMLMessage(net.minecraftforge.fml.common.network.internal.FMLMessage) ObfuscationReflectionHelper(net.minecraftforge.fml.common.ObfuscationReflectionHelper) Side(net.minecraftforge.fml.relauncher.Side) EntityVeinBall(stevekung.mods.moreplanets.planets.nibiru.entity.projectile.EntityVeinBall) ClientEventHandler(stevekung.mods.moreplanets.core.event.ClientEventHandler) MPSchematics(stevekung.mods.moreplanets.init.MPSchematics) ItemCapsule(stevekung.mods.moreplanets.items.ItemCapsule) EntitySmallCheeseSpore(stevekung.mods.moreplanets.planets.chalos.entity.projectile.EntitySmallCheeseSpore) Function(com.google.common.base.Function) ParticleInfectedPurloniteFlame(stevekung.mods.moreplanets.planets.diona.client.particle.ParticleInfectedPurloniteFlame) MorePlanetsMod(stevekung.mods.moreplanets.core.MorePlanetsMod) ParticleInfectedGuardianAppearance(stevekung.mods.moreplanets.planets.nibiru.client.particle.ParticleInfectedGuardianAppearance) ModelLoaderRegistry(net.minecraftforge.client.model.ModelLoaderRegistry) MPItems(stevekung.mods.moreplanets.init.MPItems) EnumParticleTypesMP(stevekung.mods.moreplanets.utils.EnumParticleTypesMP) FMLClientHandler(net.minecraftforge.fml.client.FMLClientHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) stevekung.mods.moreplanets.utils.client.particle(stevekung.mods.moreplanets.utils.client.particle) CommonUtils(stevekung.mods.stevekunglib.utils.CommonUtils) EntityCheeseSpore(stevekung.mods.moreplanets.planets.chalos.entity.projectile.EntityCheeseSpore) FMLPostInitializationEvent(net.minecraftforge.fml.common.event.FMLPostInitializationEvent) WorldClient(net.minecraft.client.multiplayer.WorldClient) stevekung.mods.moreplanets.client.renderer(stevekung.mods.moreplanets.client.renderer) Minecraft(net.minecraft.client.Minecraft) ParticleKoentusMeteor(stevekung.mods.moreplanets.moons.koentus.client.particle.ParticleKoentusMeteor) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) BlocksItemsRegistry(stevekung.mods.moreplanets.utils.BlocksItemsRegistry) FMLPreInitializationEvent(net.minecraftforge.fml.common.event.FMLPreInitializationEvent) FMLInitializationEvent(net.minecraftforge.fml.common.event.FMLInitializationEvent) ColorUtils(stevekung.mods.stevekunglib.utils.ColorUtils) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Entity(net.minecraft.entity.Entity) CompatibilityManagerMP(stevekung.mods.moreplanets.utils.CompatibilityManagerMP) ClientRegistryUtils(stevekung.mods.stevekunglib.utils.client.ClientRegistryUtils) ParticleAlienBerryLeavesSpark(stevekung.mods.moreplanets.planets.nibiru.client.particle.ParticleAlienBerryLeavesSpark) IMorePlanetsBoss(stevekung.mods.moreplanets.utils.IMorePlanetsBoss) ParticleInfectedSpore(stevekung.mods.moreplanets.planets.nibiru.client.particle.ParticleInfectedSpore) EntitySpaceFishHook(stevekung.mods.moreplanets.entity.projectile.EntitySpaceFishHook) BlockColors(net.minecraft.client.renderer.color.BlockColors) EntityRegistration(net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) ItemBlock(net.minecraft.item.ItemBlock) ParticleAlienMinerSpark(stevekung.mods.moreplanets.planets.diona.client.particle.ParticleAlienMinerSpark) EntityRegistry(net.minecraftforge.fml.common.registry.EntityRegistry) Entity(net.minecraft.entity.Entity) EntityVeinBall(stevekung.mods.moreplanets.planets.nibiru.entity.projectile.EntityVeinBall) FMLMessage(net.minecraftforge.fml.common.network.internal.FMLMessage) EntitySmallCheeseSpore(stevekung.mods.moreplanets.planets.chalos.entity.projectile.EntitySmallCheeseSpore) EntityCheeseSpore(stevekung.mods.moreplanets.planets.chalos.entity.projectile.EntityCheeseSpore) WorldClient(net.minecraft.client.multiplayer.WorldClient) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntitySpaceFishHook(stevekung.mods.moreplanets.entity.projectile.EntitySpaceFishHook) EntityRegistration(net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration)

Example 32 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project Almura by AlmuraDev.

the class ClientboundFeaturesOpenResponsePacketHandler method handleMessage.

@Override
public void handleMessage(ClientboundFeaturesOpenResponsePacket message, RemoteConnection connection, Platform.Type side) {
    if (side.isClient()) {
        final Minecraft client = Minecraft.getMinecraft();
        if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
            final EntityPlayerSP player = client.player;
            final WorldClient world = client.world;
            final boolean isAdmin = message.admin;
            new FeatureScreen(player, world, isAdmin).display();
        }
    }
}
Also used : FeatureScreen(com.almuradev.almura.feature.menu.ingame.FeatureScreen) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft) WorldClient(net.minecraft.client.multiplayer.WorldClient)

Example 33 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project Almura by AlmuraDev.

the class ClientboundPlayerDiedPacketHandler method handleMessage.

@Override
public void handleMessage(ClientboundPlayerDiedPacket message, RemoteConnection connection, Platform.Type side) {
    if (side.isClient()) {
        final Minecraft client = Minecraft.getMinecraft();
        if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
            final EntityPlayerSP player = client.player;
            final WorldClient world = client.world;
            new PlayerDiedGUI(player, message.droppedAmount, message.deathTaxAmount, message.dropCoins, message.canRevive).display();
        }
    }
}
Also used : EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) PlayerDiedGUI(com.almuradev.almura.feature.death.client.gui.PlayerDiedGUI) Minecraft(net.minecraft.client.Minecraft) WorldClient(net.minecraft.client.multiplayer.WorldClient)

Example 34 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project Hyperium by HyperiumClient.

the class DragonHeadRenderer method renderHead.

private void renderHead(EntityPlayer player, float partialTicks) {
    double scale = 1.0F;
    double rotate = CosmeticsUtil.interpolate(player.prevRotationYawHead, player.rotationYawHead, partialTicks);
    double rotate1 = CosmeticsUtil.interpolate(player.prevRotationPitch, player.rotationPitch, partialTicks);
    GlStateManager.scale(-scale, -scale, scale);
    GL11.glRotated(180.0 + rotate, 0.0, 1.0, 0.0);
    GlStateManager.translate(0.0, -(player.height - .4) / scale, 0.0);
    GlStateManager.translate(0.0D, 0.0D, .05 / scale);
    GL11.glRotated(rotate1, 1.0D, 0.0D, 0.0D);
    GlStateManager.translate(0.0, -0.3 / scale, .06);
    if (player.isSneaking())
        GlStateManager.translate(0.0, 0.125 / scale, 0.0);
    float[] colors = new float[] { 1.0f, 1.0f, 1.0f };
    if (player.onGround) {
        jaw.rotateAngleX = 0;
    } else {
        if (mc.theWorld != null) {
            int e = -1;
            WorldClient theWorld = Minecraft.getMinecraft().theWorld;
            Chunk chunk = theWorld.getChunkFromBlockCoords(new BlockPos(player.posX, player.posY, player.posZ));
            for (int i = 0; i < 255; i++) {
                if (i > player.posY)
                    break;
                Block block = chunk.getBlock(new BlockPos(player.posX, i, player.posZ));
                if (block != null && !block.getMaterial().equals(Material.air))
                    e = i;
            }
            jaw.rotateAngleX = 0;
            if (e != -1) {
                double dis = Math.abs(e - player.posY);
                dis /= 4;
                if (dis != 0) {
                    jaw.rotateAngleX = (float) ((dis) / (1 + dis));
                }
            }
        } else {
            jaw.rotateAngleX = 0;
        }
    }
    GlStateManager.color(colors[0], colors[1], colors[2]);
    mc.getTextureManager().bindTexture(selectedLoc);
    GlStateManager.scale(0.5F, 0.5F, 0.5F);
    head.render(.1F);
    GL11.glCullFace(GL11.GL_BACK);
    GL11.glDisable(GL11.GL_CULL_FACE);
}
Also used : Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.BlockPos) Chunk(net.minecraft.world.chunk.Chunk) WorldClient(net.minecraft.client.multiplayer.WorldClient)

Example 35 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project Hyperium by HyperiumClient.

the class GuiHyperiumScreenIngameMenu method initGui.

@Override
public void initGui() {
    super.initGui();
    buttonList.clear();
    int i = -16;
    buttonList.add(new GuiButton(1, width / 2 - 100, height / 4 + 120 + i, I18n.format("menu.returnToMenu")));
    /* If Client is on server, add disconnect button */
    if (!mc.isIntegratedServerRunning())
        (buttonList.get(0)).displayString = I18n.format("menu.disconnect");
    /* Add initial buttons */
    buttonList.add(new GuiButton(4, width / 2 - 100, height / 4 + 24 + i, I18n.format("menu.returnToGame")));
    buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 96 + i, 98, 20, I18n.format("menu.options")));
    GuiButton guibutton;
    buttonList.add(guibutton = new GuiButton(7, width / 2 + 2, height / 4 + 96 + i, 98, 20, I18n.format("menu.shareToLan")));
    buttonList.add(new GuiButton(5, width / 2 - 100, height / 4 + 48 + i, 98, 20, I18n.format("gui.achievements")));
    buttonList.add(new GuiButton(6, width / 2 + 2, height / 4 + 48 + i, 98, 20, I18n.format("gui.stats")));
    guibutton.enabled = mc.isSingleplayer() && !mc.getIntegratedServer().getPublic();
    buttonList.add(new GuiButton(9, width / 2 - 100, height / 4 + 56, 98, 20, I18n.format("button.ingame.hyperiumsettings")));
    buttonList.add(new GuiButton(8, width / 2 + 2, height / 4 + 56, 98, 20, I18n.format("button.ingame.hyperiumcredits")));
    WorldClient theWorld = Minecraft.getMinecraft().theWorld;
    // Used to detect if the player is on a singleplayer world or a multiplayer world.
    MinecraftServer integratedServer = Minecraft.getMinecraft().getIntegratedServer();
    if (theWorld != null && (integratedServer == null)) {
        GuiButton oldButton = buttonList.remove(3);
        GuiButton newButton = new GuiButton(10, oldButton.xPosition, oldButton.yPosition, oldButton.getButtonWidth(), 20, I18n.format("button.ingame.serverlist"));
        buttonList.add(newButton);
    }
}
Also used : WorldClient(net.minecraft.client.multiplayer.WorldClient) MinecraftServer(net.minecraft.server.MinecraftServer)

Aggregations

WorldClient (net.minecraft.client.multiplayer.WorldClient)39 Minecraft (net.minecraft.client.Minecraft)19 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)12 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)10 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)10 Entity (net.minecraft.entity.Entity)9 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 BlockPos (net.minecraft.util.math.BlockPos)7 Block (net.minecraft.block.Block)6 IBlockState (net.minecraft.block.state.IBlockState)6 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)4 IRenderHandler (net.minecraftforge.client.IRenderHandler)4 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)3 ItemStack (net.minecraft.item.ItemStack)3 TileEntity (net.minecraft.tileentity.TileEntity)3 BlockPos (net.minecraft.util.BlockPos)3 Function (com.google.common.base.Function)2 Random (java.util.Random)2 GuiCelestialSelection (micdoodle8.mods.galacticraft.core.client.gui.screen.GuiCelestialSelection)2 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)2