use of micdoodle8.mods.galacticraft.api.world.IOrbitDimension in project Galacticraft by micdoodle8.
the class GalacticraftCore method init.
@EventHandler
public void init(FMLInitializationEvent event) {
GCBlocks.doOtherModsTorches();
GalacticraftCore.handler.registerItemChanges();
GalacticraftCore.galacticraftBlocksTab.setItemForTab(Item.getItemFromBlock(GCBlocks.machineBase2));
GalacticraftCore.galacticraftItemsTab.setItemForTab(GCItems.rocketTier1);
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
GCBlocks.finalizeSort();
GCItems.finalizeSort();
}
GalacticraftCore.proxy.init(event);
GalacticraftCore.packetPipeline = GalacticraftChannelHandler.init();
GalacticraftCore.solarSystemSol = new SolarSystem("sol", "milky_way").setMapPosition(new Vector3(0.0F, 0.0F, 0.0F));
Star starSol = (Star) new Star("sol").setParentSolarSystem(GalacticraftCore.solarSystemSol).setTierRequired(-1);
starSol.setBodyIcon(new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/celestialbodies/sun.png"));
GalacticraftCore.solarSystemSol.setMainStar(starSol);
GalacticraftCore.planetOverworld = (Planet) new Planet("overworld").setParentSolarSystem(GalacticraftCore.solarSystemSol).setRingColorRGB(0.1F, 0.9F, 0.6F).setPhaseShift(0.0F);
GalacticraftCore.planetOverworld.setBodyIcon(new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/celestialbodies/earth.png"));
GalacticraftCore.planetOverworld.setDimensionInfo(ConfigManagerCore.idDimensionOverworld, WorldProvider.class, false).setTierRequired(1);
GalacticraftCore.planetOverworld.atmosphereComponent(EnumAtmosphericGas.NITROGEN).atmosphereComponent(EnumAtmosphericGas.OXYGEN).atmosphereComponent(EnumAtmosphericGas.ARGON).atmosphereComponent(EnumAtmosphericGas.WATER);
GalacticraftCore.planetOverworld.addChecklistKeys("equip_parachute");
GalacticraftCore.moonMoon = (Moon) new Moon("moon").setParentPlanet(GalacticraftCore.planetOverworld).setRelativeSize(0.2667F).setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(13F, 13F)).setRelativeOrbitTime(1 / 0.01F);
GalacticraftCore.moonMoon.setDimensionInfo(ConfigManagerCore.idDimensionMoon, WorldProviderMoon.class).setTierRequired(1);
GalacticraftCore.moonMoon.setBodyIcon(new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/celestialbodies/moon.png"));
GalacticraftCore.moonMoon.setAtmosphere(new AtmosphereInfo(false, false, false, 0.0F, 0.0F, 0.0F));
GalacticraftCore.moonMoon.setBiomeInfo(BiomeGenBaseMoon.moonFlat);
GalacticraftCore.moonMoon.addMobInfo(new SpawnListEntry(EntityEvolvedZombie.class, 8, 2, 3));
GalacticraftCore.moonMoon.addMobInfo(new SpawnListEntry(EntityEvolvedSpider.class, 8, 2, 3));
GalacticraftCore.moonMoon.addMobInfo(new SpawnListEntry(EntityEvolvedSkeleton.class, 8, 2, 3));
GalacticraftCore.moonMoon.addMobInfo(new SpawnListEntry(EntityEvolvedCreeper.class, 8, 2, 3));
GalacticraftCore.moonMoon.addMobInfo(new SpawnListEntry(EntityEvolvedEnderman.class, 10, 1, 4));
GalacticraftCore.moonMoon.addChecklistKeys("equip_oxygen_suit");
// Satellites must always have a WorldProvider implementing IOrbitDimension
GalacticraftCore.satelliteSpaceStation = (Satellite) new Satellite("spacestation.overworld").setParentBody(GalacticraftCore.planetOverworld).setRelativeSize(0.2667F).setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(9F, 9F)).setRelativeOrbitTime(1 / 0.05F);
GalacticraftCore.satelliteSpaceStation.setDimensionInfo(ConfigManagerCore.idDimensionOverworldOrbit, ConfigManagerCore.idDimensionOverworldOrbitStatic, WorldProviderOverworldOrbit.class).setTierRequired(1);
GalacticraftCore.satelliteSpaceStation.setBodyIcon(new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/celestialbodies/space_station.png"));
GalacticraftCore.satelliteSpaceStation.setAtmosphere(new AtmosphereInfo(false, false, false, 0.0F, 0.1F, 0.02F));
GalacticraftCore.satelliteSpaceStation.addChecklistKeys("equip_oxygen_suit", "create_grapple");
ForgeChunkManager.setForcedChunkLoadingCallback(GalacticraftCore.instance, new ChunkLoadingCallback());
MinecraftForge.EVENT_BUS.register(new ConnectionEvents());
SchematicRegistry.registerSchematicRecipe(new SchematicRocketT1());
SchematicRegistry.registerSchematicRecipe(new SchematicMoonBuggy());
SchematicRegistry.registerSchematicRecipe(new SchematicAdd());
ChunkPowerHandler.initiate();
EnergyConfigHandler.initGas();
CompatibilityManager.registerMicroBlocks();
this.registerCreatures();
this.registerOtherEntities();
this.registerTileEntities();
GalaxyRegistry.registerSolarSystem(GalacticraftCore.solarSystemSol);
GalaxyRegistry.registerPlanet(GalacticraftCore.planetOverworld);
GalaxyRegistry.registerMoon(GalacticraftCore.moonMoon);
GalaxyRegistry.registerSatellite(GalacticraftCore.satelliteSpaceStation);
GalacticraftRegistry.registerProvider(ConfigManagerCore.idDimensionOverworldOrbit, WorldProviderOverworldOrbit.class, false, 0);
GalacticraftRegistry.registerProvider(ConfigManagerCore.idDimensionOverworldOrbitStatic, WorldProviderOverworldOrbit.class, true, 0);
GalacticraftRegistry.registerTeleportType(WorldProviderSurface.class, new TeleportTypeOverworld());
GalacticraftRegistry.registerTeleportType(WorldProviderOverworldOrbit.class, new TeleportTypeOrbit());
GalacticraftRegistry.registerTeleportType(WorldProviderMoon.class, new TeleportTypeMoon());
GalacticraftRegistry.registerRocketGui(WorldProviderOverworldOrbit.class, new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/overworld_rocket_gui.png"));
GalacticraftRegistry.registerRocketGui(WorldProviderSurface.class, new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/overworld_rocket_gui.png"));
GalacticraftRegistry.registerRocketGui(WorldProviderMoon.class, new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/moon_rocket_gui.png"));
GalacticraftRegistry.addDungeonLoot(1, new ItemStack(GCItems.schematic, 1, 0));
GalacticraftRegistry.addDungeonLoot(1, new ItemStack(GCItems.schematic, 1, 1));
if (ConfigManagerCore.enableCopperOreGen) {
GameRegistry.registerWorldGenerator(new OverworldGenerator(GCBlocks.basicBlock, 5, 24, 0, 75, 7), 4);
}
if (ConfigManagerCore.enableTinOreGen) {
GameRegistry.registerWorldGenerator(new OverworldGenerator(GCBlocks.basicBlock, 6, 22, 0, 60, 7), 4);
}
if (ConfigManagerCore.enableAluminumOreGen) {
GameRegistry.registerWorldGenerator(new OverworldGenerator(GCBlocks.basicBlock, 7, 18, 0, 45, 7), 4);
}
if (ConfigManagerCore.enableSiliconOreGen) {
GameRegistry.registerWorldGenerator(new OverworldGenerator(GCBlocks.basicBlock, 8, 3, 0, 25, 7), 4);
}
FMLInterModComms.sendMessage("OpenBlocks", "donateUrl", "http://www.patreon.com/micdoodle8");
registerCoreGameScreens();
GCFluids.registerLegacyFluids();
GCFluids.registerDispenserBehaviours();
GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_MASK, EnumExtendedInventorySlot.MASK, GCItems.oxMask);
GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_GEAR, EnumExtendedInventorySlot.GEAR, GCItems.oxygenGear);
GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_LIGHT, EnumExtendedInventorySlot.LEFT_TANK, GCItems.oxTankLight);
GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_LIGHT, EnumExtendedInventorySlot.RIGHT_TANK, GCItems.oxTankLight);
GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_MEDIUM, EnumExtendedInventorySlot.LEFT_TANK, GCItems.oxTankMedium);
GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_MEDIUM, EnumExtendedInventorySlot.RIGHT_TANK, GCItems.oxTankMedium);
GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_HEAVY, EnumExtendedInventorySlot.LEFT_TANK, GCItems.oxTankHeavy);
GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_HEAVY, EnumExtendedInventorySlot.RIGHT_TANK, GCItems.oxTankHeavy);
GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_INFINITE, EnumExtendedInventorySlot.LEFT_TANK, GCItems.oxygenCanisterInfinite);
GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_INFINITE, EnumExtendedInventorySlot.RIGHT_TANK, GCItems.oxygenCanisterInfinite);
GalacticraftRegistry.registerGear(Constants.GEAR_ID_PARACHUTE, EnumExtendedInventorySlot.PARACHUTE, GCItems.parachute);
GalacticraftRegistry.registerGear(Constants.GEAR_ID_FREQUENCY_MODULE, EnumExtendedInventorySlot.FREQUENCY_MODULE, new ItemStack(GCItems.basicItem, 1, 19));
GalacticraftCore.proxy.registerFluidTexture(GCFluids.fluidOil, new ResourceLocation(Constants.ASSET_PREFIX, "textures/misc/underoil.png"));
GalacticraftCore.proxy.registerFluidTexture(GCFluids.fluidFuel, new ResourceLocation(Constants.ASSET_PREFIX, "textures/misc/underfuel.png"));
// switch (this.getSlotIndex())
// {
// case 0:
// return itemstack.getItem() instanceof ItemOxygenMask;
// case 1:
// return itemstack.getItem() == GCItems.oxygenGear;
// case 2:
// case 3:
// return itemstack.getItem() instanceof ItemOxygenTank || itemstack.getItem() instanceof ItemCanisterOxygenInfinite;
// case 4:
// return itemstack.getItem() instanceof ItemParaChute;
// case 5:
// return itemstack.getItem() == GCItems.basicItem && itemstack.getItemDamage() == 19;
// case 6:
// return this.thermalArmorSlotValid(itemstack, 0);
// case 7:
// return this.thermalArmorSlotValid(itemstack, 1);
// case 8:
// return this.thermalArmorSlotValid(itemstack, 2);
// case 9:
// return this.thermalArmorSlotValid(itemstack, 3);
// case 10:
// return this.shieldControllerSlotValid(itemstack);
// }
}
use of micdoodle8.mods.galacticraft.api.world.IOrbitDimension in project Galacticraft by micdoodle8.
the class EntityAutoRocket method onLaunch.
@Override
public void onLaunch() {
if (!(this.worldObj.provider.getDimensionId() == GalacticraftCore.planetOverworld.getDimensionID() || this.worldObj.provider instanceof IGalacticraftWorldProvider)) {
if (ConfigManagerCore.disableRocketLaunchAllNonGC) {
this.cancelLaunch();
return;
}
// No rocket flight in the Nether, the End etc
for (int i = ConfigManagerCore.disableRocketLaunchDimensions.length - 1; i >= 0; i--) {
if (ConfigManagerCore.disableRocketLaunchDimensions[i] == this.worldObj.provider.getDimensionId()) {
this.cancelLaunch();
return;
}
}
}
super.onLaunch();
if (!this.worldObj.isRemote) {
GCPlayerStats stats = null;
if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayerMP) {
stats = GCPlayerStats.get(this.riddenByEntity);
if (!(this.worldObj.provider instanceof IOrbitDimension)) {
stats.setCoordsTeleportedFromX(this.riddenByEntity.posX);
stats.setCoordsTeleportedFromZ(this.riddenByEntity.posZ);
}
}
int amountRemoved = 0;
PADSEARCH: for (int x = MathHelper.floor_double(this.posX) - 1; x <= MathHelper.floor_double(this.posX) + 1; x++) {
for (int y = MathHelper.floor_double(this.posY) - 3; y <= MathHelper.floor_double(this.posY) + 1; y++) {
for (int z = MathHelper.floor_double(this.posZ) - 1; z <= MathHelper.floor_double(this.posZ) + 1; z++) {
BlockPos pos = new BlockPos(x, y, z);
final Block block = this.worldObj.getBlockState(pos).getBlock();
if (block != null && block instanceof BlockLandingPadFull) {
if (amountRemoved < 9) {
EventLandingPadRemoval event = new EventLandingPadRemoval(this.worldObj, pos);
MinecraftForge.EVENT_BUS.post(event);
if (event.allow) {
this.worldObj.setBlockToAir(pos);
amountRemoved = 9;
}
break PADSEARCH;
}
}
}
}
}
// Set the player's launchpad item for return on landing - or null if launchpads not removed
if (stats != null) {
stats.setLaunchpadStack(amountRemoved == 9 ? new ItemStack(GCBlocks.landingPad, 9, 0) : null);
}
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
}
}
use of micdoodle8.mods.galacticraft.api.world.IOrbitDimension in project Galacticraft by micdoodle8.
the class TickHandlerServer method onWorldTick.
@SubscribeEvent
public void onWorldTick(WorldTickEvent event) {
if (event.phase == Phase.START) {
final WorldServer world = (WorldServer) event.world;
CopyOnWriteArrayList<ScheduledBlockChange> changeList = TickHandlerServer.scheduledBlockChanges.get(GCCoreUtil.getDimensionID(world));
if (changeList != null && !changeList.isEmpty()) {
int blockCount = 0;
int blockCountMax = Math.max(this.MAX_BLOCKS_PER_TICK, changeList.size() / 4);
List<ScheduledBlockChange> newList = new ArrayList<ScheduledBlockChange>(Math.max(0, changeList.size() - blockCountMax));
for (ScheduledBlockChange change : changeList) {
if (++blockCount > blockCountMax) {
newList.add(change);
} else {
if (change != null) {
BlockPos changePosition = change.getChangePosition();
Block block = world.getBlockState(changePosition).getBlock();
// Only replace blocks of type BlockAir or fire - this is to prevent accidents where other mods have moved blocks
if (changePosition != null && (block instanceof BlockAir || block == Blocks.fire)) {
world.setBlockState(changePosition, change.getChangeID().getStateFromMeta(change.getChangeMeta()), change.getChangeUpdateFlag());
}
}
}
}
changeList.clear();
TickHandlerServer.scheduledBlockChanges.remove(GCCoreUtil.getDimensionID(world));
if (newList.size() > 0) {
TickHandlerServer.scheduledBlockChanges.put(GCCoreUtil.getDimensionID(world), new CopyOnWriteArrayList<ScheduledBlockChange>(newList));
}
}
CopyOnWriteArrayList<BlockVec3> torchList = TickHandlerServer.scheduledTorchUpdates.get(GCCoreUtil.getDimensionID(world));
if (torchList != null && !torchList.isEmpty()) {
for (BlockVec3 torch : torchList) {
if (torch != null) {
BlockPos pos = new BlockPos(torch.x, torch.y, torch.z);
Block b = world.getBlockState(pos).getBlock();
if (b instanceof BlockUnlitTorch) {
world.scheduleUpdate(pos, b, 2 + world.rand.nextInt(30));
}
}
}
torchList.clear();
TickHandlerServer.scheduledTorchUpdates.remove(GCCoreUtil.getDimensionID(world));
}
if (world.provider instanceof IOrbitDimension) {
try {
int dim = GCCoreUtil.getDimensionID(WorldUtil.getProviderForNameServer(((IOrbitDimension) world.provider).getPlanetToOrbit()));
int minY = ((IOrbitDimension) world.provider).getYCoordToTeleportToPlanet();
final Entity[] entityList = world.loadedEntityList.toArray(new Entity[world.loadedEntityList.size()]);
for (final Entity e : entityList) {
if (e.posY <= minY && e.worldObj == world) {
WorldUtil.transferEntityToDimension(e, dim, world, false, null);
}
}
} catch (Exception ex) {
}
}
int dimensionID = GCCoreUtil.getDimensionID(world);
if (worldsNeedingUpdate.contains(dimensionID)) {
worldsNeedingUpdate.remove(dimensionID);
for (Object obj : event.world.loadedTileEntityList) {
TileEntity tile = (TileEntity) obj;
if (tile instanceof TileEntityFluidTank) {
((TileEntityFluidTank) tile).updateClient = true;
}
}
}
} else if (event.phase == Phase.END) {
final WorldServer world = (WorldServer) event.world;
for (GalacticraftPacketHandler handler : packetHandlers) {
handler.tick(world);
}
int dimID = GCCoreUtil.getDimensionID(world);
Set<BlockPos> edgesList = TickHandlerServer.edgeChecks.get(dimID);
final HashSet<BlockPos> checkedThisTick = new HashSet<>();
if (edgesList != null && !edgesList.isEmpty()) {
List<BlockPos> edgesListCopy = new ArrayList<>();
edgesListCopy.addAll(edgesList);
for (BlockPos edgeBlock : edgesListCopy) {
if (edgeBlock != null && !checkedThisTick.contains(edgeBlock)) {
if (TickHandlerServer.scheduledForChange(dimID, edgeBlock)) {
continue;
}
ThreadFindSeal done = new ThreadFindSeal(world, edgeBlock, 0, new ArrayList<TileEntityOxygenSealer>());
checkedThisTick.addAll(done.checkedAll());
}
}
TickHandlerServer.edgeChecks.remove(GCCoreUtil.getDimensionID(world));
}
}
}
use of micdoodle8.mods.galacticraft.api.world.IOrbitDimension in project Galacticraft by micdoodle8.
the class WorldUtil method getArrayOfPossibleDimensions.
/**
* This will *load* all the GC dimensions which the player has access to (taking account of space station permissions).
* Loading the dimensions through Forge activates any chunk loaders or forced chunks in that dimension,
* if the dimension was not previously loaded. This may place load on the server.
*
* @param tier - the rocket tier to test
* @param playerBase - the player who will be riding the rocket (needed for checking space station permissions)
* @return a Map of the names of the dimension vs. the dimension IDs
*/
public static HashMap<String, Integer> getArrayOfPossibleDimensions(int tier, EntityPlayerMP playerBase) {
List<Integer> ids = WorldUtil.getPossibleDimensionsForSpaceshipTier(tier, playerBase);
final HashMap<String, Integer> map = new HashMap<String, Integer>(ids.size(), 1F);
for (Integer id : ids) {
CelestialBody celestialBody = getReachableCelestialBodiesForDimensionID(id);
// It's a space station
if (id > 0 && celestialBody == null) {
celestialBody = GalacticraftCore.satelliteSpaceStation;
// This no longer checks whether a WorldProvider can be created, for performance reasons (that causes the dimension to load unnecessarily at map building stage)
if (playerBase != null) {
final SpaceStationWorldData data = SpaceStationWorldData.getStationData(playerBase.worldObj, id, null);
map.put(celestialBody.getName() + "$" + data.getOwner() + "$" + data.getSpaceStationName() + "$" + id + "$" + data.getHomePlanet(), id);
}
} else // It's a planet or moon
{
if (celestialBody == GalacticraftCore.planetOverworld) {
map.put(celestialBody.getName(), id);
} else {
WorldProvider provider = WorldUtil.getProviderForDimensionServer(id);
if (celestialBody != null && provider != null) {
if (provider instanceof IGalacticraftWorldProvider && !(provider instanceof IOrbitDimension) || GCCoreUtil.getDimensionID(provider) == 0) {
map.put(celestialBody.getName(), GCCoreUtil.getDimensionID(provider));
}
}
}
}
}
ArrayList<CelestialBody> cBodyList = new ArrayList<CelestialBody>();
cBodyList.addAll(GalaxyRegistry.getRegisteredPlanets().values());
cBodyList.addAll(GalaxyRegistry.getRegisteredMoons().values());
for (CelestialBody body : cBodyList) {
if (!body.getReachable()) {
map.put(body.getLocalizedName() + "*", body.getDimensionID());
}
}
WorldUtil.celestialMapCache.put(playerBase, map);
return map;
}
Aggregations