Search in sources :

Example 11 with GCPlayerStatsClient

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient in project Galacticraft by micdoodle8.

the class GuiHandler method getClientGuiElement.

@SideOnly(Side.CLIENT)
private Object getClientGuiElement(int ID, EntityPlayer player, World world, BlockPos position) {
    EntityPlayerSP playerClient = PlayerUtil.getPlayerBaseClientFromPlayer(player, false);
    if (ID == GuiIdsCore.GALAXY_MAP) {
        return new GuiCelestialSelection(true, null);
    } else if (ID == GuiIdsCore.ROCKET_INVENTORY && player.ridingEntity instanceof EntityTieredRocket) {
        return new GuiRocketInventory(player.inventory, (EntityTieredRocket) player.ridingEntity, ((EntityTieredRocket) player.ridingEntity).getType());
    } else if (ID == GuiIdsCore.EXTENDED_INVENTORY) {
        return new GuiExtendedInventory(player, ClientProxyCore.dummyInventory);
    } else if (ID == GuiIdsCore.SPACE_RACE_START) {
        return new GuiNewSpaceRace(player);
    } else if (ID == GuiIdsCore.SPACE_RACE_JOIN) {
        return new GuiJoinSpaceRace(playerClient);
    } else if (ID == GuiIdsCore.PRE_LAUNCH_CHECKLIST) {
        return new GuiPreLaunchChecklist(WorldUtil.getAllChecklistKeys(), player.getHeldItem().hasTagCompound() ? (NBTTagCompound) player.getHeldItem().getTagCompound().getTag("checklistData") : null);
    }
    TileEntity tile = world.getTileEntity(position);
    if (tile != null) {
        if (tile instanceof TileEntityCrafting) {
            return new GuiCrafting(player.inventory, (TileEntityCrafting) tile);
        } else if (tile instanceof TileEntityRefinery) {
            return new GuiRefinery(player.inventory, (TileEntityRefinery) world.getTileEntity(position));
        } else if (tile instanceof TileEntityOxygenCollector) {
            return new GuiOxygenCollector(player.inventory, (TileEntityOxygenCollector) tile);
        } else if (tile instanceof TileEntityOxygenDistributor) {
            return new GuiOxygenDistributor(player.inventory, (TileEntityOxygenDistributor) tile);
        } else if (tile instanceof TileEntityFuelLoader) {
            return new GuiFuelLoader(player.inventory, (TileEntityFuelLoader) tile);
        } else if (tile instanceof TileEntityOxygenSealer) {
            return new GuiOxygenSealer(player.inventory, (TileEntityOxygenSealer) tile);
        } else if (tile instanceof TileEntityCargoLoader) {
            return new GuiCargoLoader(player.inventory, (TileEntityCargoLoader) tile);
        } else if (tile instanceof TileEntityCargoUnloader) {
            return new GuiCargoUnloader(player.inventory, (TileEntityCargoUnloader) tile);
        } else if (tile instanceof TileEntityParaChest) {
            return new GuiParaChest(player.inventory, (TileEntityParaChest) tile);
        } else if (tile instanceof TileEntitySolar) {
            return new GuiSolar(player.inventory, (TileEntitySolar) tile);
        } else if (tile instanceof TileEntityAirLockController) {
            return new GuiAirLockController((TileEntityAirLockController) tile);
        } else if (tile instanceof TileEntityEnergyStorageModule) {
            return new GuiEnergyStorageModule(player.inventory, (TileEntityEnergyStorageModule) tile);
        } else if (tile instanceof TileEntityCoalGenerator) {
            return new GuiCoalGenerator(player.inventory, (TileEntityCoalGenerator) tile);
        } else if (tile instanceof TileEntityElectricFurnace) {
            return new GuiElectricFurnace(player.inventory, (TileEntityElectricFurnace) tile);
        } else if (tile instanceof TileEntityIngotCompressor) {
            return new GuiIngotCompressor(player.inventory, (TileEntityIngotCompressor) tile);
        } else if (tile instanceof TileEntityElectricIngotCompressor) {
            return new GuiElectricIngotCompressor(player.inventory, (TileEntityElectricIngotCompressor) tile);
        } else if (tile instanceof TileEntityCircuitFabricator) {
            return new GuiCircuitFabricator(player.inventory, (TileEntityCircuitFabricator) tile);
        } else if (tile instanceof TileEntityOxygenStorageModule) {
            return new GuiOxygenStorageModule(player.inventory, (TileEntityOxygenStorageModule) tile);
        } else if (tile instanceof TileEntityOxygenCompressor) {
            return new GuiOxygenCompressor(player.inventory, (TileEntityOxygenCompressor) tile);
        } else if (tile instanceof TileEntityOxygenDecompressor) {
            return new GuiOxygenDecompressor(player.inventory, (TileEntityOxygenDecompressor) tile);
        } else if (tile instanceof TileEntityDeconstructor) {
            return new GuiDeconstructor(player.inventory, (TileEntityDeconstructor) tile);
        } else if (tile instanceof TileEntityPainter) {
            return new GuiPainter(player.inventory, (TileEntityPainter) tile);
        }
    }
    if (playerClient != null) {
        GCPlayerStatsClient stats = GCPlayerStatsClient.get(playerClient);
        for (ISchematicPage page : stats.getUnlockedSchematics()) {
            if (ID == page.getGuiID()) {
                GuiScreen screen = page.getResultScreen(playerClient, position);
                if (screen instanceof ISchematicResultPage) {
                    ((ISchematicResultPage) screen).setPageIndex(page.getPageID());
                }
                return screen;
            }
        }
    }
    return null;
}
Also used : EntityTieredRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket) GuiJoinSpaceRace(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiJoinSpaceRace) GuiCelestialSelection(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiCelestialSelection) GCPlayerStatsClient(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient) ISchematicResultPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicResultPage) TileEntity(net.minecraft.tileentity.TileEntity) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) GuiScreen(net.minecraft.client.gui.GuiScreen) GuiNewSpaceRace(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiNewSpaceRace) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) GuiPreLaunchChecklist(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiPreLaunchChecklist) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 12 with GCPlayerStatsClient

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient in project Galacticraft by micdoodle8.

the class TransformerHooks method orientCamera.

@SideOnly(Side.CLIENT)
public static void orientCamera(float partialTicks) {
    EntityPlayerSP player = ClientProxyCore.mc.thePlayer;
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    Entity viewEntity = ClientProxyCore.mc.getRenderViewEntity();
    if (player.ridingEntity instanceof ICameraZoomEntity && ClientProxyCore.mc.gameSettings.thirdPersonView == 0) {
        Entity entity = player.ridingEntity;
        float offset = ((ICameraZoomEntity) entity).getRotateOffset();
        if (offset > -10F) {
            offset += PLAYER_Y_OFFSET;
            GL11.glTranslatef(0, -offset, 0);
            float anglePitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks;
            float angleYaw = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks;
            GL11.glRotatef(-anglePitch, 0.0F, 0.0F, 1.0F);
            GL11.glRotatef(angleYaw, 0.0F, 1.0F, 0.0F);
            GL11.glTranslatef(0, offset, 0);
        }
    }
    if (viewEntity instanceof EntityLivingBase && viewEntity.worldObj.provider instanceof IZeroGDimension && !((EntityLivingBase) viewEntity).isPlayerSleeping()) {
        float pitch = viewEntity.prevRotationPitch + (viewEntity.rotationPitch - viewEntity.prevRotationPitch) * partialTicks;
        float yaw = viewEntity.prevRotationYaw + (viewEntity.rotationYaw - viewEntity.prevRotationYaw) * partialTicks + 180.0F;
        float eyeHeightChange = viewEntity.width / 2.0F;
        // GL11.glTranslatef(0.0F, -f1, 0.0F);
        GL11.glRotatef(-yaw, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-pitch, 1.0F, 0.0F, 0.0F);
        GL11.glTranslatef(0.0F, 0.0F, 0.1F);
        EnumGravity gDir = stats.getGdir();
        GL11.glRotatef(180.0F * gDir.getThetaX(), 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(180.0F * gDir.getThetaZ(), 0.0F, 0.0F, 1.0F);
        GL11.glRotatef(pitch * gDir.getPitchGravityX(), 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(pitch * gDir.getPitchGravityY(), 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(yaw * gDir.getYawGravityX(), 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(yaw * gDir.getYawGravityY(), 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(yaw * gDir.getYawGravityZ(), 0.0F, 0.0F, 1.0F);
        // GL11.glTranslatef(sneakY * gDir.getSneakVecX(), sneakY * gDir.getSneakVecY(), sneakY * gDir.getSneakVecZ());
        GL11.glTranslatef(eyeHeightChange * gDir.getEyeVecX(), eyeHeightChange * gDir.getEyeVecY(), eyeHeightChange * gDir.getEyeVecZ());
        if (stats.getGravityTurnRate() < 1.0F) {
            GL11.glRotatef(90.0F * (stats.getGravityTurnRatePrev() + (stats.getGravityTurnRate() - stats.getGravityTurnRatePrev()) * partialTicks), stats.getGravityTurnVecX(), stats.getGravityTurnVecY(), stats.getGravityTurnVecZ());
        }
    }
// omit this for interesting 3P views
// GL11.glTranslatef(0.0F, 0.0F, -0.1F);
// GL11.glRotatef(pitch, 1.0F, 0.0F, 0.0F);
// GL11.glRotatef(yaw, 0.0F, 1.0F, 0.0F);
// GL11.glTranslatef(0.0F, f1, 0.0F);
}
Also used : ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Entity(net.minecraft.entity.Entity) GCPlayerStatsClient(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient) EnumGravity(micdoodle8.mods.galacticraft.core.entities.player.EnumGravity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 13 with GCPlayerStatsClient

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient in project Galacticraft by micdoodle8.

the class PlayerClient method onBuild.

@Override
public void onBuild(int i, EntityPlayerSP player) {
    // 0 : opened GC inventory tab
    // 1,2,3 : Compressor, CF, Standard Wrench
    // 4,5,6 : Fuel loader, Launchpad, NASA Workbench
    // 7: oil found 8: placed rocket
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    int flag = stats.getBuildFlags();
    if (flag == -1) {
        flag = 0;
    }
    int repeatCount = flag >> 9;
    if (repeatCount <= 3) {
        repeatCount++;
    }
    if ((flag & 1 << i) > 0) {
        return;
    }
    flag |= 1 << i;
    stats.setBuildFlags((flag & 511) + (repeatCount << 9));
    GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_BUILDFLAGS_UPDATE, GCCoreUtil.getDimensionID(player.worldObj), new Object[] { stats.getBuildFlags() }));
    switch(i) {
        case 0:
        case 1:
        case 2:
        case 3:
            player.addChatMessage(IChatComponent.Serializer.jsonToComponent("[{\"text\":\"" + GCCoreUtil.translate("gui.message.help1") + ": \",\"color\":\"white\"}," + "{\"text\":\" " + EnumColor.BRIGHT_GREEN + "wiki." + Constants.PREFIX + "com/wiki/1" + "\"," + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":" + "{\"text\":\"" + GCCoreUtil.translate("gui.message.clicklink") + "\",\"color\":\"yellow\"}}," + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + "http://wiki." + Constants.PREFIX + "com/wiki/1" + "\"}}]"));
            player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.message.help1a") + EnumColor.AQUA + " /gchelp"));
            break;
        case 4:
        case 5:
        case 6:
            player.addChatMessage(IChatComponent.Serializer.jsonToComponent("[{\"text\":\"" + GCCoreUtil.translate("gui.message.help2") + ": \",\"color\":\"white\"}," + "{\"text\":\" " + EnumColor.BRIGHT_GREEN + "wiki." + Constants.PREFIX + "com/wiki/2" + "\"," + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":" + "{\"text\":\"" + GCCoreUtil.translate("gui.message.clicklink") + "\",\"color\":\"yellow\"}}," + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + "http://wiki." + Constants.PREFIX + "com/wiki/2" + "\"}}]"));
            break;
        case 7:
            player.addChatMessage(IChatComponent.Serializer.jsonToComponent("[{\"text\":\"" + GCCoreUtil.translate("gui.message.help3") + ": \",\"color\":\"white\"}," + "{\"text\":\" " + EnumColor.BRIGHT_GREEN + "wiki." + Constants.PREFIX + "com/wiki/oil" + "\"," + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":" + "{\"text\":\"" + GCCoreUtil.translate("gui.message.clicklink") + "\",\"color\":\"yellow\"}}," + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + "http://wiki." + Constants.PREFIX + "com/wiki/oil" + "\"}}]"));
            break;
        case 8:
            player.addChatMessage(IChatComponent.Serializer.jsonToComponent("[{\"text\":\"" + GCCoreUtil.translate("gui.message.prelaunch") + ": \",\"color\":\"white\"}," + "{\"text\":\" " + EnumColor.BRIGHT_GREEN + "wiki." + Constants.PREFIX + "com/wiki/pre" + "\"," + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":" + "{\"text\":\"" + GCCoreUtil.translate("gui.message.clicklink") + "\",\"color\":\"yellow\"}}," + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + "http://wiki." + Constants.PREFIX + "com/wiki/pre" + "\"}}]"));
            break;
    }
}
Also used : PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple)

Example 14 with GCPlayerStatsClient

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient in project Galacticraft by micdoodle8.

the class PlayerClient method onLivingUpdatePost.

@Override
public void onLivingUpdatePost(EntityPlayerSP player) {
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    boolean ridingThirdPersonEntity = player.ridingEntity instanceof ICameraZoomEntity && ((ICameraZoomEntity) player.ridingEntity).defaultThirdPerson();
    if (stats.getPlatformControlled() || player.worldObj.provider instanceof IZeroGDimension) {
        stats.getFreefallHandler().postVanillaMotion(player);
        if (stats.isInFreefall() || ridingThirdPersonEntity) {
            this.cancelLimbSwing(player);
        } else {
            if (stats.isInFreefallLast() && this.downMot2 < -0.008D) {
                stats.setLandingTicks(5 - (int) (Math.min(this.downMot2, stats.getDownMotionLast()) * 40));
                if (stats.getLandingTicks() > stats.getMaxLandingticks()) {
                    if (stats.getLandingTicks() > stats.getMaxLandingticks() + 4) {
                        stats.getFreefallHandler().pjumpticks = stats.getLandingTicks() - stats.getMaxLandingticks() - 5;
                    }
                    stats.setLandingTicks(stats.getMaxLandingticks());
                }
                float dYmax = 0.3F * stats.getLandingTicks() / stats.getMaxLandingticks();
                float factor = 1F;
                for (int i = 0; i <= stats.getLandingTicks(); i++) {
                    stats.getLandingYOffset()[i] = dYmax * MathHelper.sin(i * 3.1415926F / stats.getLandingTicks()) * factor;
                    factor *= 0.97F;
                }
            }
        }
        if (stats.getLandingTicks() > 0) {
            stats.setLandingTicks(stats.getLandingTicks() - 1);
            player.limbSwing *= 0.8F;
            player.limbSwingAmount = 0F;
        }
    } else {
        stats.setInFreefall(false);
        if (ridingThirdPersonEntity) {
            this.cancelLimbSwing(player);
        }
    }
    if (ridingThirdPersonEntity && !stats.isLastRidingCameraZoomEntity()) {
        if (!ConfigManagerCore.disableVehicleCameraChanges)
            FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = 1;
    }
    if (player.ridingEntity instanceof ICameraZoomEntity) {
        if (!ConfigManagerCore.disableVehicleCameraChanges) {
            stats.setLastZoomed(true);
            TickHandlerClient.zoom(((ICameraZoomEntity) player.ridingEntity).getCameraZoom());
        }
    } else if (stats.isLastZoomed()) {
        if (!ConfigManagerCore.disableVehicleCameraChanges) {
            stats.setLastZoomed(false);
            TickHandlerClient.zoom(4.0F);
        }
    }
    stats.setLastRidingCameraZoomEntity(ridingThirdPersonEntity);
    if (stats.isUsingParachute()) {
        player.fallDistance = 0.0F;
    }
    PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
    stats.setUsingParachute(false);
    if (gearData != null) {
        stats.setUsingParachute(gearData.getParachute() != null);
        if (!GalacticraftCore.isHeightConflictingModInstalled) {
            if (gearData.getMask() != GCPlayerHandler.GEAR_NOT_PRESENT) {
                player.height = 1.9375F;
            } else {
                player.height = 1.8F;
            }
            AxisAlignedBB bounds = player.getEntityBoundingBox();
            player.setEntityBoundingBox(new AxisAlignedBB(bounds.minX, bounds.minY, bounds.minZ, bounds.maxX, bounds.minY + (double) player.height, bounds.maxZ));
        }
    }
    if (stats.isUsingParachute() && player.onGround) {
        stats.setUsingParachute(false);
        stats.setLastUsingParachute(false);
        FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = stats.getThirdPersonView();
    }
    if (!stats.isLastUsingParachute() && stats.isUsingParachute()) {
        FMLClientHandler.instance().getClient().getSoundHandler().playSound(new PositionedSoundRecord(new ResourceLocation(Constants.TEXTURE_PREFIX + "player.parachute"), 0.95F + player.getRNG().nextFloat() * 0.1F, 1.0F, (float) player.posX, (float) player.posY, (float) player.posZ));
    }
    stats.setLastUsingParachute(stats.isUsingParachute());
    stats.setLastOnGround(player.onGround);
}
Also used : PositionedSoundRecord(net.minecraft.client.audio.PositionedSoundRecord) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension) PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

Example 15 with GCPlayerStatsClient

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient in project Galacticraft by micdoodle8.

the class EventHandlerGC method getLastSchematic.

@SideOnly(Side.CLIENT)
private static ISchematicPage getLastSchematic(int currentIndex) {
    EntityPlayerSP player = PlayerUtil.getPlayerBaseClientFromPlayer(FMLClientHandler.instance().getClient().thePlayer, false);
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    final int size = stats.getUnlockedSchematics().size();
    final HashMap<Integer, Integer> idList = new HashMap<Integer, Integer>(size, 1F);
    for (int i = 0; i < size; i++) {
        idList.put(i, stats.getUnlockedSchematics().get(i).getPageID());
    }
    final SortedSet<Integer> keys = new TreeSet<Integer>(idList.keySet());
    final Iterator<Integer> iterator = keys.iterator();
    for (int count = 0; count < keys.size(); count++) {
        final int i = iterator.next();
        final ISchematicPage page = SchematicRegistry.getMatchingRecipeForID(idList.get(i));
        if (page.getPageID() == currentIndex) {
            if (count - 1 >= 0) {
                return stats.getUnlockedSchematics().get(count - 1);
            } else {
                return null;
            }
        }
    }
    return null;
}
Also used : GCPlayerStatsClient(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

GCPlayerStatsClient (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient)9 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)9 IZeroGDimension (micdoodle8.mods.galacticraft.api.world.IZeroGDimension)6 Entity (net.minecraft.entity.Entity)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 ICameraZoomEntity (micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity)4 ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)4 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)3 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)3 IBlockState (net.minecraft.block.state.IBlockState)3 TileEntity (net.minecraft.tileentity.TileEntity)3 EntityAutoRocket (micdoodle8.mods.galacticraft.api.prefab.entity.EntityAutoRocket)2 EntitySpaceshipBase (micdoodle8.mods.galacticraft.api.prefab.entity.EntitySpaceshipBase)2 GuiCelestialSelection (micdoodle8.mods.galacticraft.core.client.gui.screen.GuiCelestialSelection)2 GuiNewSpaceRace (micdoodle8.mods.galacticraft.core.client.gui.screen.GuiNewSpaceRace)2 EntityBuggy (micdoodle8.mods.galacticraft.core.entities.EntityBuggy)2 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)2 PlayerGearData (micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)2 Minecraft (net.minecraft.client.Minecraft)2 GameProfile (com.mojang.authlib.GameProfile)1