Search in sources :

Example 6 with PlayerGearData

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

the class EntityAlienVillager method interact.

@Override
public boolean interact(EntityPlayer player) {
    ItemStack itemstack = player.inventory.getCurrentItem();
    boolean flag = itemstack != null && itemstack.getItem() == Items.spawn_egg;
    if (!flag && this.isEntityAlive() && !this.isTrading() && !this.isChild() && !player.isSneaking()) {
        PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
        if (!this.worldObj.isRemote && (this.buyingList == null || this.buyingList.size() > 0)) {
            if (gearData != null && gearData.getFrequencyModule() != GCPlayerHandler.GEAR_NOT_PRESENT) {
                this.setCustomer(player);
                player.displayVillagerTradeGui(this);
            } else {
                if (player instanceof EntityPlayerMP) {
                    EntityPlayerMP playerMP = (EntityPlayerMP) player;
                    GCPlayerStats stats = GCPlayerStats.get(playerMP);
                    if (stats.getChatCooldown() == 0) {
                        player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.village.warning.no_freq_mod")));
                        stats.setChatCooldown(20);
                    }
                }
            }
        }
        player.triggerAchievement(StatList.timesTalkedToVillagerStat);
        return true;
    } else {
        return super.interact(player);
    }
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

Example 7 with PlayerGearData

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

the class PacketSimple method handleClientSide.

@SideOnly(Side.CLIENT)
@Override
public void handleClientSide(EntityPlayer player) {
    EntityPlayerSP playerBaseClient = null;
    GCPlayerStatsClient stats = null;
    if (player instanceof EntityPlayerSP) {
        playerBaseClient = (EntityPlayerSP) player;
        stats = GCPlayerStatsClient.get(playerBaseClient);
    } else {
        if (type != EnumSimplePacket.C_UPDATE_SPACESTATION_LIST && type != EnumSimplePacket.C_UPDATE_PLANETS_LIST && type != EnumSimplePacket.C_UPDATE_CONFIGS) {
            return;
        }
    }
    switch(this.type) {
        case C_AIR_REMAINING:
            if (String.valueOf(this.data.get(2)).equals(String.valueOf(PlayerUtil.getName(player)))) {
                TickHandlerClient.airRemaining = (Integer) this.data.get(0);
                TickHandlerClient.airRemaining2 = (Integer) this.data.get(1);
            }
            break;
        case C_UPDATE_DIMENSION_LIST:
            if (String.valueOf(this.data.get(0)).equals(PlayerUtil.getName(player))) {
                String dimensionList = (String) this.data.get(1);
                if (ConfigManagerCore.enableDebug) {
                    if (!dimensionList.equals(PacketSimple.spamCheckString)) {
                        GCLog.info("DEBUG info: " + dimensionList);
                        PacketSimple.spamCheckString = dimensionList;
                    }
                }
                final String[] destinations = dimensionList.split("\\?");
                List<CelestialBody> possibleCelestialBodies = Lists.newArrayList();
                Map<Integer, Map<String, GuiCelestialSelection.StationDataGUI>> spaceStationData = Maps.newHashMap();
                for (String str : destinations) {
                    CelestialBody celestialBody = WorldUtil.getReachableCelestialBodiesForName(str);
                    if (celestialBody == null && str.contains("$")) {
                        String[] values = str.split("\\$");
                        int homePlanetID = Integer.parseInt(values[4]);
                        for (Satellite satellite : GalaxyRegistry.getRegisteredSatellites().values()) {
                            if (satellite.getParentPlanet().getDimensionID() == homePlanetID) {
                                celestialBody = satellite;
                                break;
                            }
                        }
                        if (!spaceStationData.containsKey(homePlanetID)) {
                            spaceStationData.put(homePlanetID, new HashMap<String, GuiCelestialSelection.StationDataGUI>());
                        }
                        spaceStationData.get(homePlanetID).put(values[1], new GuiCelestialSelection.StationDataGUI(values[2], Integer.parseInt(values[3])));
                    // spaceStationNames.put(values[1], values[2]);
                    // spaceStationIDs.put(values[1], Integer.parseInt(values[3]));
                    // spaceStationHomes.put(values[1], Integer.parseInt(values[4]));
                    }
                    if (celestialBody != null) {
                        possibleCelestialBodies.add(celestialBody);
                    }
                }
                if (FMLClientHandler.instance().getClient().theWorld != null) {
                    if (!(FMLClientHandler.instance().getClient().currentScreen instanceof GuiCelestialSelection)) {
                        GuiCelestialSelection gui = new GuiCelestialSelection(false, possibleCelestialBodies);
                        gui.spaceStationMap = spaceStationData;
                        // gui.spaceStationNames = spaceStationNames;
                        // gui.spaceStationIDs = spaceStationIDs;
                        FMLClientHandler.instance().getClient().displayGuiScreen(gui);
                    } else {
                        ((GuiCelestialSelection) FMLClientHandler.instance().getClient().currentScreen).possibleBodies = possibleCelestialBodies;
                        ((GuiCelestialSelection) FMLClientHandler.instance().getClient().currentScreen).spaceStationMap = spaceStationData;
                    // ((GuiCelestialSelection) FMLClientHandler.instance().getClient().currentScreen).spaceStationNames = spaceStationNames;
                    // ((GuiCelestialSelection) FMLClientHandler.instance().getClient().currentScreen).spaceStationIDs = spaceStationIDs;
                    }
                }
            }
            break;
        case C_SPAWN_SPARK_PARTICLES:
            BlockPos pos = (BlockPos) this.data.get(0);
            Minecraft mc = Minecraft.getMinecraft();
            for (int i = 0; i < 4; i++) {
                if (mc != null && mc.getRenderViewEntity() != null && mc.effectRenderer != null && mc.theWorld != null) {
                    final EntityFX fx = new EntityFXSparks(mc.theWorld, pos.getX() - 0.15 + 0.5, pos.getY() + 1.2, pos.getZ() + 0.15 + 0.5, mc.theWorld.rand.nextDouble() / 20 - mc.theWorld.rand.nextDouble() / 20, mc.theWorld.rand.nextDouble() / 20 - mc.theWorld.rand.nextDouble() / 20);
                    if (fx != null) {
                        mc.effectRenderer.addEffect(fx);
                    }
                }
            }
            break;
        case C_UPDATE_GEAR_SLOT:
            int subtype = (Integer) this.data.get(3);
            String gearName = (String) this.data.get(0);
            EntityPlayer gearDataPlayer = player.worldObj.getPlayerEntityByName(gearName);
            if (gearDataPlayer != null) {
                PlayerGearData gearData = ClientProxyCore.playerItemData.get(PlayerUtil.getName(gearDataPlayer));
                if (gearData == null) {
                    gearData = new PlayerGearData(player);
                    if (!ClientProxyCore.gearDataRequests.contains(gearName)) {
                        GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(PacketSimple.EnumSimplePacket.S_REQUEST_GEAR_DATA, getDimensionID(), new Object[] { gearName }));
                        ClientProxyCore.gearDataRequests.add(gearName);
                    }
                } else {
                    ClientProxyCore.gearDataRequests.remove(gearName);
                }
                EnumExtendedInventorySlot type = EnumExtendedInventorySlot.values()[(Integer) this.data.get(2)];
                EnumModelPacketType typeChange = EnumModelPacketType.values()[(Integer) this.data.get(1)];
                switch(type) {
                    case MASK:
                        gearData.setMask(subtype);
                        break;
                    case GEAR:
                        gearData.setGear(subtype);
                        break;
                    case LEFT_TANK:
                        gearData.setLeftTank(subtype);
                        break;
                    case RIGHT_TANK:
                        gearData.setRightTank(subtype);
                        break;
                    case PARACHUTE:
                        if (typeChange == EnumModelPacketType.ADD) {
                            String name;
                            if (subtype != -1) {
                                name = ItemParaChute.names[subtype];
                                gearData.setParachute(new ResourceLocation(Constants.ASSET_PREFIX, "textures/model/parachute/" + name + ".png"));
                            }
                        } else {
                            gearData.setParachute(null);
                        }
                        break;
                    case FREQUENCY_MODULE:
                        gearData.setFrequencyModule(subtype);
                        break;
                    case THERMAL_HELMET:
                        gearData.setThermalPadding(0, subtype);
                        break;
                    case THERMAL_CHESTPLATE:
                        gearData.setThermalPadding(1, subtype);
                        break;
                    case THERMAL_LEGGINGS:
                        gearData.setThermalPadding(2, subtype);
                        break;
                    case THERMAL_BOOTS:
                        gearData.setThermalPadding(3, subtype);
                        break;
                    case SHIELD_CONTROLLER:
                        gearData.setShieldController(subtype);
                        break;
                    default:
                        break;
                }
                ClientProxyCore.playerItemData.put(gearName, gearData);
            }
            break;
        case C_CLOSE_GUI:
            FMLClientHandler.instance().getClient().displayGuiScreen(null);
            break;
        case C_RESET_THIRD_PERSON:
            FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = stats.getThirdPersonView();
            break;
        case C_UPDATE_SPACESTATION_LIST:
            WorldUtil.decodeSpaceStationListClient(data);
            break;
        case C_UPDATE_SPACESTATION_DATA:
            SpaceStationWorldData var4 = SpaceStationWorldData.getMPSpaceStationData(player.worldObj, (Integer) this.data.get(0), player);
            var4.readFromNBT((NBTTagCompound) this.data.get(1));
            break;
        case C_UPDATE_SPACESTATION_CLIENT_ID:
            ClientProxyCore.clientSpaceStationID = WorldUtil.stringToSpaceStationData((String) this.data.get(0));
            break;
        case C_UPDATE_PLANETS_LIST:
            WorldUtil.decodePlanetsListClient(data);
            break;
        case C_UPDATE_CONFIGS:
            ConfigManagerCore.saveClientConfigOverrideable();
            ConfigManagerCore.setConfigOverride(data);
            break;
        case C_ADD_NEW_SCHEMATIC:
            final ISchematicPage page = SchematicRegistry.getMatchingRecipeForID((Integer) this.data.get(0));
            if (!stats.getUnlockedSchematics().contains(page)) {
                stats.getUnlockedSchematics().add(page);
            }
            break;
        case C_UPDATE_SCHEMATIC_LIST:
            for (Object o : this.data) {
                Integer schematicID = (Integer) o;
                if (schematicID != -2) {
                    Collections.sort(stats.getUnlockedSchematics());
                    if (!stats.getUnlockedSchematics().contains(SchematicRegistry.getMatchingRecipeForID(schematicID))) {
                        stats.getUnlockedSchematics().add(SchematicRegistry.getMatchingRecipeForID(schematicID));
                    }
                }
            }
            break;
        case C_PLAY_SOUND_BOSS_DEATH:
            player.playSound(Constants.TEXTURE_PREFIX + "entity.bossdeath", 10.0F, (Float) this.data.get(0));
            break;
        case C_PLAY_SOUND_EXPLODE:
            player.playSound("random.explode", 10.0F, 0.7F);
            break;
        case C_PLAY_SOUND_BOSS_LAUGH:
            player.playSound(Constants.TEXTURE_PREFIX + "entity.bosslaugh", 10.0F, 1.1F);
            break;
        case C_PLAY_SOUND_BOW:
            player.playSound("random.bow", 10.0F, 0.2F);
            break;
        case C_UPDATE_OXYGEN_VALIDITY:
            stats.setOxygenSetupValid((Boolean) this.data.get(0));
            break;
        case C_OPEN_PARACHEST_GUI:
            switch((Integer) this.data.get(1)) {
                case 0:
                    if (player.ridingEntity instanceof EntityBuggy) {
                        FMLClientHandler.instance().getClient().displayGuiScreen(new GuiBuggy(player.inventory, (EntityBuggy) player.ridingEntity, ((EntityBuggy) player.ridingEntity).getType()));
                        player.openContainer.windowId = (Integer) this.data.get(0);
                    }
                    break;
                case 1:
                    int entityID = (Integer) this.data.get(2);
                    Entity entity = player.worldObj.getEntityByID(entityID);
                    if (entity != null && entity instanceof IInventorySettable) {
                        FMLClientHandler.instance().getClient().displayGuiScreen(new GuiParaChest(player.inventory, (IInventorySettable) entity));
                    }
                    player.openContainer.windowId = (Integer) this.data.get(0);
                    break;
            }
            break;
        case C_UPDATE_WIRE_BOUNDS:
            TileEntity tile = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tile instanceof TileBaseConductor) {
                ((TileBaseConductor) tile).adjacentConnections = null;
                player.worldObj.getBlockState(tile.getPos()).getBlock().setBlockBoundsBasedOnState(player.worldObj, tile.getPos());
            }
            break;
        case C_OPEN_SPACE_RACE_GUI:
            if (Minecraft.getMinecraft().currentScreen == null) {
                TickHandlerClient.spaceRaceGuiScheduled = false;
                player.openGui(GalacticraftCore.instance, GuiIdsCore.SPACE_RACE_START, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
            } else {
                TickHandlerClient.spaceRaceGuiScheduled = true;
            }
            break;
        case C_UPDATE_SPACE_RACE_DATA:
            Integer teamID = (Integer) this.data.get(0);
            String teamName = (String) this.data.get(1);
            FlagData flagData = (FlagData) this.data.get(2);
            Vector3 teamColor = (Vector3) this.data.get(3);
            List<String> playerList = new ArrayList<String>();
            for (int i = 4; i < this.data.size(); i++) {
                String playerName = (String) this.data.get(i);
                ClientProxyCore.flagRequestsSent.remove(playerName);
                playerList.add(playerName);
            }
            SpaceRace race = new SpaceRace(playerList, teamName, flagData, teamColor);
            race.setSpaceRaceID(teamID);
            SpaceRaceManager.addSpaceRace(race);
            break;
        case C_OPEN_JOIN_RACE_GUI:
            stats.setSpaceRaceInviteTeamID((Integer) this.data.get(0));
            player.openGui(GalacticraftCore.instance, GuiIdsCore.SPACE_RACE_JOIN, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
            break;
        case C_UPDATE_DUNGEON_DIRECTION:
            stats.setDungeonDirection((Float) this.data.get(0));
            break;
        case C_UPDATE_FOOTPRINT_LIST:
            List<Footprint> printList = new ArrayList<Footprint>();
            long chunkKey = (Long) this.data.get(0);
            for (int i = 1; i < this.data.size(); i++) {
                Footprint print = (Footprint) this.data.get(i);
                if (!print.owner.equals(player.getName())) {
                    printList.add(print);
                }
            }
            FootprintRenderer.setFootprints(chunkKey, printList);
            break;
        case C_FOOTPRINTS_REMOVED:
            long chunkKey0 = (Long) this.data.get(0);
            BlockVec3 position = (BlockVec3) this.data.get(1);
            List<Footprint> footprintList = FootprintRenderer.footprints.get(chunkKey0);
            List<Footprint> toRemove = new ArrayList<Footprint>();
            if (footprintList != null) {
                for (Footprint footprint : footprintList) {
                    if (footprint.position.x > position.x && footprint.position.x < position.x + 1 && footprint.position.z > position.z && footprint.position.z < position.z + 1) {
                        toRemove.add(footprint);
                    }
                }
            }
            if (!toRemove.isEmpty()) {
                footprintList.removeAll(toRemove);
                FootprintRenderer.footprints.put(chunkKey0, footprintList);
            }
            break;
        case C_UPDATE_STATION_SPIN:
            if (playerBaseClient.worldObj.provider instanceof WorldProviderSpaceStation) {
                ((WorldProviderSpaceStation) playerBaseClient.worldObj.provider).getSpinManager().setSpinRate((Float) this.data.get(0), (Boolean) this.data.get(1));
            }
            break;
        case C_UPDATE_STATION_DATA:
            if (playerBaseClient.worldObj.provider instanceof WorldProviderSpaceStation) {
                ((WorldProviderSpaceStation) playerBaseClient.worldObj.provider).getSpinManager().setSpinCentre((Double) this.data.get(0), (Double) this.data.get(1));
            }
            break;
        case C_UPDATE_STATION_BOX:
            if (playerBaseClient.worldObj.provider instanceof WorldProviderSpaceStation) {
                ((WorldProviderSpaceStation) playerBaseClient.worldObj.provider).getSpinManager().setSpinBox((Integer) this.data.get(0), (Integer) this.data.get(1), (Integer) this.data.get(2), (Integer) this.data.get(3), (Integer) this.data.get(4), (Integer) this.data.get(5));
            }
            break;
        case C_UPDATE_THERMAL_LEVEL:
            stats.setThermalLevel((Integer) this.data.get(0));
            stats.setThermalLevelNormalising((Boolean) this.data.get(1));
            break;
        case C_DISPLAY_ROCKET_CONTROLS:
            player.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.spaceKey.getKeyCode()) + "  - " + GCCoreUtil.translate("gui.rocket.launch.name")));
            player.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.leftKey.getKeyCode()) + " / " + GameSettings.getKeyDisplayString(KeyHandlerClient.rightKey.getKeyCode()) + "  - " + GCCoreUtil.translate("gui.rocket.turn.name")));
            player.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.accelerateKey.getKeyCode()) + " / " + GameSettings.getKeyDisplayString(KeyHandlerClient.decelerateKey.getKeyCode()) + "  - " + GCCoreUtil.translate("gui.rocket.updown.name")));
            player.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.openFuelGui.getKeyCode()) + "       - " + GCCoreUtil.translate("gui.rocket.inv.name")));
            break;
        case C_GET_CELESTIAL_BODY_LIST:
            String str = "";
            for (CelestialBody cBody : GalaxyRegistry.getRegisteredPlanets().values()) {
                str = str.concat(cBody.getUnlocalizedName() + ";");
            }
            for (CelestialBody cBody : GalaxyRegistry.getRegisteredMoons().values()) {
                str = str.concat(cBody.getUnlocalizedName() + ";");
            }
            for (CelestialBody cBody : GalaxyRegistry.getRegisteredSatellites().values()) {
                str = str.concat(cBody.getUnlocalizedName() + ";");
            }
            for (SolarSystem solarSystem : GalaxyRegistry.getRegisteredSolarSystems().values()) {
                str = str.concat(solarSystem.getUnlocalizedName() + ";");
            }
            GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_COMPLETE_CBODY_HANDSHAKE, getDimensionID(), new Object[] { str }));
            break;
        case C_UPDATE_ENERGYUNITS:
            CommandGCEnergyUnits.handleParamClientside((Integer) this.data.get(0));
            break;
        case C_RESPAWN_PLAYER:
            final WorldProvider provider = WorldUtil.getProviderForNameClient((String) this.data.get(0));
            final int dimID = GCCoreUtil.getDimensionID(provider);
            if (ConfigManagerCore.enableDebug) {
                GCLog.info("DEBUG: Client receiving respawn packet for dim " + dimID);
            }
            int par2 = (Integer) this.data.get(1);
            String par3 = (String) this.data.get(2);
            int par4 = (Integer) this.data.get(3);
            WorldUtil.forceRespawnClient(dimID, par2, par3, par4);
            break;
        case C_UPDATE_STATS:
            stats.setBuildFlags((Integer) this.data.get(0));
            BlockPanelLighting.updateClient(this.data);
            break;
        case C_UPDATE_TELEMETRY:
            tile = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tile instanceof TileEntityTelemetry) {
                ((TileEntityTelemetry) tile).receiveUpdate(data, this.getDimensionID());
            }
            break;
        case C_SEND_PLAYERSKIN:
            String strName = (String) this.data.get(0);
            String s1 = (String) this.data.get(1);
            String s2 = (String) this.data.get(2);
            String strUUID = (String) this.data.get(3);
            GameProfile gp = PlayerUtil.getOtherPlayerProfile(strName);
            if (gp == null) {
                gp = PlayerUtil.makeOtherPlayerProfile(strName, strUUID);
            }
            gp.getProperties().put("textures", new Property("textures", s1, s2));
            break;
        case C_SEND_OVERWORLD_IMAGE:
            try {
                int cx = (Integer) this.data.get(0);
                int cz = (Integer) this.data.get(1);
                byte[] bytes = (byte[]) this.data.get(2);
                MapUtil.receiveOverworldImageCompressed(cx, cz, bytes);
            } catch (Exception e) {
                e.printStackTrace();
            }
            break;
        case C_RECOLOR_PIPE:
            TileEntity tileEntity = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tileEntity instanceof TileEntityFluidPipe) {
                TileEntityFluidPipe pipe = (TileEntityFluidPipe) tileEntity;
                pipe.getNetwork().split(pipe);
                pipe.setNetwork(null);
            }
            break;
        case C_RECOLOR_ALL_GLASS:
            BlockSpaceGlass.updateGlassColors((Integer) this.data.get(0), (Integer) this.data.get(1), (Integer) this.data.get(2));
            break;
        case C_UPDATE_MACHINE_DATA:
            TileEntity tile3 = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tile3 instanceof ITileClientUpdates) {
                ((ITileClientUpdates) tile3).updateClient(this.data);
            }
            break;
        case C_LEAK_DATA:
            TileEntity tile4 = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tile4 instanceof TileEntityOxygenSealer) {
                ((ITileClientUpdates) tile4).updateClient(this.data);
            }
            break;
        case C_SPAWN_HANGING_SCHEMATIC:
            EntityHangingSchematic entity = new EntityHangingSchematic(player.worldObj, (BlockPos) this.data.get(0), EnumFacing.getFront((Integer) this.data.get(2)), (Integer) this.data.get(3));
            ((WorldClient) player.worldObj).addEntityToWorld((Integer) this.data.get(1), entity);
            break;
        default:
            break;
    }
}
Also used : IControllableEntity(micdoodle8.mods.galacticraft.core.entities.IControllableEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) TileBaseConductor(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseConductor) SolarSystem(micdoodle8.mods.galacticraft.api.galaxies.SolarSystem) EntityBuggy(micdoodle8.mods.galacticraft.core.entities.EntityBuggy) WorldProvider(net.minecraft.world.WorldProvider) EntityFXSparks(micdoodle8.mods.galacticraft.core.client.fx.EntityFXSparks) EntityFX(net.minecraft.client.particle.EntityFX) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) EnumExtendedInventorySlot(micdoodle8.mods.galacticraft.api.item.EnumExtendedInventorySlot) GuiParaChest(micdoodle8.mods.galacticraft.core.client.gui.container.GuiParaChest) WorldClient(net.minecraft.client.multiplayer.WorldClient) EntityHangingSchematic(micdoodle8.mods.galacticraft.core.entities.EntityHangingSchematic) GuiCelestialSelection(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiCelestialSelection) GameProfile(com.mojang.authlib.GameProfile) EntityPlayer(net.minecraft.entity.player.EntityPlayer) GuiBuggy(micdoodle8.mods.galacticraft.core.client.gui.container.GuiBuggy) SpaceRace(micdoodle8.mods.galacticraft.core.dimension.SpaceRace) ITileClientUpdates(micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates) Satellite(micdoodle8.mods.galacticraft.api.galaxies.Satellite) TileEntity(net.minecraft.tileentity.TileEntity) FlagData(micdoodle8.mods.galacticraft.core.wrappers.FlagData) WorldProviderSpaceStation(micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation) CelestialBody(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody) PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData) EnumModelPacketType(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerHandler.EnumModelPacketType) Property(com.mojang.authlib.properties.Property) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3) SpaceStationWorldData(micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData) IInventorySettable(micdoodle8.mods.galacticraft.core.inventory.IInventorySettable) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) Minecraft(net.minecraft.client.Minecraft) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) IOException(java.io.IOException) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with PlayerGearData

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

the class CommonProxyCore method getGearData.

public PlayerGearData getGearData(EntityPlayer player) {
    GCPlayerStats stats = GCPlayerStats.get(player);
    int mask = stats.getMaskInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getMaskInSlot(), EnumExtendedInventorySlot.MASK);
    int gear = stats.getGearInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getGearInSlot(), EnumExtendedInventorySlot.GEAR);
    int leftTank = stats.getTankInSlot1() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getTankInSlot1(), EnumExtendedInventorySlot.LEFT_TANK);
    int rightTank = stats.getTankInSlot2() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getTankInSlot2(), EnumExtendedInventorySlot.RIGHT_TANK);
    int frequencyModule = stats.getFrequencyModuleInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getFrequencyModuleInSlot(), EnumExtendedInventorySlot.FREQUENCY_MODULE);
    int[] thermalPadding = new int[4];
    thermalPadding[0] = stats.getThermalHelmetInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getThermalHelmetInSlot(), EnumExtendedInventorySlot.THERMAL_HELMET);
    thermalPadding[1] = stats.getThermalChestplateInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getThermalChestplateInSlot(), EnumExtendedInventorySlot.THERMAL_CHESTPLATE);
    thermalPadding[2] = stats.getThermalLeggingsInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getThermalLeggingsInSlot(), EnumExtendedInventorySlot.THERMAL_LEGGINGS);
    thermalPadding[3] = stats.getThermalBootsInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getThermalBootsInSlot(), EnumExtendedInventorySlot.THERMAL_BOOTS);
    // TODO: Parachute
    return new PlayerGearData(player, mask, gear, leftTank, rightTank, frequencyModule, thermalPadding);
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

Example 9 with PlayerGearData

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

the class LayerShield method doRenderLayer.

@Override
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float f2, float f3, float partialTicks, float f5, float f6, float f7, float scale) {
    if (!entitylivingbaseIn.isInvisible()) {
        PlayerGearData gearData = GalacticraftCore.proxy.getGearData((EntityPlayer) entitylivingbaseIn);
        if (gearData != null) {
            if (gearData.getShieldController() != GCPlayerHandler.GEAR_NOT_PRESENT) {
                this.shieldModel.setInvisible(false);
                this.shieldModel.bipedRightLeg.showModel = true;
                this.shieldModel.bipedLeftLeg.showModel = true;
                this.shieldModel.bipedBody.showModel = true;
                this.shieldModel.bipedRightArm.showModel = true;
                this.shieldModel.bipedLeftArm.showModel = true;
                this.shieldModel.bipedHead.showModel = true;
                this.shieldModel.bipedHeadwear.showModel = true;
                this.shieldModel.setModelAttributes(this.renderer.getMainModel());
                this.shieldModel.setLivingAnimations(entitylivingbaseIn, f2, f3, partialTicks);
                this.renderer.bindTexture(RenderPlayerGC.thermalPaddingTexture0);
                GlStateManager.matrixMode(5890);
                GlStateManager.loadIdentity();
                float f = (float) Math.sin((entitylivingbaseIn.ticksExisted + partialTicks) / 20.0F) * 5.0F;
                GlStateManager.translate(0.0F, f * 0.01F, 0.0F);
                GlStateManager.matrixMode(5888);
                GL11.glDisable(GL11.GL_LIGHTING);
                Minecraft.getMinecraft().renderEngine.bindTexture(RenderPlayerGC.heatShieldTexture);
                GL11.glEnable(GL11.GL_BLEND);
                float sTime = (float) ((1.0F - Math.sin((entitylivingbaseIn.ticksExisted + partialTicks) / 10.0F)) * 0.1F + 0.0F);
                float r = 0.9F * sTime;
                float g = 0.2F * sTime;
                float b = 0.9F * sTime;
                GlStateManager.depthMask(true);
                GL11.glColor4f(r, g, b, 0.2F);
                GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
                this.shieldModel.render(entitylivingbaseIn, f2, f3, f5, f6, f7, scale);
                GlStateManager.matrixMode(5890);
                GlStateManager.loadIdentity();
                GlStateManager.matrixMode(5888);
                GL11.glColor4f(1, 1, 1, 1);
                GL11.glDisable(GL11.GL_BLEND);
                GL11.glEnable(GL11.GL_ALPHA_TEST);
                GL11.glEnable(GL11.GL_LIGHTING);
            }
        }
    }
}
Also used : PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

Example 10 with PlayerGearData

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

the class ModelBipedGC method setRotationAngles.

public static void setRotationAngles(ModelBiped biped, float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) {
    if (!(par7Entity instanceof EntityPlayer))
        return;
    final EntityPlayer player = (EntityPlayer) par7Entity;
    final ItemStack currentItemStack = player.inventory.getCurrentItem();
    final float floatPI = 3.1415927F;
    if (!par7Entity.onGround && par7Entity.worldObj.provider instanceof IGalacticraftWorldProvider && par7Entity.ridingEntity == null && !(currentItemStack != null && currentItemStack.getItem() instanceof IHoldableItem)) {
        float speedModifier = 0.1162F * 2;
        float angularSwingArm = MathHelper.cos(par1 * (speedModifier / 2));
        float rightMod = biped.heldItemRight != 0 ? 1 : 2;
        biped.bipedRightArm.rotateAngleX -= MathHelper.cos(par1 * 0.6662F + floatPI) * rightMod * par2 * 0.5F;
        biped.bipedLeftArm.rotateAngleX -= MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
        biped.bipedRightArm.rotateAngleX += -angularSwingArm * 4.0F * par2 * 0.5F;
        biped.bipedLeftArm.rotateAngleX += angularSwingArm * 4.0F * par2 * 0.5F;
        biped.bipedLeftLeg.rotateAngleX -= MathHelper.cos(par1 * 0.6662F + floatPI) * 1.4F * par2;
        biped.bipedLeftLeg.rotateAngleX += MathHelper.cos(par1 * 0.1162F * 2 + floatPI) * 1.4F * par2;
        biped.bipedRightLeg.rotateAngleX -= MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;
        biped.bipedRightLeg.rotateAngleX += MathHelper.cos(par1 * 0.1162F * 2) * 1.4F * par2;
    }
    PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
    if (gearData != null) {
        if (gearData.getParachute() != null) {
            // Parachute is equipped
            biped.bipedLeftArm.rotateAngleX += floatPI;
            biped.bipedLeftArm.rotateAngleZ += floatPI / 10;
            biped.bipedRightArm.rotateAngleX += floatPI;
            biped.bipedRightArm.rotateAngleZ -= floatPI / 10;
        }
    }
    if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof IHoldableItem && !(player.ridingEntity instanceof ICameraZoomEntity)) {
        Item heldItem = player.inventory.getCurrentItem().getItem();
        IHoldableItem holdableItem = (IHoldableItem) heldItem;
        IHoldableItemCustom holdableItemCustom = heldItem instanceof IHoldableItemCustom ? (IHoldableItemCustom) heldItem : null;
        if (holdableItem.shouldHoldLeftHandUp(player)) {
            Vector3 angle = null;
            if (holdableItemCustom != null) {
                angle = holdableItemCustom.getLeftHandRotation(player);
            }
            if (angle == null) {
                angle = new Vector3(floatPI + 0.3F, 0.0F, floatPI / 10.0F);
            }
            biped.bipedLeftArm.rotateAngleX = angle.floatX();
            biped.bipedLeftArm.rotateAngleY = angle.floatY();
            biped.bipedLeftArm.rotateAngleZ = angle.floatZ();
        }
        if (holdableItem.shouldHoldRightHandUp(player)) {
            Vector3 angle = null;
            if (holdableItemCustom != null) {
                angle = holdableItemCustom.getRightHandRotation(player);
            }
            if (angle == null) {
                angle = new Vector3(floatPI + 0.3F, 0.0F, (float) -Math.PI / 10.0F);
            }
            biped.bipedRightArm.rotateAngleX = angle.floatX();
            biped.bipedRightArm.rotateAngleY = angle.floatY();
            biped.bipedRightArm.rotateAngleZ = angle.floatZ();
        }
    }
    final List<?> l = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.fromBounds(player.posX - 20, 0, player.posZ - 20, player.posX + 20, 200, player.posZ + 20));
    for (int i = 0; i < l.size(); i++) {
        final Entity e = (Entity) l.get(i);
        if (e instanceof EntityTieredRocket) {
            final EntityTieredRocket ship = (EntityTieredRocket) e;
            if (ship.riddenByEntity != null && !(ship.riddenByEntity).equals(player) && (ship.getLaunched() || ship.timeUntilLaunch < 390)) {
                biped.bipedRightArm.rotateAngleZ -= floatPI / 8F + MathHelper.sin(par3 * 0.9F) * 0.2F;
                biped.bipedRightArm.rotateAngleX = floatPI;
                break;
            }
        }
    }
    if (player.isPlayerSleeping() && GalacticraftCore.isPlanetsLoaded) {
        RenderPlayerGC.RotatePlayerEvent event = new RenderPlayerGC.RotatePlayerEvent((AbstractClientPlayer) player);
        MinecraftForge.EVENT_BUS.post(event);
        if (event.vanillaOverride && (event.shouldRotate == null || event.shouldRotate)) {
            biped.bipedHead.rotateAngleX = (float) (20.0F - Math.sin(player.ticksExisted / 10.0F) / 7.0F);
            biped.bipedHead.rotateAngleY = 0.0F;
            biped.bipedHead.rotateAngleZ = 0.0F;
            biped.bipedLeftArm.rotateAngleX = 0.0F;
            biped.bipedLeftArm.rotateAngleY = 0.0F;
            biped.bipedLeftArm.rotateAngleZ = 0.0F;
            biped.bipedRightArm.rotateAngleX = 0.0F;
            biped.bipedRightArm.rotateAngleY = 0.0F;
            biped.bipedRightArm.rotateAngleZ = 0.0F;
        }
    }
    if (biped instanceof ModelPlayer) {
        ModelBiped.copyModelAngles(biped.bipedHead, ((ModelPlayer) biped).bipedHeadwear);
    }
}
Also used : Entity(net.minecraft.entity.Entity) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) EntityTieredRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket) RenderPlayerGC(micdoodle8.mods.galacticraft.core.client.render.entities.RenderPlayerGC) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) IHoldableItemCustom(micdoodle8.mods.galacticraft.api.item.IHoldableItemCustom) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) Item(net.minecraft.item.Item) IHoldableItem(micdoodle8.mods.galacticraft.api.item.IHoldableItem) ModelPlayer(net.minecraft.client.model.ModelPlayer) IHoldableItem(micdoodle8.mods.galacticraft.api.item.IHoldableItem) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) 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