Skip to content

Commit

Permalink
Updated to v0.1.4.6
Browse files Browse the repository at this point in the history
 (Merged commits due to large file)

Update logs:

Updated to v0.1.4.4

- HUD inhanced; now hour settings, alpha and brightness settings are
available.
- Removed; Now 1 hour is always 60 minute.
- Added Progress Messages on World loading.
- Fixed periods of moon&planets.

Updated to v0.1.4.5

- Updated for Stellar API v0.1.3.3

Updated to v0.1.4.6

- Added tooltips for overlays.
- Added HUD element for Client Settings Configurations.
- Fixed issue #29 (stars drawn on the moon.)
- Added equator, ecliptic and horizon.

Simple Fix before release
  • Loading branch information
Abastro committed May 15, 2016
1 parent 43a0b22 commit 1ff6acf
Show file tree
Hide file tree
Showing 152 changed files with 6,429 additions and 9,951 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "0.1.4.3"
version = "0.1.4.6"
group= "stellarium" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "Stellar Sky"

Expand Down
Binary file removed libs/Stellar API-0.1.3.1b-deobf.jar
Binary file not shown.
Binary file added libs/Stellar API-0.1.3.4-deobf.jar
Binary file not shown.
Binary file not shown.
19 changes: 4 additions & 15 deletions src/main/java/stellarium/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import stellarapi.api.gui.overlay.OverlayRegistry;
import stellarapi.api.lib.config.ConfigManager;
import stellarium.api.StellarSkyAPI;
import stellarium.client.ClientSettings;
import stellarium.client.DefaultHourProvider;
import stellarium.client.StellarClientFMLHook;
import stellarium.client.StellarClientForgeHook;
import stellarium.client.overlay.StellarSkyOverlays;
import stellarium.client.overlay.clientcfg.OverlayClientSettingsType;
import stellarium.client.overlay.clock.OverlayClockType;
import stellarium.stellars.Optics;
import stellarium.stellars.layer.CelestialManager;

public class ClientProxy extends CommonProxy implements IProxy {

private static final String clientConfigCategory = "clientconfig";
public static final String clientConfigCategory = "clientconfig";
private static final String clientConfigOpticsCategory = "clientconfig.optics";

private ClientSettings clientSettings = new ClientSettings();
Expand All @@ -46,15 +43,12 @@ public void preInit(FMLPreInitializationEvent event) {
this.guiConfig = new ConfigManager(
StellarSkyReferences.getConfiguration(event.getModConfigurationDirectory(),
StellarSkyReferences.guiSettings));

MinecraftForge.EVENT_BUS.register(new StellarClientForgeHook());


FMLCommonHandler.instance().bus().register(new StellarClientFMLHook());

StellarSkyAPI.registerHourProvider(new DefaultHourProvider(this.clientSettings));

OverlayRegistry.registerOverlaySet("stellarsky", new StellarSkyOverlays());
OverlayRegistry.registerOverlay("clock", new OverlayClockType(), this.guiConfig);
OverlayRegistry.registerOverlay("clientconfig", new OverlayClientSettingsType(), this.guiConfig);
}

@Override
Expand Down Expand Up @@ -82,11 +76,6 @@ public World getDefWorld() {
return Minecraft.getMinecraft().theWorld;
}

@Override
public World getDefWorld(boolean isRemote) {
return isRemote? this.getDefWorld() : super.getDefWorld();
}

public Entity getDefViewerEntity() {
return Minecraft.getMinecraft().renderViewEntity;
}
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/stellarium/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import net.minecraft.entity.Entity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import stellarapi.api.lib.config.ConfigManager;
import stellarium.client.ClientSettings;
Expand Down Expand Up @@ -39,12 +38,7 @@ public void setupCelestialConfigManager(ConfigManager manager) {

@Override
public World getDefWorld() {
return MinecraftServer.getServer().getEntityWorld();
}

@Override
public World getDefWorld(boolean isRemote) {
return MinecraftServer.getServer().getEntityWorld();
return null;
}

@Override
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/stellarium/IProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ public interface IProxy {

public void postInit(FMLPostInitializationEvent event);

public World getDefWorld();
public World getDefWorld(boolean isRemote);

public World getDefWorld();

public Entity getDefViewerEntity();

public ClientSettings getClientSettings();
Expand Down
131 changes: 128 additions & 3 deletions src/main/java/stellarium/StellarAPIEventHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@

import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.IProgressUpdate;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraftforge.client.IRenderHandler;
import stellarapi.api.ICelestialCoordinate;
import stellarapi.api.ISkyEffect;
import stellarapi.api.StellarAPIReference;
import stellarapi.api.celestials.IEffectorType;
import stellarapi.api.event.ConstructCelestialsEvent;
import stellarapi.api.event.ResetCoordinateEvent;
import stellarapi.api.event.ResetSkyEffectEvent;
import stellarapi.api.event.world.ClientWorldEvent;
import stellarapi.api.event.world.ServerWorldEvent;
import stellarapi.api.helper.WorldProviderReplaceHelper;
import stellarium.api.StellarSkyAPI;
import stellarium.render.SkyRenderCelestial;
import stellarium.stellars.DefaultCelestialHelper;
import stellarium.stellars.StellarManager;
import stellarium.stellars.layer.CelestialManager;
import stellarium.world.StellarDimensionManager;

public class StellarAPIEventHook {
Expand All @@ -17,6 +30,7 @@ public class StellarAPIEventHook {
public void onConstruct(ConstructCelestialsEvent event) {
StellarDimensionManager dimManager = StellarDimensionManager.get(event.getWorld());
if(dimManager != null) {
StellarSky.logger.info("Startng Construction of Celestial Images...");
StellarAPIReference.resetCoordinate(event.getWorld());
StellarAPIReference.resetSkyEffect(event.getWorld());

Expand All @@ -26,22 +40,133 @@ public void onConstruct(ConstructCelestialsEvent event) {
event.getCollections().addAll(dimManager.constructCelestials(coordinate, sky));
event.getEffectors(IEffectorType.Light).addAll(dimManager.getSuns());
event.getEffectors(IEffectorType.Tide).addAll(dimManager.getMoons());
} else event.setCanceled(true);
StellarSky.logger.info("Finished Construction of Celestial Images.");
} else if(!StellarManager.hasSetup(event.getWorld())) {
StellarSky.logger.info("Delayed Celestial Setup since StellarManager had not been initialized.");
event.setCanceled(true);
}
}

@SubscribeEvent(priority = EventPriority.HIGH)
public void onReset(ResetCoordinateEvent event) {
StellarDimensionManager dimManager = StellarDimensionManager.get(event.getWorld());
if(dimManager != null)
event.setCoordinate(dimManager.getCoordinate());
else event.setCanceled(true);
else if(!StellarManager.hasSetup(event.getWorld())) {
StellarSky.logger.info("Delayed Dimension setup since StellarManager had not been initialized.");
event.setCanceled(true);
}
}

@SubscribeEvent(priority = EventPriority.HIGH)
public void onReset(ResetSkyEffectEvent event) {
StellarDimensionManager dimManager = StellarDimensionManager.get(event.getWorld());
if(dimManager != null)
event.setSkyEffect(dimManager.getSkySet());
else event.setCanceled(true);
else if(!StellarManager.hasSetup(event.getWorld())) {
StellarSky.logger.info("Delayed Sky Setup since StellarManager had not been initialized.");
event.setCanceled(true);
}
}


@SubscribeEvent
public void onClientWorldLoad(ClientWorldEvent.Load event) {
IProgressUpdate update = event.getProgressUpdate("StellarSky");
update.displayProgressMessage(I18n.format("progress.text.injection.main"));
update.resetProgresAndWorkingMessage(I18n.format("progress.text.injection.manager"));
StellarManager manager = StellarManager.loadOrCreateClientManager(event.getWorld());

if(!manager.getSettings().serverEnabled)
manager.setup(StellarSky.proxy.getClientCelestialManager().copy());

String dimName = event.getWorld().provider.getDimensionName();
if(!StellarSky.proxy.commonSettings.serverEnabled)
handleDimOnServerDisabled(event.getWorld(), manager,update);

if(mark) {
handleNotHaveModOnServer(event.getWorld(), manager, update);
mark = false;
} else if(StellarSky.proxy.commonSettings.serverEnabled) {
update.resetProgresAndWorkingMessage(I18n.format("progress.text.injection.query", dimName));
update.setLoadingProgress(0);
StellarSky.instance.getNetworkManager().queryInformation(event.getWorld());
}
}

@SubscribeEvent(receiveCanceled = true)
public void onClientWorldLoaded(ClientWorldEvent.Loaded event) {
if(StellarManager.getClientManager().hasSetup())
event.getProgressUpdate("StellarSky").resetProgresAndWorkingMessage("");
else {
event.getProgressUpdate("StellarSky").setLoadingProgress(99);
event.setCanceled(true);
}
}

@SubscribeEvent
public void onServerWorldInitiate(ServerWorldEvent.Initial event) {
StellarManager manager = StellarManager.loadOrCreateServerManager(event.getServer());
manager.setup(new CelestialManager(false));
}

@SubscribeEvent
public void onServerWorldLoad(ServerWorldEvent.Load event) {
StellarManager manager = StellarManager.getServerManager(event.getServer());
String dimName = event.getWorld().provider.getDimensionName();
if(StellarSky.proxy.dimensionSettings.hasSubConfig(dimName)) {
StellarDimensionManager dimManager = StellarDimensionManager.loadOrCreate(event.getWorld(), manager, dimName);
setupDimension(event.getWorld(), manager, dimManager);
}
}


public static void setupDimension(World world, StellarManager manager, StellarDimensionManager dimManager) {
dimManager.setup();

StellarAPIReference.constructCelestials(world);
StellarAPIReference.resetSkyEffect(world);

ICelestialCoordinate coordinate = StellarAPIReference.getCoordinate(world);
ISkyEffect skyEffect = StellarAPIReference.getSkyEffect(world);

if(manager.getSettings().serverEnabled && dimManager.getSettings().doesPatchProvider()) {
DefaultCelestialHelper helper = new DefaultCelestialHelper((float)dimManager.getSettings().getSunlightMultiplier(), 1.0f,
dimManager.getSuns().get(0), dimManager.getMoons().get(0), coordinate, skyEffect);
WorldProvider newProvider = StellarSkyAPI.getReplacedWorldProvider(world, world.provider, helper);
WorldProviderReplaceHelper.patchWorldProviderWith(world, newProvider);
}

if(world.isRemote)
{
IRenderHandler renderer = StellarSkyAPI.getRendererFor(dimManager.getSettings().getSkyRendererType(), new SkyRenderCelestial(manager));
world.provider.setSkyRenderer(renderer);
}
}


private static boolean mark = false;

public static void markNotHave() {
mark = true;
}

private static void handleNotHaveModOnServer(World world, StellarManager manager, IProgressUpdate update) {
manager.handleServerWithoutMod();

if(manager.getCelestialManager() == null) {
manager.setup(StellarSky.proxy.getClientCelestialManager().copy());
handleDimOnServerDisabled(world, manager, update);
}
}

private static void handleDimOnServerDisabled(World world, StellarManager manager, IProgressUpdate update) {
String dimName = world.provider.getDimensionName();
if(StellarSky.proxy.dimensionSettings.hasSubConfig(dimName)) {
update.resetProgresAndWorkingMessage(I18n.format("progress.text.injection.dimmanager", dimName));
StellarDimensionManager dimManager = StellarDimensionManager.loadOrCreate(world, manager, dimName);
setupDimension(world, manager, dimManager);
update.resetProgresAndWorkingMessage("");
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/stellarium/StellarFMLEventHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public void handleNotHave(FMLNetworkEvent.CustomPacketRegistrationEvent event) {
}

private void handleNotHave() {
StellarForgeEventHook.markNotHave();
StellarAPIEventHook.markNotHave();
}
}
115 changes: 1 addition & 114 deletions src/main/java/stellarium/StellarForgeEventHook.java
Original file line number Diff line number Diff line change
@@ -1,119 +1,6 @@
package stellarium;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

import com.google.common.base.Throwables;

import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraftforge.client.IRenderHandler;
import net.minecraftforge.event.world.WorldEvent;
import stellarapi.api.ICelestialCoordinate;
import stellarapi.api.ISkyEffect;
import stellarapi.api.StellarAPIReference;
import stellarapi.api.helper.WorldProviderReplaceHelper;
import stellarium.api.StellarSkyAPI;
import stellarium.render.SkyRenderCelestial;
import stellarium.stellars.DefaultCelestialHelper;
import stellarium.stellars.StellarManager;
import stellarium.stellars.layer.CelestialManager;
import stellarium.world.StellarDimensionManager;

public class StellarForgeEventHook {

private static Field providerField = ReflectionHelper.findField(World.class,
ObfuscationReflectionHelper.remapFieldNames(World.class.getName(), "provider", "field_73011_w"));

static {
try {
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(providerField, providerField.getModifiers() & ~ Modifier.FINAL);
} catch(Exception exc) {
Throwables.propagate(exc);
}
}

@SubscribeEvent
public void onWorldLoad(WorldEvent.Load e)
{
StellarManager manager;
if(!StellarManager.hasManager(e.world, e.world.isRemote)) {
manager = StellarManager.loadOrCreateManager(e.world);
} else manager = StellarManager.getManager(e.world.isRemote);

if(manager.getCelestialManager() == null && (!e.world.isRemote || !manager.getSettings().serverEnabled))
setupManager(e.world, manager);

String dimName = e.world.provider.getDimensionName();
if(!e.world.isRemote || !StellarSky.proxy.commonSettings.serverEnabled)
if(StellarSky.proxy.dimensionSettings.hasSubConfig(dimName)) {
StellarDimensionManager dimManager = StellarDimensionManager.loadOrCreate(e.world, manager, dimName);
setupDimension(e.world, manager, dimManager);
}

if(e.world.isRemote) {
if(mark) {
handleNotHaveModOnServer(e.world);
mark = false;
} else if(StellarSky.proxy.commonSettings.serverEnabled)
StellarSky.instance.getNetworkManager().queryInformation(e.world);
}
}

public static void setupManager(World world, StellarManager manager) {
if(world.isRemote)
manager.setup(StellarSky.proxy.getClientCelestialManager().copy());
else manager.setup(new CelestialManager(false));
}

public static void setupDimension(World world, StellarManager manager, StellarDimensionManager dimManager) {
dimManager.setup();

StellarAPIReference.resetSkyEffect(world);
StellarAPIReference.constructCelestials(world);

ICelestialCoordinate coordinate = StellarAPIReference.getCoordinate(world);
ISkyEffect skyEffect = StellarAPIReference.getSkyEffect(world);

if(manager.getSettings().serverEnabled && dimManager.getSettings().doesPatchProvider()) {
DefaultCelestialHelper helper = new DefaultCelestialHelper((float)dimManager.getSettings().getSunlightMultiplier(), 1.0f,
dimManager.getSuns().get(0), dimManager.getMoons().get(0), coordinate, skyEffect);
WorldProvider newProvider = StellarSkyAPI.getReplacedWorldProvider(world, world.provider, helper);
new WorldProviderReplaceHelper().patchWorldProviderWith(world, newProvider);
}

if(world.isRemote)
{
IRenderHandler renderer = StellarSkyAPI.getRendererFor(dimManager.getSettings().getSkyRendererType(), new SkyRenderCelestial(manager));
world.provider.setSkyRenderer(renderer);
}
}

private static boolean mark = false;

private static void handleNotHaveModOnServer(World world) {
StellarManager manager = StellarManager.loadOrCreateManager(world);
manager.handleServerWithoutMod();

if(manager.getCelestialManager() == null)
{
StellarForgeEventHook.setupManager(world, manager);

String dimName = world.provider.getDimensionName();
if(StellarSky.proxy.dimensionSettings.hasSubConfig(dimName)) {
StellarDimensionManager dimManager = StellarDimensionManager.loadOrCreate(world, manager, dimName);
StellarForgeEventHook.setupDimension(world, manager, dimManager);
}
}
}

public static void markNotHave() {
mark = true;
}


}
Loading

0 comments on commit 1ff6acf

Please sign in to comment.