Search in sources :

Example 1 with PlayerGearData

use of micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData in project Galacticraft by micdoodle8.

the class LayerFrequencyModule method doRenderLayer.

@Override
public void doRenderLayer(AbstractClientPlayer player, float f5, float f6, float partialTicks, float f8, float f2, float f7, float scale) {
    if (!player.isInvisible()) {
        PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
        if (gearData != null) {
            boolean wearingModule = gearData.getFrequencyModule() != GCPlayerHandler.GEAR_NOT_PRESENT;
            boolean wearingHelmet = gearData.getMask() != GCPlayerHandler.GEAR_NOT_PRESENT;
            FMLClientHandler.instance().getClient().renderEngine.bindTexture(ModelPlayerGC.playerTexture);
            if (wearingModule) {
                this.updateModels();
                GlStateManager.pushMatrix();
                Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
                if (Minecraft.isAmbientOcclusionEnabled()) {
                    GlStateManager.shadeModel(GL11.GL_SMOOTH);
                } else {
                    GlStateManager.shadeModel(GL11.GL_FLAT);
                }
                GlStateManager.rotate(180, 1, 0, 0);
                GlStateManager.pushMatrix();
                GlStateManager.rotate((float) (this.playerRenderer.getMainModel().bipedHeadwear.rotateAngleY * -Constants.RADIANS_TO_DEGREES), 0, 1, 0);
                GlStateManager.rotate((float) (this.playerRenderer.getMainModel().bipedHeadwear.rotateAngleX * Constants.RADIANS_TO_DEGREES), 1, 0, 0);
                GlStateManager.scale(0.3F, 0.3F, 0.3F);
                if (wearingHelmet) {
                    GlStateManager.translate(-1.1F, player.isSneaking() ? 0.35F : 1.2F, 0);
                } else {
                    GlStateManager.translate(-0.9F, player.isSneaking() ? 0.1F : 0.9F, 0);
                }
                ClientUtil.drawBakedModel(this.moduleModel);
                GlStateManager.translate(0.0F, 1.3F, 0.0F);
                GlStateManager.rotate((float) (Math.sin(player.ticksExisted * 0.05) * 50.0F), 1, 0, 0);
                GlStateManager.rotate((float) (Math.cos(player.ticksExisted * 0.1) * 50.0F), 0, 1, 0);
                ClientUtil.drawBakedModel(this.radarModel);
                GlStateManager.popMatrix();
                GlStateManager.color(1.0F, 1.0F, 1.0F);
                GlStateManager.popMatrix();
            }
        }
    }
}
Also used : PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

Example 2 with PlayerGearData

use of micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData in project Galacticraft by micdoodle8.

the class EventHandlerGC method onSoundPlayed.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onSoundPlayed(PlaySoundEvent event) {
    // The event.result starts off equal to event.sound, but could have been altered or set to null by another mod
    if (event.result == null) {
        return;
    }
    EntityPlayerSP player = FMLClientHandler.instance().getClient().thePlayer;
    if (player != null && player.worldObj != null && player.worldObj.provider instanceof IGalacticraftWorldProvider && event != null) {
        // Only modify standard game sounds, not music
        if (event.result.getAttenuationType() != ISound.AttenuationType.NONE) {
            PlayerGearData gearData = ClientProxyCore.playerItemData.get(PlayerUtil.getName(player));
            float x = event.result.getXPosF();
            float y = event.result.getYPosF();
            float z = event.result.getZPosF();
            if (gearData == null || gearData.getFrequencyModule() == -1) {
                // If the player doesn't have a frequency module, and the player isn't in an oxygenated environment
                // Note: this is a very simplistic approach, and nowhere near realistic, but required for performance reasons
                AxisAlignedBB bb = AxisAlignedBB.fromBounds(x - 0.0015D, y - 0.0015D, z - 0.0015D, x + 0.0015D, y + 0.0015D, z + 0.0015D);
                boolean playerInAtmosphere = OxygenUtil.isAABBInBreathableAirBlock(player);
                boolean soundInAtmosphere = OxygenUtil.isAABBInBreathableAirBlock(player.worldObj, bb);
                if ((!playerInAtmosphere || !soundInAtmosphere)) {
                    float volume = event.result.getVolume();
                    // First check for duplicate firing of PlaySoundEvent17 on this handler's own playing of a reduced volume sound (see below)
                    for (int i = 0; i < this.soundPlayList.size(); i++) {
                        SoundPlayEntry entry = this.soundPlayList.get(i);
                        if (entry.name.equals(event.name) && entry.x == x && entry.y == y && entry.z == z && entry.volume == volume) {
                            this.soundPlayList.remove(i);
                            return;
                        }
                    }
                    // If it's not a duplicate: play the same sound but at reduced volume
                    float newVolume = volume / Math.max(0.01F, ((IGalacticraftWorldProvider) player.worldObj.provider).getSoundVolReductionAmount());
                    this.soundPlayList.add(new SoundPlayEntry(event.name, x, y, z, newVolume));
                    ISound newSound = new PositionedSoundRecord(event.result.getSoundLocation(), newVolume, event.result.getPitch(), x, y, z);
                    event.manager.playSound(newSound);
                    event.result = null;
                    return;
                }
            }
        }
    }
}
Also used : ISound(net.minecraft.client.audio.ISound) PositionedSoundRecord(net.minecraft.client.audio.PositionedSoundRecord) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with PlayerGearData

use of micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData in project Galacticraft by micdoodle8.

the class ClientProxyCore method getGearData.

@Override
public PlayerGearData getGearData(EntityPlayer player) {
    PlayerGearData gearData = ClientProxyCore.playerItemData.get(player.getName());
    if (gearData == null) {
        String id = PlayerUtil.getName(player);
        if (!ClientProxyCore.gearDataRequests.contains(id)) {
            GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(PacketSimple.EnumSimplePacket.S_REQUEST_GEAR_DATA, GCCoreUtil.getDimensionID(player.worldObj), new Object[] { id }));
            ClientProxyCore.gearDataRequests.add(id);
        }
    }
    return gearData;
}
Also used : PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

Example 4 with PlayerGearData

use of micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData in project Galacticraft by micdoodle8.

the class LayerOxygenMask method doRenderLayer.

@Override
public void doRenderLayer(AbstractClientPlayer player, float f5, float f6, float partialTicks, float f8, float f2, float f7, float scale) {
    if (!player.isInvisible()) {
        PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
        if (gearData != null) {
            boolean wearingMask = gearData.getMask() != GCPlayerHandler.GEAR_NOT_PRESENT;
            FMLClientHandler.instance().getClient().renderEngine.bindTexture(ModelPlayerGC.oxygenMaskTexture);
            ModelPlayer.copyModelAngles(this.playerRenderer.getMainModel().bipedHeadwear, this.oxygenMask);
            this.oxygenMask.rotationPointY = this.playerRenderer.getMainModel().bipedHeadwear.rotationPointY * 8.0F;
            GlStateManager.pushMatrix();
            GlStateManager.scale(0.5F, 0.5F, 0.5F);
            if (wearingMask) {
                GL11.glPushMatrix();
                GL11.glScalef(1.05F, 1.05F, 1.05F);
                this.oxygenMask.render(scale);
                GL11.glScalef(1F, 1F, 1F);
                GL11.glPopMatrix();
            }
            GlStateManager.popMatrix();
        }
    }
}
Also used : PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

Example 5 with PlayerGearData

use of micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData in project Galacticraft by micdoodle8.

the class LayerOxygenParachute method doRenderLayer.

@Override
public void doRenderLayer(AbstractClientPlayer player, float f5, float f6, float partialTicks, float f8, float f2, float f7, float scale) {
    if (!player.isInvisible()) {
        PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
        if (gearData != null) {
            boolean usingParachute = gearData.getParachute() != null;
            if (usingParachute) {
                FMLClientHandler.instance().getClient().renderEngine.bindTexture(ModelPlayerGC.playerTexture);
                this.parachute[0].rotateAngleZ = (float) (30F / Constants.RADIANS_TO_DEGREES);
                this.parachute[2].rotateAngleZ = (float) -(30F / Constants.RADIANS_TO_DEGREES);
                this.parachuteStrings[0].rotateAngleZ = (float) (155F / Constants.RADIANS_TO_DEGREES);
                this.parachuteStrings[0].rotateAngleX = (float) (23F / Constants.RADIANS_TO_DEGREES);
                this.parachuteStrings[0].setRotationPoint(-9.0F, -7.0F, 2.0F);
                this.parachuteStrings[1].rotateAngleZ = (float) (155F / Constants.RADIANS_TO_DEGREES);
                this.parachuteStrings[1].rotateAngleX = (float) -(23F / Constants.RADIANS_TO_DEGREES);
                this.parachuteStrings[1].setRotationPoint(-9.0F, -7.0F, 2.0F);
                this.parachuteStrings[2].rotateAngleZ = (float) -(155F / Constants.RADIANS_TO_DEGREES);
                this.parachuteStrings[2].rotateAngleX = (float) (23F / Constants.RADIANS_TO_DEGREES);
                this.parachuteStrings[2].setRotationPoint(9.0F, -7.0F, 2.0F);
                this.parachuteStrings[3].rotateAngleZ = (float) -(155F / Constants.RADIANS_TO_DEGREES);
                this.parachuteStrings[3].rotateAngleX = (float) -(23F / Constants.RADIANS_TO_DEGREES);
                this.parachuteStrings[3].setRotationPoint(9.0F, -7.0F, 2.0F);
                GlStateManager.pushMatrix();
                FMLClientHandler.instance().getClient().renderEngine.bindTexture(gearData.getParachute());
                this.parachute[0].render(scale);
                this.parachute[1].render(scale);
                this.parachute[2].render(scale);
                this.parachuteStrings[0].render(scale);
                this.parachuteStrings[1].render(scale);
                this.parachuteStrings[2].render(scale);
                this.parachuteStrings[3].render(scale);
                GlStateManager.popMatrix();
            }
        }
    }
}
Also used : PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

Aggregations

PlayerGearData (micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)13 ICameraZoomEntity (micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity)2 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)2 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)2 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)2 PositionedSoundRecord (net.minecraft.client.audio.PositionedSoundRecord)2 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)2 Entity (net.minecraft.entity.Entity)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 GameProfile (com.mojang.authlib.GameProfile)1 Property (com.mojang.authlib.properties.Property)1 IOException (java.io.IOException)1 CelestialBody (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody)1 Satellite (micdoodle8.mods.galacticraft.api.galaxies.Satellite)1 SolarSystem (micdoodle8.mods.galacticraft.api.galaxies.SolarSystem)1 EnumExtendedInventorySlot (micdoodle8.mods.galacticraft.api.item.EnumExtendedInventorySlot)1 IHoldableItem (micdoodle8.mods.galacticraft.api.item.IHoldableItem)1 IHoldableItemCustom (micdoodle8.mods.galacticraft.api.item.IHoldableItemCustom)1 EntityTieredRocket (micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket)1 ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)1