From ec9e7bf225f13e37662f9f7acf3922e04f7a13df Mon Sep 17 00:00:00 2001 From: ROM <42848897+ROMVoid95@users.noreply.github.com> Date: Thu, 15 Oct 2020 07:12:34 -0500 Subject: [PATCH] 1.3.0 --- CHANGELOG.md | 14 +- build.gradle | 20 +- .../romvoid95/gctweaks/GalacticTweaks.java | 27 ++- .../romvoid95/gctweaks/ModuleController.java | 2 +- .../gctweaks/base/core/proxy/ClientProxy.java | 10 +- .../gctweaks/base/core/utils/GameUtil.java | 18 +- .../gctweaks/gc/GalacticraftModule.java | 15 +- .../gc/features/DimensionalComets.java | 187 ++++++++++-------- .../gc/features/MobsBreatheInSpace.java | 6 +- .../gctweaks/gc/features/OverworldComets.java | 94 --------- .../gc/features/UnlockSchematics.java | 63 ------ .../{galaxyfeature => galaxy}/GCPlanets.java | 15 +- .../{galaxyfeature => galaxy}/GCSystems.java | 2 +- .../SeperateAddonPlanets.java | 2 +- .../generation/DisableDungeonGeneration.java | 43 ---- .../world/gen/EmptyMapGenDungeon.java | 29 --- .../generation/world/gen/MapGenEmpty.java | 15 -- .../SpawnWithOxygenEquip.java | 20 +- .../command/CommandOxygenReset.java | 2 +- .../features/schematic/UnlockSchematics.java | 62 ++++++ .../gc/features/spawndim/SpawnDimension.java | 151 ++++++++++++++ .../SpaceRaceFeature.java | 4 +- .../command/CommandLeaveSpaceRace.java | 2 +- .../gctweaks/internal/CrashLogWarning.java | 23 +-- .../gctweaks/internal/config/ConfigCore.java | 22 +-- .../internal/versioning/DownloadUpdate.java | 11 +- .../gctweaks/internal/versioning/Request.java | 67 +++++-- .../versioning/ThreadVersionChecker.java | 26 +-- .../internal/versioning/VersionChecker.java | 11 +- 29 files changed, 483 insertions(+), 480 deletions(-) delete mode 100644 src/main/java/net/romvoid95/gctweaks/gc/features/OverworldComets.java delete mode 100644 src/main/java/net/romvoid95/gctweaks/gc/features/UnlockSchematics.java rename src/main/java/net/romvoid95/gctweaks/gc/features/{galaxyfeature => galaxy}/GCPlanets.java (89%) rename src/main/java/net/romvoid95/gctweaks/gc/features/{galaxyfeature => galaxy}/GCSystems.java (95%) rename src/main/java/net/romvoid95/gctweaks/gc/features/{galaxyfeature => galaxy}/SeperateAddonPlanets.java (96%) delete mode 100644 src/main/java/net/romvoid95/gctweaks/gc/features/generation/DisableDungeonGeneration.java delete mode 100644 src/main/java/net/romvoid95/gctweaks/gc/features/generation/world/gen/EmptyMapGenDungeon.java delete mode 100644 src/main/java/net/romvoid95/gctweaks/gc/features/generation/world/gen/MapGenEmpty.java rename src/main/java/net/romvoid95/gctweaks/gc/features/{oxygenfeature => oxygen}/SpawnWithOxygenEquip.java (97%) rename src/main/java/net/romvoid95/gctweaks/gc/features/{oxygenfeature => oxygen}/command/CommandOxygenReset.java (97%) create mode 100644 src/main/java/net/romvoid95/gctweaks/gc/features/schematic/UnlockSchematics.java create mode 100644 src/main/java/net/romvoid95/gctweaks/gc/features/spawndim/SpawnDimension.java rename src/main/java/net/romvoid95/gctweaks/gc/features/{sprfeature => spawnitems}/SpaceRaceFeature.java (88%) rename src/main/java/net/romvoid95/gctweaks/gc/features/{sprfeature => spawnitems}/command/CommandLeaveSpaceRace.java (98%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d69f42..192660b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ [Added] - - command /leaverace to leave GC SpaceRace team - (Team owners cannot use command) + - Ability to unlock Rocket Schematics via Configs - - Feature to fix planet/star Icon sizes when using AsmodeusCore celestial map \ No newline at end of file + - Dimensional-Comets Spawn Rate can be modified per dimension via Configs + + - Custom Spawn Dimension can be set via Configs + + - New Version checking system + + +[Changed] + + - Overworld-Comets merged into Dimensional-Comets \ No newline at end of file diff --git a/build.gradle b/build.gradle index c1d305b..103f942 100644 --- a/build.gradle +++ b/build.gradle @@ -67,7 +67,11 @@ jacocoTestReport { } repositories { - jcenter() + maven { + // Location of CurseAPI Files + url "https://jitpack.io" + } + mavenCentral() maven { name 'MJRLegends' url = "https://maven.mjrlegends.com/" @@ -87,14 +91,18 @@ repositories { maven { url = "https://www.cursemaven.com" } - maven { - // Location of CurseAPI Files - url "https://jitpack.io" - } + } dependencies { + compile("com.github.TheRandomLabs:CurseAPI:master-SNAPSHOT"){ + exclude group: 'com.google.guava', module: 'guava' + } + + compile "org.apache.logging.log4j:log4j-core:2.13.3" + compile "org.apache.logging.log4j:log4j-slf4j18-impl:2.13.3" + compile "org.projectlombok:lombok:1.18.12" apt "org.projectlombok:lombok:1.18.12" @@ -102,7 +110,7 @@ dependencies { // LOAD GC ADDONS compile "com.mjr.planetprogression:PlanetProgression:1.12.2-0.4.5:api" - compile "curse.maven:AsmodeusCore-Dev:3039768" + compile "curse.maven:AsmodeusCore-Dev:3063158" compile "curse.maven:GSMod-0.0.14:3015062" compile "curse.maven:ExtraPlanets-1.7.0:3031689" runtime "curse.maven:MJRLib-1.2.0:3029769" diff --git a/src/main/java/net/romvoid95/gctweaks/GalacticTweaks.java b/src/main/java/net/romvoid95/gctweaks/GalacticTweaks.java index 663a4cc..2633029 100644 --- a/src/main/java/net/romvoid95/gctweaks/GalacticTweaks.java +++ b/src/main/java/net/romvoid95/gctweaks/GalacticTweaks.java @@ -8,21 +8,16 @@ import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.event.FMLServerStartingEvent; +import net.minecraftforge.fml.common.event.*; import net.minecraftforge.fml.common.network.NetworkCheckHandler; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; + import net.romvoid95.gctweaks.base.InternalModule; import net.romvoid95.gctweaks.base.Module; import net.romvoid95.gctweaks.base.core.proxy.CommonProxy; -import net.romvoid95.gctweaks.base.core.utils.GameUtil; -import net.romvoid95.gctweaks.base.core.utils.I18nHelper; -import net.romvoid95.gctweaks.base.core.utils.LogHelper; +import net.romvoid95.gctweaks.base.core.utils.*; //import net.romvoid95.gctweaks.base.version.CommandDownloadUpdate; import net.romvoid95.gctweaks.internal.command.DownloadCommand; import net.romvoid95.gctweaks.internal.config.ConfigCore; @@ -31,10 +26,11 @@ public class GalacticTweaks { @Instance(Ref.MOD_ID) - public static GalacticTweaks instance; - public static SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel(Ref.MOD_ID); - public static LogHelper logger = new LogHelper(); - public static I18nHelper stringz = new I18nHelper(Ref.MOD_ID, logger, false); + public static GalacticTweaks instance; + public static SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel(Ref.MOD_ID); + public static LogHelper logger = new LogHelper(); + public static I18nHelper stringz = new I18nHelper(Ref.MOD_ID, logger, false); + public static File modFolder = null; @NetworkCheckHandler public boolean networkCheck(Map map, Side side) { @@ -57,9 +53,10 @@ public void onFingerprintViolation(FMLFingerprintViolationEvent event) { @EventHandler public void preInit(FMLPreInitializationEvent event) { + GalacticTweaks.modFolder = event.getModConfigurationDirectory(); + MinecraftForge.EVENT_BUS.register(this); - MinecraftForge.EVENT_BUS - .register(new ConfigCore(new File(event.getModConfigurationDirectory(), "GalacticTweaks/core.cfg"))); + MinecraftForge.EVENT_BUS.register(new ConfigCore(new File(modFolder, "GalacticTweaks/core.cfg"))); // ========================================== // Internal Modules @@ -140,7 +137,7 @@ public void onServerStarting(FMLServerStartingEvent event) { // ~ Phase ~ // ModuleController.modules.forEach(module -> module.serverStartingEvent(event)); - if(ConfigCore.enableCheckVersion) + if (ConfigCore.enableCheckVersion) event.registerServerCommand(new DownloadCommand()); } } diff --git a/src/main/java/net/romvoid95/gctweaks/ModuleController.java b/src/main/java/net/romvoid95/gctweaks/ModuleController.java index d6eb634..34af507 100644 --- a/src/main/java/net/romvoid95/gctweaks/ModuleController.java +++ b/src/main/java/net/romvoid95/gctweaks/ModuleController.java @@ -11,8 +11,8 @@ public class ModuleController { public static List modules = new ArrayList<>(); - public static List internals = new ArrayList<>(); + public static void registerModules() { modules.add(new GalacticraftModule("Galacticraft Module")); diff --git a/src/main/java/net/romvoid95/gctweaks/base/core/proxy/ClientProxy.java b/src/main/java/net/romvoid95/gctweaks/base/core/proxy/ClientProxy.java index 13c5c81..cd62cd6 100644 --- a/src/main/java/net/romvoid95/gctweaks/base/core/proxy/ClientProxy.java +++ b/src/main/java/net/romvoid95/gctweaks/base/core/proxy/ClientProxy.java @@ -1,10 +1,10 @@ package net.romvoid95.gctweaks.base.core.proxy; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.event.*; + import net.romvoid95.gctweaks.ModuleController; import net.romvoid95.gctweaks.base.Module; +import net.romvoid95.gctweaks.internal.config.ConfigCore; //import net.romvoid95.gctweaks.base.version.VersionChecker; import net.romvoid95.gctweaks.internal.versioning.VersionChecker; @@ -19,7 +19,9 @@ public void preInit(FMLPreInitializationEvent event) { @Override public void init(FMLInitializationEvent event) { ModuleController.modules.forEach(Module::proxyInit); - VersionChecker.init(); + if (ConfigCore.enableCheckVersion) { + VersionChecker.init(); + } super.init(event); } diff --git a/src/main/java/net/romvoid95/gctweaks/base/core/utils/GameUtil.java b/src/main/java/net/romvoid95/gctweaks/base/core/utils/GameUtil.java index 155a5ff..56847c8 100644 --- a/src/main/java/net/romvoid95/gctweaks/base/core/utils/GameUtil.java +++ b/src/main/java/net/romvoid95/gctweaks/base/core/utils/GameUtil.java @@ -1,11 +1,12 @@ package net.romvoid95.gctweaks.base.core.utils; +import java.io.IOException; + import net.minecraft.client.Minecraft; import net.minecraft.launchwrapper.Launch; + import net.minecraftforge.fml.client.FMLClientHandler; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.LoaderState; +import net.minecraftforge.fml.common.*; public final class GameUtil { private GameUtil() { @@ -36,7 +37,12 @@ public static boolean isServer() { * @return True if and only if we are running in a deobfuscated environment */ public static boolean isDeobfuscated() { - return (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); + try { + return Launch.classLoader.getClassBytes("net.minecraft.world.World") != null; + } catch (IOException e) { + e.printStackTrace(); + } + return false; } public static Minecraft getMinecraft() { @@ -56,7 +62,7 @@ public static boolean shouldCalculateTooltip() { LoaderState state = Loader.instance().getLoaderState(); // These states have no reason to go through tooltips that I can tell, but they // do. - return state != LoaderState.INITIALIZATION && state != LoaderState.SERVER_ABOUT_TO_START - && state != LoaderState.SERVER_STOPPING; + return (state != LoaderState.INITIALIZATION) && (state != LoaderState.SERVER_ABOUT_TO_START) + && (state != LoaderState.SERVER_STOPPING); } } diff --git a/src/main/java/net/romvoid95/gctweaks/gc/GalacticraftModule.java b/src/main/java/net/romvoid95/gctweaks/gc/GalacticraftModule.java index 2e1d428..ef6cf9d 100644 --- a/src/main/java/net/romvoid95/gctweaks/gc/GalacticraftModule.java +++ b/src/main/java/net/romvoid95/gctweaks/gc/GalacticraftModule.java @@ -2,11 +2,11 @@ import net.romvoid95.gctweaks.base.Module; import net.romvoid95.gctweaks.gc.features.*; -import net.romvoid95.gctweaks.gc.features.DimensionalComets; -import net.romvoid95.gctweaks.gc.features.galaxyfeature.SeperateAddonPlanets; -import net.romvoid95.gctweaks.gc.features.generation.DisableDungeonGeneration; -import net.romvoid95.gctweaks.gc.features.oxygenfeature.SpawnWithOxygenEquip; -import net.romvoid95.gctweaks.gc.features.sprfeature.SpaceRaceFeature; +import net.romvoid95.gctweaks.gc.features.galaxy.SeperateAddonPlanets; +import net.romvoid95.gctweaks.gc.features.oxygen.SpawnWithOxygenEquip; +import net.romvoid95.gctweaks.gc.features.schematic.UnlockSchematics; +import net.romvoid95.gctweaks.gc.features.spawndim.SpawnDimension; +import net.romvoid95.gctweaks.gc.features.spawnitems.SpaceRaceFeature; public class GalacticraftModule extends Module { @@ -25,8 +25,7 @@ public void addFeatures() { registerFeature(new FixAsmodeusMapIcons()); registerFeature(new DimensionalComets()); registerFeature(new UnlockSchematics()); - - //registerFeature(new OverworldComets()); No longer needed. Replaced with DimensionalComets.java - //registerFeature(new DisableDungeonGeneration()); I couldn't figure this our right now. Later + registerFeature(new SpawnDimension()); + } } diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/DimensionalComets.java b/src/main/java/net/romvoid95/gctweaks/gc/features/DimensionalComets.java index d42972c..8a0ba12 100644 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/DimensionalComets.java +++ b/src/main/java/net/romvoid95/gctweaks/gc/features/DimensionalComets.java @@ -1,95 +1,124 @@ package net.romvoid95.gctweaks.gc.features; -import micdoodle8.mods.galacticraft.core.entities.EntityMeteor; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; + import net.minecraftforge.common.config.Configuration; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.romvoid95.gctweaks.base.Feature; +import micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider; +import micdoodle8.mods.galacticraft.core.entities.EntityMeteor; +import net.romvoid95.gctweaks.base.Feature; public class DimensionalComets extends Feature { - private static boolean cometModification; - private static int[] dimensionID; - private static double cometSpawnRate; - - - @Override - public String[] category() { - return new String[] {"dimensional-comets"}; - } - - @Override - public String comment() { - return "You can specify where asteroids will drop via dimension IDs\nCheck GC dimension ID's here https://wiki.micdoodle8.com/wiki/Dimensions"; - } - - @Override - public void syncConfig(Configuration config, String[] category) { - cometModification = config - .get(category[0],"comet-modification", false, "Set to true to specify what new dimensions asteroids drop").getBoolean(); - cometSpawnRate = config - .get(category[0], "cometSpawnRate", 1.0D, "Specify the global asteroid spawn rate between values 0.0 - 1.0").getDouble(); - dimensionID = config - .get(category[0], "dimension-id", new int[] {-1, 0, 1}, "dimension IDs for asteroids").getIntList(); - } - - @Override - public boolean usesEvents() { return true; } - - @SubscribeEvent - public void entityLivingEvent(LivingEvent.LivingUpdateEvent event) { - if (cometModification) { - final EntityLivingBase entityLiving = event.getEntityLiving(); - if (entityLiving instanceof EntityPlayerMP) { - this.onPlayerUpdate((EntityPlayerMP) entityLiving); - } - } - } - private void onPlayerUpdate(EntityPlayerMP player) { - for (int id : dimensionID) { - this.meteors(player, id); - } - } - - protected void meteors(EntityPlayerMP player, int dimensionid) { - World world = player.world; - if (world.provider.getDimensionType().getId() == dimensionid ) { - final int f = (int) ((int) 5D * 750D * (1.0 / cometSpawnRate)); - int e = world.rand.nextInt(f); - if (e < 3) { - final EntityPlayer closestPlayer = world.getClosestPlayerToEntity(player, 100); - if (closestPlayer == null || closestPlayer.getEntityId() <= player.getEntityId()) { - - int r = world.getMinecraftServer().getPlayerList().getViewDistance(); - int x, z; - double motX, motZ; - x = world.rand.nextInt(20) + 160; - z = world.rand.nextInt(20) - 10; - motX = world.rand.nextDouble() * 2 - 2.5D; - motZ = world.rand.nextDouble() * 5 - 2.5D; - int px = MathHelper.floor(player.posX); - if ((x + px >> 4) - (px >> 4) >= r) { - x = ((px >> 4) + r << 4) - 1 - px; - } - - final EntityMeteor meteor = new EntityMeteor(world, player.posX + x, 355D, player.posZ + z, motX, 0, - motZ, 1); - - if (!world.isRemote) { - world.spawnEntity(meteor); -// String pos = meteor.getPosition().toString().replace("[BlockPos{", "[").replace("}]", "]"); -// String[] msg = { "[DEBUG] ", "Meteor has spawned at ", pos}; -// Utilz.sendColorizedMulti(closestPlayer, msg); - } - } - } - } - } + private static boolean cometModification; + private static String[] dimensionID_spawnrate; + + @Override + public String[] category() { + return new String[] { "dimensional-comets" }; + } + + @Override + public String comment() { + return "You can specify where asteroids will drop via dimension IDs\nCheck GC dimension ID's here https://wiki.micdoodle8.com/wiki/Dimensions"; + } + + @Override + public void syncConfig(Configuration config, String[] category) { + cometModification = config.get(category[0], "comet-modification", false, + "Set to true to specify what new dimensions asteroids drop").getBoolean(); + dimensionID_spawnrate = config.get(category[0], "dimension-id", new String[] { "0:1.0", "1:2.0" }, + "Data consisting of which Dimensions meteors will spawn in and the spawn-rate modification value.\nSpec: (Ex: -1:3.5)").getStringList(); + } + + @Override + public boolean usesEvents() { + return true; + } + + @SubscribeEvent + public void entityLivingEvent(LivingEvent.LivingUpdateEvent event) { + if (cometModification) { + final EntityLivingBase entityLiving = event.getEntityLiving(); + if (entityLiving instanceof EntityPlayerMP) { + this.onPlayerUpdate((EntityPlayerMP) entityLiving); + } + } + } + + private void onPlayerUpdate(EntityPlayerMP player) { + for (String data : dimensionID_spawnrate) { + int dimId = Integer.parseInt(data.split(":")[0]); + double spawnRate = Double.parseDouble(data.split(":")[1]); + this.meteors(player, dimId, spawnRate); + } + } + + protected void meteors(EntityPlayerMP player, int dimensionid, double spawnRate) { + World world = player.world; + int f; + if (world.provider.getDimensionType().getId() == dimensionid && !world.isRemote) { + if (world.provider instanceof IGalacticraftWorldProvider) { + f = (int) (((IGalacticraftWorldProvider) world.provider).getMeteorFrequency() * 750D * (1.0 / spawnRate)); + } else { + f = (int) (750D * (1.0 / spawnRate)); + } + if (world.rand.nextInt(f) == 0) { + final EntityPlayer closestPlayer = world.getClosestPlayerToEntity(player, 100); + + if (closestPlayer == null || closestPlayer.getEntityId() <= player.getEntityId()) { + int r = world.getMinecraftServer().getPlayerList().getViewDistance(); + int x, z; + double motX, motZ; + x = world.rand.nextInt(20) + 160; + z = world.rand.nextInt(20) - 10; + motX = world.rand.nextDouble() * 2 - 2.5D; + motZ = world.rand.nextDouble() * 5 - 2.5D; + int px = MathHelper.floor(player.posX); + if ((x + px >> 4) - (px >> 4) >= r) { + x = ((px >> 4) + r << 4) - 1 - px; + } + + final EntityMeteor meteor = new EntityMeteor(world, player.posX + x, 355D, player.posZ + + z, motX, 0, motZ, 1); + + if (!world.isRemote) { + world.spawnEntity(meteor); + } + } + } + + if (world.rand.nextInt(f * 3) == 0) { + final EntityPlayer closestPlayer = world.getClosestPlayerToEntity(player, 100); + + if (closestPlayer == null || closestPlayer.getEntityId() <= player.getEntityId()) { + int r = world.getMinecraftServer().getPlayerList().getViewDistance(); + int x, z; + double motX, motZ; + x = world.rand.nextInt(20) + 160; + z = world.rand.nextInt(20) - 10; + motX = world.rand.nextDouble() * 2 - 2.5D; + motZ = world.rand.nextDouble() * 5 - 2.5D; + int px = MathHelper.floor(player.posX); + if ((x + px >> 4) - (px >> 4) >= r) { + x = ((px >> 4) + r << 4) - 1 - px; + } + + final EntityMeteor meteor = new EntityMeteor(world, player.posX + x, 355D, player.posZ + + z, motX, 0, motZ, 6); + + if (!world.isRemote) { + world.spawnEntity(meteor); + } + } + } + } + } } diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/MobsBreatheInSpace.java b/src/main/java/net/romvoid95/gctweaks/gc/features/MobsBreatheInSpace.java index 099db7a..3bfebbb 100644 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/MobsBreatheInSpace.java +++ b/src/main/java/net/romvoid95/gctweaks/gc/features/MobsBreatheInSpace.java @@ -2,8 +2,8 @@ import micdoodle8.mods.galacticraft.api.event.oxygen.GCCoreOxygenSuffocationEvent; import micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; + +import net.minecraft.entity.*; import net.minecraft.entity.passive.EntityAnimal; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -39,7 +39,7 @@ public void GCCoreOxygenSuffocationEvent(GCCoreOxygenSuffocationEvent.Pre event) if (mobsBreatheInSpace) { EntityLivingBase e = event.getEntityLiving(); if (e.world.provider instanceof IGalacticraftWorldProvider) { - if (e instanceof EntityLiving || e instanceof EntityAnimal) { + if (e instanceof EntityLiving || e instanceof EntityAnimal || e instanceof EntityCreature) { event.setCanceled(true); } } diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/OverworldComets.java b/src/main/java/net/romvoid95/gctweaks/gc/features/OverworldComets.java deleted file mode 100644 index 8122b8b..0000000 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/OverworldComets.java +++ /dev/null @@ -1,94 +0,0 @@ -package net.romvoid95.gctweaks.gc.features; - -import micdoodle8.mods.galacticraft.core.entities.EntityMeteor; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.romvoid95.gctweaks.base.Feature; - -/** - * Replaced with DimensionalComets.java - */ -@Deprecated -public class OverworldComets extends Feature { - - private static boolean overworldComets; - private static double overworldCometSpawnRate; - - @Override - public String[] category() { - return new String[] {"overworld-comets"}; - } - - @Override - public String comment() { - return "Have comets also drop in the overworld - extending realism even further"; - } - - @Override - public void syncConfig(Configuration config, String[] category) { - overworldComets = config - .get(category[0], "overworldComets", false, "Set to true to enable comets in the Overworld").getBoolean(); - overworldCometSpawnRate = config.get(category[0], "overworldCometSpawnRate", 1.0D, - "Set to a value between 0.0 and 0.9 to decrease meteor spawn").getDouble(); - } - - @Override - public boolean usesEvents() { - return true; - } - - @SubscribeEvent - public void entityLivingEvent(LivingEvent.LivingUpdateEvent event) { - if (overworldComets) { - final EntityLivingBase entityLiving = event.getEntityLiving(); - if (entityLiving instanceof EntityPlayerMP) { - this.onPlayerUpdate((EntityPlayerMP) entityLiving); - } - } - } - - private void onPlayerUpdate(EntityPlayerMP player) { - this.meteors(player); - } - - protected void meteors(EntityPlayerMP player) { - World world = player.world; - if (world.provider.getDimensionType().getId() == 0) { - final int f = (int) ((int) 5D * 750D * (1.0 / overworldCometSpawnRate)); - int e = world.rand.nextInt(f); - if (e < 3) { - final EntityPlayer closestPlayer = world.getClosestPlayerToEntity(player, 100); - if (closestPlayer == null || closestPlayer.getEntityId() <= player.getEntityId()) { - - int r = world.getMinecraftServer().getPlayerList().getViewDistance(); - int x, z; - double motX, motZ; - x = world.rand.nextInt(20) + 160; - z = world.rand.nextInt(20) - 10; - motX = world.rand.nextDouble() * 2 - 2.5D; - motZ = world.rand.nextDouble() * 5 - 2.5D; - int px = MathHelper.floor(player.posX); - if ((x + px >> 4) - (px >> 4) >= r) { - x = ((px >> 4) + r << 4) - 1 - px; - } - - final EntityMeteor meteor = new EntityMeteor(world, player.posX + x, 355D, player.posZ + z, motX, 0, - motZ, 1); - - if (!world.isRemote) { - world.spawnEntity(meteor); -// String pos = meteor.getPosition().toString().replace("[BlockPos{", "[").replace("}]", "]"); -// String[] msg = { "[DEBUG] ", "Meteor has spawned at ", pos}; -// Utilz.sendColorizedMulti(closestPlayer, msg); - } - } - } - } - } -} diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/UnlockSchematics.java b/src/main/java/net/romvoid95/gctweaks/gc/features/UnlockSchematics.java deleted file mode 100644 index 0db5d63..0000000 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/UnlockSchematics.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.romvoid95.gctweaks.gc.features; - -import micdoodle8.mods.galacticraft.api.recipe.SchematicRegistry; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.PlayerEvent; -import net.romvoid95.gctweaks.GalacticTweaks; -import net.romvoid95.gctweaks.base.Feature; - -public class UnlockSchematics extends Feature { - - private static boolean unlockSchematicsOnJoin; - private static int[] schematicID; - - - - @Override - public String[] category() { - return new String[] {"unlock-schematics"}; - } - - @Override - public String comment() { return "Unlock all schematics specified when the player joins the world."; } - - @Override - public void syncConfig(Configuration config, String[] category) { - unlockSchematicsOnJoin = config.get(category[0], "unlock-schematics", false, - "Set to true unlock schematics specified in config on player join.\nYou can see what schematic IDs are in GC by default in configs.").getBoolean(); - schematicID = config.get(category[0], "schematic-ids", new int[] {0, 1, 2, 3, 4}, - "Check galacticraft/addon config for schematic IDs").getIntList(); //maybe have a link to list of IDs on GCTweaks wiki. I'll work on that -SebaSphere - } - - @Override - public boolean usesEvents() { - return true; - } - - @SubscribeEvent - public void PlayerWorldJoin(PlayerEvent.PlayerLoggedInEvent e) { - final EntityPlayerMP player = (EntityPlayerMP) e.player; - if (unlockSchematicsOnJoin) { - perPlayerSchems(player); - } - - } - - - private void perPlayerSchems(EntityPlayerMP player) { - for (int schem : schematicID) { - try { - SchematicRegistry.unlockNewPage(player, SchematicRegistry.getSchematicItem(schem)); - - } catch (Exception e) { - GalacticTweaks.logger.error("Please remove " + schem + " from the schematics config. This is a invalid value..." ); - } - - } - } - - //maybe we can have a command to clear everyones data or specific player. Prob gonna be people reeing "I think that mod brok, removed value and nothing happened." - -} diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/galaxyfeature/GCPlanets.java b/src/main/java/net/romvoid95/gctweaks/gc/features/galaxy/GCPlanets.java similarity index 89% rename from src/main/java/net/romvoid95/gctweaks/gc/features/galaxyfeature/GCPlanets.java rename to src/main/java/net/romvoid95/gctweaks/gc/features/galaxy/GCPlanets.java index 17760ab..d2e9c45 100644 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/galaxyfeature/GCPlanets.java +++ b/src/main/java/net/romvoid95/gctweaks/gc/features/galaxy/GCPlanets.java @@ -1,17 +1,16 @@ -package net.romvoid95.gctweaks.gc.features.galaxyfeature; +package net.romvoid95.gctweaks.gc.features.galaxy; import com.mjr.extraplanets.planets.ExtraPlanets_Planets; -import galaxyspace.systems.SolarSystem.SolarSystemBodies; -import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody; +import net.minecraft.util.ResourceLocation; + +import micdoodle8.mods.galacticraft.api.galaxies.*; import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody.ScalableDistance; -import micdoodle8.mods.galacticraft.api.galaxies.GalaxyRegistry; -import micdoodle8.mods.galacticraft.api.galaxies.Planet; -import micdoodle8.mods.galacticraft.api.galaxies.SolarSystem; import micdoodle8.mods.galacticraft.api.world.EnumAtmosphericGas; import micdoodle8.mods.galacticraft.core.GalacticraftCore; import micdoodle8.mods.galacticraft.planets.asteroids.AsteroidsModule; -import net.minecraft.util.ResourceLocation; + +import galaxyspace.systems.SolarSystem.SolarSystemBodies; public class GCPlanets { public static Planet FAKE_OVERWORLD; @@ -74,7 +73,7 @@ public static void buildFakeEarth (Planet planet, String planetName, SolarSystem planet.setRelativeSize(1.0F); planet.setBodyIcon(new ResourceLocation("galacticraftcore:textures/gui/celestialbodies/earth.png")); planet.atmosphereComponent(EnumAtmosphericGas.NITROGEN).atmosphereComponent(EnumAtmosphericGas.OXYGEN) - .atmosphereComponent(EnumAtmosphericGas.ARGON).atmosphereComponent(EnumAtmosphericGas.WATER); + .atmosphereComponent(EnumAtmosphericGas.ARGON).atmosphereComponent(EnumAtmosphericGas.WATER); planet.setUnreachable(); GalaxyRegistry.registerPlanet(planet); } diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/galaxyfeature/GCSystems.java b/src/main/java/net/romvoid95/gctweaks/gc/features/galaxy/GCSystems.java similarity index 95% rename from src/main/java/net/romvoid95/gctweaks/gc/features/galaxyfeature/GCSystems.java rename to src/main/java/net/romvoid95/gctweaks/gc/features/galaxy/GCSystems.java index 8300a91..866ef9e 100644 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/galaxyfeature/GCSystems.java +++ b/src/main/java/net/romvoid95/gctweaks/gc/features/galaxy/GCSystems.java @@ -1,4 +1,4 @@ -package net.romvoid95.gctweaks.gc.features.galaxyfeature; +package net.romvoid95.gctweaks.gc.features.galaxy; import asmodeuscore.core.astronomy.BodiesRegistry; diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/galaxyfeature/SeperateAddonPlanets.java b/src/main/java/net/romvoid95/gctweaks/gc/features/galaxy/SeperateAddonPlanets.java similarity index 96% rename from src/main/java/net/romvoid95/gctweaks/gc/features/galaxyfeature/SeperateAddonPlanets.java rename to src/main/java/net/romvoid95/gctweaks/gc/features/galaxy/SeperateAddonPlanets.java index 75c40ee..94b2ee6 100644 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/galaxyfeature/SeperateAddonPlanets.java +++ b/src/main/java/net/romvoid95/gctweaks/gc/features/galaxy/SeperateAddonPlanets.java @@ -1,4 +1,4 @@ -package net.romvoid95.gctweaks.gc.features.galaxyfeature; +package net.romvoid95.gctweaks.gc.features.galaxy; import asmodeuscore.core.astronomy.BodiesRegistry; import net.minecraftforge.common.config.Configuration; diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/generation/DisableDungeonGeneration.java b/src/main/java/net/romvoid95/gctweaks/gc/features/generation/DisableDungeonGeneration.java deleted file mode 100644 index d69e4ca..0000000 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/generation/DisableDungeonGeneration.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.romvoid95.gctweaks.gc.features.generation; - -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.event.terraingen.InitMapGenEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import net.romvoid95.gctweaks.gc.features.generation.world.gen.EmptyMapGenDungeon; -import net.romvoid95.gctweaks.base.Feature; - -public class DisableDungeonGeneration extends Feature { - private static boolean disableDungeonGeneration; - - @Override - public String[] category () { - return new String[] { "worldgen" }; - } - - @Override - public String comment () { - return "Ability to disable dungeon generation"; - } - - @Override - public void syncConfig (Configuration config, String[] category) { - disableDungeonGeneration = config - .get(category[0], "disableDungeonGeneration", false, "Set to true if you want to disable GC dungeon generation.") - .getBoolean(); - } - - @Override - public boolean usesEvents() { - return true; - } - - @SubscribeEvent - public void onMapGen (InitMapGenEvent event) { - if (disableDungeonGeneration) { - new EmptyMapGenDungeon(); - System.out.println("testAAA"); - } - } - -} diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/generation/world/gen/EmptyMapGenDungeon.java b/src/main/java/net/romvoid95/gctweaks/gc/features/generation/world/gen/EmptyMapGenDungeon.java deleted file mode 100644 index 6971656..0000000 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/generation/world/gen/EmptyMapGenDungeon.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.romvoid95.gctweaks.gc.features.generation.world.gen; - -import micdoodle8.mods.galacticraft.core.world.gen.dungeon.MapGenDungeon; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.World; - -import java.util.Random; - -public class EmptyMapGenDungeon extends MapGenDungeon { - - public EmptyMapGenDungeon() { - super(null); - System.out.println("AAAH"); - } - - - - @Override - public synchronized boolean generateStructure(World worldIn, Random randomIn, ChunkPos chunkCoord) { - return false; - } - - @Override - public boolean canSpawnStructureAtCoords (int chunkX, int chunkZ) { - - return false; - } - -} diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/generation/world/gen/MapGenEmpty.java b/src/main/java/net/romvoid95/gctweaks/gc/features/generation/world/gen/MapGenEmpty.java deleted file mode 100644 index 261ca94..0000000 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/generation/world/gen/MapGenEmpty.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.romvoid95.gctweaks.gc.features.generation.world.gen; - -import net.minecraft.world.World; -import net.minecraft.world.chunk.ChunkPrimer; -import net.minecraft.world.gen.MapGenBase; - -public class MapGenEmpty extends MapGenBase { - - - - @Override - public void generate (World worldIn, int x, int z, ChunkPrimer primer) { - - } -} diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/oxygenfeature/SpawnWithOxygenEquip.java b/src/main/java/net/romvoid95/gctweaks/gc/features/oxygen/SpawnWithOxygenEquip.java similarity index 97% rename from src/main/java/net/romvoid95/gctweaks/gc/features/oxygenfeature/SpawnWithOxygenEquip.java rename to src/main/java/net/romvoid95/gctweaks/gc/features/oxygen/SpawnWithOxygenEquip.java index e2c8109..4ab38e7 100644 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/oxygenfeature/SpawnWithOxygenEquip.java +++ b/src/main/java/net/romvoid95/gctweaks/gc/features/oxygen/SpawnWithOxygenEquip.java @@ -1,22 +1,25 @@ -package net.romvoid95.gctweaks.gc.features.oxygenfeature; +package net.romvoid95.gctweaks.gc.features.oxygen; -import micdoodle8.mods.galacticraft.core.GCItems; -import micdoodle8.mods.galacticraft.core.entities.player.GCCapabilities; -import micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats; -import micdoodle8.mods.galacticraft.core.inventory.InventoryExtended; -import micdoodle8.mods.galacticraft.planets.asteroids.items.AsteroidsItems; -import micdoodle8.mods.galacticraft.planets.venus.VenusItems; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; + import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; + +import micdoodle8.mods.galacticraft.core.GCItems; +import micdoodle8.mods.galacticraft.core.entities.player.GCCapabilities; +import micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats; +import micdoodle8.mods.galacticraft.core.inventory.InventoryExtended; +import micdoodle8.mods.galacticraft.planets.asteroids.items.AsteroidsItems; +import micdoodle8.mods.galacticraft.planets.venus.VenusItems; + import net.romvoid95.gctweaks.Ref; import net.romvoid95.gctweaks.base.Feature; -import net.romvoid95.gctweaks.gc.features.oxygenfeature.command.CommandOxygenReset; +import net.romvoid95.gctweaks.gc.features.oxygen.command.CommandOxygenReset; public class SpawnWithOxygenEquip extends Feature { @@ -75,7 +78,6 @@ public boolean usesEvents () { @SubscribeEvent public void playerLogin (PlayerLoggedInEvent event) { final EntityPlayer player = event.player; - final NBTTagCompound entityData = player.getEntityData(); final NBTTagCompound persistedData = entityData.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); entityData.setTag(EntityPlayer.PERSISTED_NBT_TAG, persistedData); diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/oxygenfeature/command/CommandOxygenReset.java b/src/main/java/net/romvoid95/gctweaks/gc/features/oxygen/command/CommandOxygenReset.java similarity index 97% rename from src/main/java/net/romvoid95/gctweaks/gc/features/oxygenfeature/command/CommandOxygenReset.java rename to src/main/java/net/romvoid95/gctweaks/gc/features/oxygen/command/CommandOxygenReset.java index 239433f..5e3cd0f 100644 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/oxygenfeature/command/CommandOxygenReset.java +++ b/src/main/java/net/romvoid95/gctweaks/gc/features/oxygen/command/CommandOxygenReset.java @@ -1,4 +1,4 @@ -package net.romvoid95.gctweaks.gc.features.oxygenfeature.command; +package net.romvoid95.gctweaks.gc.features.oxygen.command; import java.util.List; diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/schematic/UnlockSchematics.java b/src/main/java/net/romvoid95/gctweaks/gc/features/schematic/UnlockSchematics.java new file mode 100644 index 0000000..749c4a1 --- /dev/null +++ b/src/main/java/net/romvoid95/gctweaks/gc/features/schematic/UnlockSchematics.java @@ -0,0 +1,62 @@ +package net.romvoid95.gctweaks.gc.features.schematic; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.PlayerEvent; + +import micdoodle8.mods.galacticraft.api.recipe.SchematicRegistry; + +import net.romvoid95.gctweaks.GalacticTweaks; +import net.romvoid95.gctweaks.base.Feature; + +public class UnlockSchematics extends Feature { + + private static boolean unlockSchematicsOnJoin; + private static int[] schematicID; + + @Override + public String[] category() { + return new String[] { "unlock-schematics" }; + } + + @Override + public String comment() { + return "Unlock all schematics specified when the player joins the world."; + } + + @Override + public void syncConfig(Configuration config, String[] category) { + unlockSchematicsOnJoin = config.get(category[0], "unlock-schematics", false, + "Set to true unlock schematics specified in config on player join.\nYou can see what schematic IDs are in GC by default in configs.").getBoolean(); + schematicID = config.get(category[0], "schematic-ids", new int[] { 0, 1, 2, 3, 4 }, + "Check galacticraft/addon config for schematic IDs").getIntList(); + } + + @Override + public boolean usesEvents() { + return true; + } + + @SubscribeEvent + public void PlayerWorldJoin(PlayerEvent.PlayerLoggedInEvent e) { + final EntityPlayerMP player = (EntityPlayerMP) e.player; + if (unlockSchematicsOnJoin) { + perPlayerSchems(player); + } + } + + private void perPlayerSchems(EntityPlayerMP player) { + for (int schem : schematicID) { + ItemStack schemItem = SchematicRegistry.getSchematicItem(schem); + try { + SchematicRegistry.unlockNewPage(player, schemItem); + } catch (Exception e) { + GalacticTweaks.logger.error( + "Please remove " + schem + " from the schematics config. This is a invalid value..."); + } + } + } +} diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/spawndim/SpawnDimension.java b/src/main/java/net/romvoid95/gctweaks/gc/features/spawndim/SpawnDimension.java new file mode 100644 index 0000000..f991fc0 --- /dev/null +++ b/src/main/java/net/romvoid95/gctweaks/gc/features/spawndim/SpawnDimension.java @@ -0,0 +1,151 @@ +package net.romvoid95.gctweaks.gc.features.spawndim; + +import java.io.*; +import java.util.*; +import java.util.Map.Entry; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.WorldServer; + +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; +import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent; + +import micdoodle8.mods.galacticraft.api.galaxies.*; +import micdoodle8.mods.galacticraft.api.vector.Vector3; +import micdoodle8.mods.galacticraft.core.util.WorldUtil; + +import net.romvoid95.gctweaks.GalacticTweaks; +import net.romvoid95.gctweaks.Ref; +import net.romvoid95.gctweaks.base.Feature; +import net.romvoid95.gctweaks.base.core.compat.CompatMods; + +public class SpawnDimension extends Feature { + + private static boolean enableSpawnDimension, firstJoinOnly, everyDeath; + private static int spawnDimId; + + @Override + public String[] category() { + return new String[] { "spawn-dimension" }; + } + + @Override + public String comment() { + return "Set a certain Planet or Moon as a Spawn Point\n\nYou should have SPAWN-ITEMS Configured and set prior to enabling this setting\n" + + "At the moment any moon or planet set to spawn in uses that bodies teleport system (spawns in the lander)"; + } + + @Override + public void syncConfig(Configuration config, String[] category) { + enableSpawnDimension = config.get(category[0], "spawnfeature", false, + "Enable & Disable the Spawn Dimension Feature\n[default: false]").getBoolean(); + firstJoinOnly = config.get(category[0], "firstJoinOnly", true, + "If \"true\" players are only sent to the spawn dimension" + + " on their first time joining.\nIf \"false\" players are sent every join\n [default: false]").getBoolean(); + everyDeath = config.get(category[0], "everyDeath", false, "If \"true\" players are sent to the spawn dimension" + + "every death respawn.\n [default: false]").getBoolean(); + spawnDimId = config.get(category[0], "spawnDimId", 0, + "Set the Dimension ID of the planet/moon you want players join on\n" + + "There is a file under this one called ValidSpawnDimsneions.txt\n" + + "that will contain every valid dimension ID you can set").getInt(); + + } + + @Override + public boolean usesEvents() { + return true; + } + + @Override + public void postInit() { + creatFile(); + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onPlayerJoin(PlayerLoggedInEvent event) { + if (event.player instanceof EntityPlayer) { + if (enableSpawnDimension) { + final EntityPlayer player = event.player; + final NBTTagCompound entityData = player.getEntityData(); + final NBTTagCompound persistedData = entityData.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + entityData.setTag(EntityPlayer.PERSISTED_NBT_TAG, persistedData); + final String key = Ref.MOD_ID + ":" + "FirstSpawn"; + if (!persistedData.getBoolean(key)) { + teleport((EntityPlayerMP) event.player, spawnDimId); + persistedData.setBoolean(key, true); + } + } else if (firstJoinOnly) { + teleport((EntityPlayerMP) event.player, spawnDimId); + } + } + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onPlayerRespawn(PlayerRespawnEvent event) { + if (event.player instanceof EntityPlayer) { + if (everyDeath) { + teleport((EntityPlayerMP) event.player, spawnDimId); + } + } + } + + private void teleport(EntityPlayerMP player, int dimId) { + MinecraftServer mcServer = player.getServer(); + final WorldServer world = mcServer.getWorld(dimId); + int yy = world.getChunkFromBlockCoords(world.getSpawnPoint()).getHeight(world.getSpawnPoint()); + Vector3 v = new Vector3(world.getSpawnPoint().getX(), yy, world.getSpawnPoint().getZ()); + WorldUtil.teleportEntitySimple(world, dimId, player, v); + } + + private static boolean creatFile() { + File dims = new File(GalacticTweaks.modFolder, "GalacticTweaks/ValidSpawnDimsneions.txt"); + if (dims.exists()) { + dims.delete(); + } + Map planets = new HashMap<>(); + for (Entry body : GalaxyRegistry.getRegisteredPlanets().entrySet()) { + if (body.getValue().getReachable()) { + planets.put(body.getValue().getLocalizedName(), body.getValue().getDimensionID()); + } + } + Map moons = new HashMap<>(); + for (Entry body : GalaxyRegistry.getRegisteredMoons().entrySet()) { + if (body.getValue().getReachable()) { + moons.put(body.getValue().getLocalizedName(), body.getValue().getDimensionID()); + } + } + try { + dims.createNewFile(); + PrintWriter print_line = new PrintWriter(new FileWriter(dims)); + if(CompatMods.EXTRAPLANETS.isLoaded()) { + print_line.println("### NOTICE ###"); + print_line.println("Planets & Moons that end with \"ep\" are added by ExtraPlanets."); + print_line.println("Please keep this in mind if choosing a planet that is added by both ExtraPlanets & GalaxySpace"); + } + print_line.println(""); + print_line.println("If adding or removing Galacticraft Addons, This file is regenerated every time minecraft is ran"); + print_line.println(""); + print_line.println("| ### PLANETS ###"); + print_line.println("|------------------"); + planets.entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).forEach( + s -> print_line.println(String.format("| %-15s %15s", s.getKey(), s.getValue()))); + print_line.println(""); + print_line.println(""); + print_line.println("| ### MOONS ###"); + print_line.println("|------------------"); + moons.entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).forEach( + s -> print_line.println(String.format("| %-15s %15s", s.getKey(), s.getValue()))); + print_line.flush(); + print_line.close(); + return true; + } catch (IOException localIOException) { + return false; + } + } +} diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/sprfeature/SpaceRaceFeature.java b/src/main/java/net/romvoid95/gctweaks/gc/features/spawnitems/SpaceRaceFeature.java similarity index 88% rename from src/main/java/net/romvoid95/gctweaks/gc/features/sprfeature/SpaceRaceFeature.java rename to src/main/java/net/romvoid95/gctweaks/gc/features/spawnitems/SpaceRaceFeature.java index c5b40e9..41a5802 100644 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/sprfeature/SpaceRaceFeature.java +++ b/src/main/java/net/romvoid95/gctweaks/gc/features/spawnitems/SpaceRaceFeature.java @@ -1,9 +1,9 @@ -package net.romvoid95.gctweaks.gc.features.sprfeature; +package net.romvoid95.gctweaks.gc.features.spawnitems; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.romvoid95.gctweaks.base.Feature; -import net.romvoid95.gctweaks.gc.features.sprfeature.command.CommandLeaveSpaceRace; +import net.romvoid95.gctweaks.gc.features.spawnitems.command.CommandLeaveSpaceRace; public class SpaceRaceFeature extends Feature { diff --git a/src/main/java/net/romvoid95/gctweaks/gc/features/sprfeature/command/CommandLeaveSpaceRace.java b/src/main/java/net/romvoid95/gctweaks/gc/features/spawnitems/command/CommandLeaveSpaceRace.java similarity index 98% rename from src/main/java/net/romvoid95/gctweaks/gc/features/sprfeature/command/CommandLeaveSpaceRace.java rename to src/main/java/net/romvoid95/gctweaks/gc/features/spawnitems/command/CommandLeaveSpaceRace.java index e028048..d67090b 100644 --- a/src/main/java/net/romvoid95/gctweaks/gc/features/sprfeature/command/CommandLeaveSpaceRace.java +++ b/src/main/java/net/romvoid95/gctweaks/gc/features/spawnitems/command/CommandLeaveSpaceRace.java @@ -1,4 +1,4 @@ -package net.romvoid95.gctweaks.gc.features.sprfeature.command; +package net.romvoid95.gctweaks.gc.features.spawnitems.command; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/net/romvoid95/gctweaks/internal/CrashLogWarning.java b/src/main/java/net/romvoid95/gctweaks/internal/CrashLogWarning.java index 66c84cc..c22b2c3 100644 --- a/src/main/java/net/romvoid95/gctweaks/internal/CrashLogWarning.java +++ b/src/main/java/net/romvoid95/gctweaks/internal/CrashLogWarning.java @@ -1,28 +1,21 @@ package net.romvoid95.gctweaks.internal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.ICrashCallable; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.*; import net.minecraftforge.fml.common.versioning.ArtifactVersion; + import net.romvoid95.gctweaks.base.InternalFeature; -import net.romvoid95.gctweaks.gc.features.galaxyfeature.SeperateAddonPlanets; +import net.romvoid95.gctweaks.gc.features.galaxy.SeperateAddonPlanets; public class CrashLogWarning extends InternalFeature { private static List loaded = Loader.instance().getActiveModList(); - private static Map sets = new HashMap(); - private static Map cores = new HashMap(); - private static Set> setRemove = new HashSet>(); - private static Set> coreRemove = new HashSet>(); + private static Map sets = new HashMap<>(); + private static Map cores = new HashMap<>(); + private static Set> setRemove = new HashSet<>(); + private static Set> coreRemove = new HashSet<>(); private static String setter = "\n\t|\t"; private static String setter2 = "\t|\t"; diff --git a/src/main/java/net/romvoid95/gctweaks/internal/config/ConfigCore.java b/src/main/java/net/romvoid95/gctweaks/internal/config/ConfigCore.java index 794e39b..98372ca 100644 --- a/src/main/java/net/romvoid95/gctweaks/internal/config/ConfigCore.java +++ b/src/main/java/net/romvoid95/gctweaks/internal/config/ConfigCore.java @@ -20,19 +20,13 @@ import static net.romvoid95.gctweaks.Ref.*; import java.io.File; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import net.minecraftforge.common.config.ConfigCategory; -import net.minecraftforge.common.config.ConfigElement; -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.common.config.Property; +import java.util.*; + +import net.minecraftforge.common.config.*; import net.minecraftforge.fml.client.config.IConfigElement; import net.minecraftforge.fml.client.event.ConfigChangedEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + import net.romvoid95.gctweaks.GalacticTweaks; import net.romvoid95.gctweaks.Ref; @@ -46,12 +40,6 @@ public ConfigCore(File file) { } public static boolean enableCheckVersion; - public static boolean enableOverworldOres; - public static boolean enableDebug; - public static boolean enableRealism; - - public static boolean warnBetaBuild; - public static int configVersion; private static Map> propOrder = new TreeMap<>(); private static String currentCat; @@ -123,7 +111,7 @@ private static void finishProp(Property prop) { } public static List getConfigElements() { - List list = new ArrayList(); + List list = new ArrayList<>(); ConfigCategory configGeneral = config.getCategory(CATEGORY_CORE); configGeneral.setComment("Core Settings"); list.add(new ConfigElement(configGeneral)); diff --git a/src/main/java/net/romvoid95/gctweaks/internal/versioning/DownloadUpdate.java b/src/main/java/net/romvoid95/gctweaks/internal/versioning/DownloadUpdate.java index 4f0b87f..cdc3705 100644 --- a/src/main/java/net/romvoid95/gctweaks/internal/versioning/DownloadUpdate.java +++ b/src/main/java/net/romvoid95/gctweaks/internal/versioning/DownloadUpdate.java @@ -10,14 +10,9 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; -import com.google.gson.JsonObject; - import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.Style; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.*; public class DownloadUpdate { @@ -27,11 +22,9 @@ public DownloadUpdate() { public void run () { - JsonObject obj = null; URL downloadUrl = null; try { - obj = Request.get(); - downloadUrl = new URL(obj.get("downloadUrl").getAsString()); + downloadUrl = new URL(Request.getLatestVersionDownload()); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/net/romvoid95/gctweaks/internal/versioning/Request.java b/src/main/java/net/romvoid95/gctweaks/internal/versioning/Request.java index 630e748..117cde7 100644 --- a/src/main/java/net/romvoid95/gctweaks/internal/versioning/Request.java +++ b/src/main/java/net/romvoid95/gctweaks/internal/versioning/Request.java @@ -5,31 +5,60 @@ import java.net.HttpURLConnection; import java.net.URL; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import com.google.gson.*; import net.romvoid95.gctweaks.GalacticTweaks; public class Request { - public static String domain = "https://addons-ecs.forgesvc.net/api/v2/addon/359766/files"; + public static String domain1 = "https://addons-ecs.forgesvc.net/api/v2/addon/359766"; - public static JsonObject get () throws Exception { - URL getRequestURL = new URL(domain); - HttpURLConnection con = (HttpURLConnection) getRequestURL.openConnection(); - con.setRequestMethod("GET"); - BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); - String inputLine; - String response = ""; - while ((inputLine = in.readLine()) != null) { - GalacticTweaks.logger.info(inputLine); - response += inputLine; - in.close(); - JsonParser parser = new JsonParser(); - JsonArray array = parser.parse(response).getAsJsonArray(); - JsonObject json = array.get(0).getAsJsonObject(); - return json; + public static String getLatestVersion() { + try { + URL getRequestURL = new URL(domain1); + HttpURLConnection con = (HttpURLConnection) getRequestURL.openConnection(); + con.setRequestMethod("GET"); + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + String response = ""; + while ((inputLine = in.readLine()) != null) { + + response += inputLine; + in.close(); + JsonParser parser = new JsonParser(); + JsonObject array = parser.parse(response).getAsJsonObject(); + JsonArray json = array.getAsJsonArray("latestFiles"); + JsonObject ob = json.get(0).getAsJsonObject(); + String version = ob.get("displayName").getAsString().split("-")[1].replace(".jar", ""); + return version; + } + } catch (Exception e) { + GalacticTweaks.logger.error("There was an issue communicating with the CurseAPI"); + } + return null; + } + + public static String getLatestVersionDownload() { + try { + URL getRequestURL = new URL(domain1); + HttpURLConnection con = (HttpURLConnection) getRequestURL.openConnection(); + con.setRequestMethod("GET"); + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + String response = ""; + while ((inputLine = in.readLine()) != null) { + //GalacticTweaks.logger.info(inputLine); + response += inputLine; + in.close(); + JsonParser parser = new JsonParser(); + JsonObject array = parser.parse(response).getAsJsonObject(); + JsonArray json = array.getAsJsonArray("latestFiles"); + JsonObject ob = json.get(0).getAsJsonObject(); + String version = ob.get("downloadUrl").getAsString(); + return version; + } + } catch (Exception e) { + GalacticTweaks.logger.error("There was an issue communicating with the CurseAPI"); } return null; } diff --git a/src/main/java/net/romvoid95/gctweaks/internal/versioning/ThreadVersionChecker.java b/src/main/java/net/romvoid95/gctweaks/internal/versioning/ThreadVersionChecker.java index bf1954f..01501fe 100644 --- a/src/main/java/net/romvoid95/gctweaks/internal/versioning/ThreadVersionChecker.java +++ b/src/main/java/net/romvoid95/gctweaks/internal/versioning/ThreadVersionChecker.java @@ -1,35 +1,19 @@ package net.romvoid95.gctweaks.internal.versioning; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; - -import net.minecraftforge.common.MinecraftForge; -import net.romvoid95.gctweaks.Ref; - public class ThreadVersionChecker extends Thread { - public ThreadVersionChecker() { + public ThreadVersionChecker () { setName("Version Checker Thread"); setDaemon(true); start(); } @Override - public void run () { + public void run() { try { - URL url = new URL("https://raw.githubusercontent.com/ReadOnly-Mods/Misc/master/" - + MinecraftForge.MC_VERSION + ".txt"); - BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream())); - String line; - while ((line = r.readLine()) != null) { - if (line.contains(Ref.MOD_ID)) { - VersionChecker.onlineVersion = line; - } - } - r.close(); - } - catch (Exception e) { + VersionChecker.onlineVersion = Request.getLatestVersion(); + + } catch (Exception e) { e.printStackTrace(); } VersionChecker.doneChecking = true; diff --git a/src/main/java/net/romvoid95/gctweaks/internal/versioning/VersionChecker.java b/src/main/java/net/romvoid95/gctweaks/internal/versioning/VersionChecker.java index 512b622..0022942 100644 --- a/src/main/java/net/romvoid95/gctweaks/internal/versioning/VersionChecker.java +++ b/src/main/java/net/romvoid95/gctweaks/internal/versioning/VersionChecker.java @@ -2,16 +2,15 @@ import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.Style; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.*; import net.minecraft.util.text.translation.I18n; + import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; import net.minecraftforge.fml.relauncher.Side; + import net.romvoid95.api.versioning.Version; import net.romvoid95.gctweaks.Ref; @@ -22,7 +21,6 @@ private VersionChecker() {} public static volatile boolean doneChecking = false; public static volatile String onlineVersion = ""; - public static volatile String fileId = ""; private static boolean triedToWarnPlayer = false; public static volatile boolean startedDownload = false; public static volatile boolean downloadedFile = false; @@ -36,9 +34,8 @@ public static void onTick (ClientTickEvent event) { if (event.phase == Phase.END && Minecraft.getMinecraft().player != null && !triedToWarnPlayer && doneChecking) { if (!onlineVersion.isEmpty()) { EntityPlayer player = Minecraft.getMinecraft().player; - Version online = new Version(onlineVersion.split(":")[0]); + Version online = new Version(Request.getLatestVersion()); Version client = new Version(Ref.MOD_VERSION); - fileId = onlineVersion.split(":")[1]; if (online.isGreaterThan(client)) { player.sendMessage(new TextComponentTranslation("galactictweaks.versions.notify") .setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE)));