Работа с GalactiCraft API.

1,057
50
234
Добрый день.
Есть ли тут те, кто работает\работал с данным модом и с API этого мода?

В GalactiCraft3 изменили галактическую карту, добавив все планеты нашей системы, но только 3 из них можно посетить (Земля, Марс, Астероиды(хоть и не планета)). Остальные же планеты сделаны "для красоты".

Вопрос: как создать, допустим Венеру?

Попытался скопировать из GalactiCraftPlanets. Но все без изменений.
Вот пакет аддона.

Где я криворукий?
 
Находил туториал по созданию луны.
А туториалы на офф сайте "изчезли".
 
Ситуация такая:
В главном классе мода есть строчки:
Код:
GalacticraftCore.planetVenus = (Planet) new Planet("venus").setParentSolarSystem(GalacticraftCore.solarSystemSol).setRingColorRGB(0.1F, 0.9F, 0.6F).setPhaseShift(2.0F).setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(0.75F, 0.75F)).setRelativeOrbitTime(0.61527929901423877327491785323111F);
        GalacticraftCore.planetVenus.setBodyIcon(new ResourceLocation(GalacticraftCore.ASSET_PREFIX, "textures/gui/celestialbodies/venus.png"));

Код:
        GalaxyRegistry.registerPlanet(GalacticraftCore.planetVenus);

Вопрос: как отловить регистрацию планеты?
Чтобы ГК не регистрировал планету из главного класса?
 
Удали из карты планет и карты айди планет уже зареганную планету и замени её своей.
 
-_- Это получается посмотреть в класс GalaxyRegistry, и увидеть там карту планет и карта айди планет, которую можно менять только через рефлексию.
 
Код:
package micdoodle8.mods.galacticraft.api.galaxies;

import com.google.common.collect.*;

import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.common.MinecraftForge;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/**
 * Credits to KingLemming and CovertJaguar, since this is based on the
 * Liquid/Fluid API
 */
public class GalaxyRegistry
{
    static int maxSolarSystemID = 0;
    static int maxPlanetID = 0;
    static int maxMoonID = 0;
    static int maxSatelliteID = 0;
    static HashMap<String, SolarSystem> solarSystems = Maps.newHashMap();
    static BiMap<String, Integer> solarSystemIDs = HashBiMap.create();
    static TreeMap<String, Planet> planets = Maps.newTreeMap();
    static BiMap<String, Integer> planetIDs = HashBiMap.create();
    static TreeMap<String, Moon> moons = Maps.newTreeMap();
    static BiMap<String, Integer> moonIDs = HashBiMap.create();
    static HashMap<String, Satellite> satellites = Maps.newHashMap();
    static BiMap<String, Integer> satelliteIDs = HashBiMap.create();
    static HashMap<Planet, List<Moon>> moonList = Maps.newHashMap();
    static HashMap<CelestialBody, List<Satellite>> satelliteList = Maps.newHashMap();
    static HashMap<SolarSystem, List<Planet>> solarSystemList = Maps.newHashMap();

    public static CelestialBody getCelestialBodyFromDimensionID(int dimensionID)
    {
        for (Planet planet : GalaxyRegistry.planets.values())
        {
            if (planet.getDimensionID() == dimensionID)
            {
                return planet;
            }
        }

        for (Moon moon : GalaxyRegistry.moons.values())
        {
            if (moon.getDimensionID() == dimensionID)
            {
                return moon;
            }
        }

        for (Satellite satellite : GalaxyRegistry.satellites.values())
        {
            if (satellite.getDimensionID() == dimensionID)
            {
                return satellite;
            }
        }

        return null;
    }

    public static void refreshGalaxies()
    {
        GalaxyRegistry.moonList.clear();
        GalaxyRegistry.satelliteList.clear();

        for (Moon moon : GalaxyRegistry.getRegisteredMoons().values())
        {
            Planet planet = moon.getParentPlanet();
            List<Moon> listOfMoons = GalaxyRegistry.moonList.get(planet);
            if (listOfMoons == null)
            {
                listOfMoons = new ArrayList<Moon>();
            }
            listOfMoons.add(moon);
            GalaxyRegistry.moonList.put(planet, listOfMoons);
        }

        for (Satellite satellite : GalaxyRegistry.getRegisteredSatellites().values())
        {
            CelestialBody celestialBody = satellite.getParentPlanet();
            List<Satellite> satelliteList1 = GalaxyRegistry.satelliteList.get(celestialBody);
            if (satelliteList1 == null)
            {
                satelliteList1 = new ArrayList<Satellite>();
            }
            satelliteList1.add(satellite);
            GalaxyRegistry.satelliteList.put(celestialBody, satelliteList1);
        }

        for (Planet planet : GalaxyRegistry.getRegisteredPlanets().values())
        {
            SolarSystem solarSystem = planet.getParentSolarSystem();
            List<Planet> planetList = GalaxyRegistry.solarSystemList.get(solarSystem);
            if (planetList == null)
            {
                planetList = new ArrayList<Planet>();
            }
            planetList.add(planet);
            GalaxyRegistry.solarSystemList.put(solarSystem, planetList);
        }
    }

    public static List<Planet> getPlanetsForSolarSystem(SolarSystem solarSystem)
    {
        List<Planet> solarSystemListLocal = GalaxyRegistry.solarSystemList.get(solarSystem);

        if (solarSystemListLocal == null)
        {
            return new ArrayList<Planet>();
        }

        return ImmutableList.copyOf(solarSystemListLocal);
    }

    public static List<Moon> getMoonsForPlanet(Planet planet)
    {
        List<Moon> moonListLocal = GalaxyRegistry.moonList.get(planet);

        if (moonListLocal == null)
        {
            return new ArrayList<Moon>();
        }

        return ImmutableList.copyOf(moonListLocal);
    }

    public static List<Satellite> getSatellitesForCelestialBody(CelestialBody celestialBody)
    {
        List<Satellite> satelliteList1 = GalaxyRegistry.satelliteList.get(celestialBody);

        if (satelliteList1 == null)
        {
            return new ArrayList<Satellite>();
        }

        return ImmutableList.copyOf(satelliteList1);
    }

    public static CelestialBody getCelestialBodyFromUnlocalizedName(String unlocalizedName)
    {
        for (Planet planet : GalaxyRegistry.planets.values())
        {
            if (planet.getUnlocalizedName().equals(unlocalizedName))
            {
                return planet;
            }
        }

        for (Moon moon : GalaxyRegistry.moons.values())
        {
            if (moon.getUnlocalizedName().equals(unlocalizedName))
            {
                return moon;
            }
        }

        return null;
    }

    public static boolean registerSolarSystem(SolarSystem solarSystem)
    {
        if (GalaxyRegistry.solarSystemIDs.containsKey(solarSystem.getName()))
        {
            return false;
        }

        GalaxyRegistry.solarSystems.put(solarSystem.getName(), solarSystem);
        GalaxyRegistry.solarSystemIDs.put(solarSystem.getName(), ++GalaxyRegistry.maxSolarSystemID);

        MinecraftForge.EVENT_BUS.post(new SolarSystemRegisterEvent(solarSystem.getName(), GalaxyRegistry.maxSolarSystemID));
        return true;
    }

    public static boolean registerPlanet(Planet planet)
    {
        if (GalaxyRegistry.planetIDs.containsKey(planet.getName()))
        {
            return false;
        }

        GalaxyRegistry.planets.put(planet.getName(), planet);
        GalaxyRegistry.planetIDs.put(planet.getName(), ++GalaxyRegistry.maxPlanetID);

        MinecraftForge.EVENT_BUS.post(new PlanetRegisterEvent(planet.getName(), GalaxyRegistry.maxPlanetID));
        return true;
    }

    public static boolean registerMoon(Moon moon)
    {
        if (GalaxyRegistry.moonIDs.containsKey(moon.getName()))
        {
            return false;
        }

        GalaxyRegistry.moons.put(moon.getName(), moon);
        GalaxyRegistry.moonIDs.put(moon.getName(), ++GalaxyRegistry.maxMoonID);

        MinecraftForge.EVENT_BUS.post(new MoonRegisterEvent(moon.getName(), GalaxyRegistry.maxMoonID));
        return true;
    }

    public static boolean registerSatellite(Satellite satellite)
    {
        if (GalaxyRegistry.satelliteIDs.containsKey(satellite.getName()))
        {
            return false;
        }

        GalaxyRegistry.satellites.put(satellite.getName(), satellite);
        GalaxyRegistry.satelliteIDs.put(satellite.getName(), ++GalaxyRegistry.maxSatelliteID);

        MinecraftForge.EVENT_BUS.post(new SatelliteRegisterEvent(satellite.getName(), GalaxyRegistry.maxSatelliteID));
        return true;
    }

    /**
     * Returns a read-only map containing Solar System Names and their
     * associated Solar Systems.
     */
    public static Map<String, SolarSystem> getRegisteredSolarSystems()
    {
        return ImmutableMap.copyOf(GalaxyRegistry.solarSystems);
    }

    /**
     * Returns a read-only map containing Solar System Names and their
     * associated IDs.
     */
    public static Map<String, Integer> getRegisteredSolarSystemIDs()
    {
        return ImmutableMap.copyOf(GalaxyRegistry.solarSystemIDs);
    }

    /**
     * Returns a read-only map containing Planet Names and their associated
     * Planets.
     */
    public static Map<String, Planet> getRegisteredPlanets()
    {
        return (Map<String, Planet>) GalaxyRegistry.planets.clone();
    }

    /**
     * Returns a read-only map containing Planet Names and their associated IDs.
     */
    public static Map<String, Integer> getRegisteredPlanetIDs()
    {
        return ImmutableMap.copyOf(GalaxyRegistry.planetIDs);
    }

    /**
     * Returns a read-only map containing Moon Names and their associated Moons.
     */
    public static Map<String, Moon> getRegisteredMoons()
    {
        return (Map<String, Moon>) GalaxyRegistry.moons.clone();
    }

    /**
     * Returns a read-only map containing Moon Names and their associated IDs.
     */
    public static Map<String, Integer> getRegisteredMoonIDs()
    {
        return ImmutableMap.copyOf(GalaxyRegistry.moonIDs);
    }

    /**
     * Returns a read-only map containing Satellite Names and their associated Satellite.
     */
    public static Map<String, Satellite> getRegisteredSatellites()
    {
        return ImmutableMap.copyOf(GalaxyRegistry.satellites);
    }

    /**
     * Returns a read-only map containing Satellite Names and their associated IDs.
     */
    public static Map<String, Integer> getRegisteredSatelliteIDs()
    {
        return ImmutableMap.copyOf(GalaxyRegistry.satelliteIDs);
    }

    public static int getSolarSystemID(String solarSystemName)
    {
        return GalaxyRegistry.solarSystemIDs.get(solarSystemName);
    }

    public static int getPlanetID(String planetName)
    {
        return GalaxyRegistry.planetIDs.get(planetName);
    }

    public static int getMoonID(String moonName)
    {
        return GalaxyRegistry.moonIDs.get(moonName);
    }

    public static int getSatelliteID(String satelliteName)
    {
        return GalaxyRegistry.satelliteIDs.get(satelliteName);
    }

    public static class SolarSystemRegisterEvent extends Event
    {
        public final String solarSystemName;
        public final int solarSystemID;

        public SolarSystemRegisterEvent(String solarSystemName, int solarSystemID)
        {
            this.solarSystemName = solarSystemName;
            this.solarSystemID = solarSystemID;
        }
    }

    public static class PlanetRegisterEvent extends Event
    {
        public final String planetName;
        public final int planetID;

        public PlanetRegisterEvent(String planetName, int planetID)
        {
            this.planetName = planetName;
            this.planetID = planetID;
        }
    }

    public static class MoonRegisterEvent extends Event
    {
        public final String moonName;
        public final int moonID;

        public MoonRegisterEvent(String moonName, int moonID)
        {
            this.moonName = moonName;
            this.moonID = moonID;
        }
    }

    public static class SatelliteRegisterEvent extends Event
    {
        public final String satelliteName;
        public final int satelliteID;

        public SatelliteRegisterEvent(String satelliteName, int satelliteID)
        {
            this.satelliteName = satelliteName;
            this.satelliteID = satelliteID;
        }
    }
}
 
Код:
  static TreeMap<String, Planet> planets = Maps.newTreeMap();
    static BiMap<String, Integer> planetIDs = HashBiMap.create();
 
В моем случае, получается что надо эти две строчки воткнуть в главный класс аддона?

Код:
 static TreeMap<String, Planet> planetVenus = Maps.newTreeMap();
    static BiMap<String, Integer> planetIDs = HashBiMap.create();

 
Но где получить ID планеты? или поставить произвольный?
 
Дали ответ на офф форуме:
"CelestialBody.getReachable() needs to return true."

Воткнул ф-цию:
planetVenus.getReachable();

Как ее вернуть к истине?
 
Воткнул в VenusWorldProvider

public boolean getReachable()
{
return true;
}

Один хрен не работает....

Уже написал на офф форум....
 
Ребят, как функцию planetVenus.getReachable(); вернуть к true?

В этом коде:
Код:
 public void init(FMLInitializationEvent event)

 { 
 planetVenus = (new Planet("venus")).setParentSolarSystem(GalacticraftCore.solarSystemSol);
 planetVenus.setRingColorRGB(58.07F, 1.54F, 1.93F);
 planetVenus.setPhaseShift(2.0F);
 planetVenus.setRelativeSize(0.5319F);
 planetVenus.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(0.75F, 0.75F));
 planetVenus.setRelativeOrbitTime(0.61527929901423877327491785323111F);
 planetVenus.setBodyIcon(new ResourceLocation("venusaddon:textures/gui/celestialbodies/venus.png"));
 planetVenus.setDimensionInfo(ConfigManagerVenus.dimensionIDVenus, VenusWorldProvider.class, true).setTierRequired(2);
 planetVenus.atmosphereComponent(IAtmosphericGas.ARGON);
 planetVenus.getReachable();
 
 GalaxyRegistry.registerPlanet(planetVenus); 
 GalacticraftRegistry.registerTeleportType(VenusWorldProvider.class, new TeleportTypeVenus());
 
 CreativeTabsBlesse.BlesseBlocksTab = new CreativeTabGC(CreativeTabs.getNextID(), "AddonsGCBlocks", Item.getItemFromBlock(GCBlocks.machineBase2), 0);
 CreativeTabsBlesse.BlesseItemsTab = new CreativeTabGC(CreativeTabs.getNextID(), "AddonsGCItems", Item.getItemFromBlock(GCBlocks.blockMoon), 0);
 

 }
 
Код:
planetVenus = new Planet("venus") {
    @Override
    public boolean getReachable() {
        return true;
    }
};
planetVenus.setParentSolarSystem(GalacticraftCore.solarSystemSol);
<...и остальное...>

P.S. Мне лень ругать тебя за непонимание кода, который ты пишешь.
> Воткнул в VenusWorldProvider
> public boolean getReachable() {
>     return true;
> }

> Один хрен не работает.... действительно, почему?
 
Назад
Сверху