Skip to content

Commit

Permalink
Feature/dimensional comets (#12)
Browse files Browse the repository at this point in the history
Co-authored-by: SebaSphere <SebaSphereEmails@gmail.com>
  • Loading branch information
ROMVoid95 and SebaSphere authored Sep 26, 2020
1 parent 4a4036e commit dbec4c9
Show file tree
Hide file tree
Showing 10 changed files with 263 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/romvoid95/gctweaks/GalacticTweaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void onFingerprintViolation(FMLFingerprintViolationEvent event) {
logger.warn("Invalid fingerprint detected! The file " + event.getSource().getName()
+ " may have been tampered with. This version will NOT be supported by the author!");
} else {
logger.info("Ignoring fingerprint signing since we are in a Development Enviroment");
logger.info("Ignoring fingerprint signing since we are in a Development Environment");
}

}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/romvoid95/gctweaks/base/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public Configuration getConfig () {
return config;
}

/**
* Method in every feature class. You can just specify this in a class and auto adds to GalacticTweaks.cfg
*/
public void syncConfig () {
features.forEach(feature -> {
feature.syncConfig(config, feature.category());
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/net/romvoid95/gctweaks/gc/GalacticraftModule.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package net.romvoid95.gctweaks.gc;

import net.romvoid95.gctweaks.base.Module;
import net.romvoid95.gctweaks.gc.features.CompressorFixes;
import net.romvoid95.gctweaks.gc.features.FixAsmodeusMapIcons;
import net.romvoid95.gctweaks.gc.features.MobsBreatheInSpace;
import net.romvoid95.gctweaks.gc.features.NoSpaceMusic;
import net.romvoid95.gctweaks.gc.features.OverworldComets;
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;

Expand All @@ -22,9 +20,13 @@ public void addFeatures() {
registerFeature(new SpawnWithOxygenEquip());
registerFeature(new NoSpaceMusic());
registerFeature(new CompressorFixes());
registerFeature(new OverworldComets());
registerFeature(new SeperateAddonPlanets());
registerFeature(new SpaceRaceFeature());
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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
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;



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);
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class MobsBreatheInSpace extends Feature {

@Override
public String comment() {
return "Adds ability for passive mobs to beathe on other planets";
return "Adds ability for passive mobs to breathe on other planets";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
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;
Expand All @@ -23,7 +27,7 @@ public String[] category() {

@Override
public String comment() {
return "have comets also drop in the overworld - extending realism even further";
return "Have comets also drop in the overworld - extending realism even further";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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."

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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) {

}
}

0 comments on commit dbec4c9

Please sign in to comment.