Stones now generate in the world
This commit is contained in:
parent
dd679a3e79
commit
7b6099e8e2
15 changed files with 387 additions and 135 deletions
46
build.gradle
46
build.gradle
|
@ -13,10 +13,6 @@ buildscript {
|
|||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.matthewprenger.cursegradle' version '1.2.0'
|
||||
}
|
||||
|
||||
apply plugin: "net.minecraftforge.gradle.forge"
|
||||
apply plugin: 'idea'
|
||||
|
||||
|
@ -30,25 +26,9 @@ def getVersionName = { ->
|
|||
return stdout.toString().trim()
|
||||
}
|
||||
|
||||
def getAPIKey = { ->
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
try {
|
||||
exec {
|
||||
commandLine 'cat', '../apiKey'
|
||||
standardOutput = stdout
|
||||
}
|
||||
return stdout.toString().trim()
|
||||
} catch(Exception e) {
|
||||
return '0'
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
version = getVersionName()
|
||||
group = modGroup
|
||||
archivesBaseName = modBaseName
|
||||
String apiToken = getAPIKey()
|
||||
|
||||
minecraft {
|
||||
version = project.forgeVersion
|
||||
|
@ -93,10 +73,10 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile 'com.gitlab.lcoremodders:LucraftCore:22057ced'
|
||||
deobfCompile 'com.gitlab.lcoremodders:HeroesExpansion:860f629ed4'
|
||||
deobfCompile 'com.gitlab.lcoremodders:SpeedsterHeroes:1e4b1fb951'
|
||||
deobfCompile "star-tech-man-the-legendary-mod:star:tech:1.1.1"
|
||||
compile 'com.gitlab.lcoremodders:LucraftCore:22057ced'
|
||||
compile 'com.gitlab.lcoremodders:HeroesExpansion:860f629ed4'
|
||||
compile 'com.gitlab.lcoremodders:SpeedsterHeroes:1e4b1fb951'
|
||||
compile "star-tech-man-the-legendary-mod:star:tech:1.1.1"
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
|
||||
|
@ -135,22 +115,4 @@ processResources {
|
|||
}
|
||||
}
|
||||
|
||||
curseforge {
|
||||
apiKey = apiToken
|
||||
project {
|
||||
id = projectID
|
||||
changelog = file('changelog.txt')
|
||||
releaseType = "beta"
|
||||
addGameVersion '1.12.2'
|
||||
|
||||
mainArtifact(jar) {
|
||||
displayName = "Infinity Craft $getVersionName"
|
||||
relations {
|
||||
requiredDependency 'lucraft-core'
|
||||
optionalDependency 'heroesexpansion'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
modGroup=anvil
|
||||
modBaseName=infinity
|
||||
forgeVersion=1.12.2-14.23.5.2816
|
||||
forgeVersion=1.12.2-14.23.5.2847
|
||||
mcpVersion=stable_39
|
||||
core_version=d406868225
|
||||
projectID=285509
|
|
@ -5,10 +5,12 @@ import anvil.infinity.capabilities.ICapabilityPlayerData;
|
|||
import anvil.infinity.capabilities.Storage;
|
||||
import anvil.infinity.compat.CompatHandler;
|
||||
import anvil.infinity.config.ConfigHandler;
|
||||
import anvil.infinity.config.ModConfig;
|
||||
import anvil.infinity.networking.LookAbilityPackageHandler;
|
||||
import anvil.infinity.networking.LookAbilityReturnPackageHandler;
|
||||
import anvil.infinity.networking.PackageKillAbility;
|
||||
import anvil.infinity.networking.PackageReq;
|
||||
import anvil.infinity.worldgen.InfinityWorldGenerator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
|
@ -39,16 +41,9 @@ public class Infinity {
|
|||
public static final String DEPENDENCIES = "required-after:lucraftcore@[1.12.2-2.4.4,)";
|
||||
public static final SimpleNetworkWrapper NETWORK_WRAPPER = NetworkRegistry.INSTANCE.newSimpleChannel(MOD_ID);
|
||||
|
||||
/**
|
||||
* This is the instance of your mod as created by Forge. It will never be null.
|
||||
*/
|
||||
@Mod.Instance(MOD_ID)
|
||||
public static Infinity INSTANCE;
|
||||
|
||||
/**
|
||||
* This is the first initialization event. Register tile entities here.
|
||||
* The registry events below will have fired prior to entry to this method.
|
||||
*/
|
||||
@Mod.EventHandler
|
||||
public void preinit(FMLPreInitializationEvent event) {
|
||||
ConfigHandler.refreshConfig(event.getSuggestedConfigurationFile());
|
||||
|
@ -58,72 +53,21 @@ public class Infinity {
|
|||
NETWORK_WRAPPER.registerMessage(LookAbilityPackageHandler.class, PackageReq.class, netID++, Side.CLIENT);
|
||||
CapabilityManager.INSTANCE.register(ICapabilityPlayerData.class, new Storage(), new Factory());
|
||||
|
||||
if (ModConfig.Worldgen.enable) {
|
||||
GameRegistry.registerWorldGenerator(new InfinityWorldGenerator(), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the second initialization event. Register custom recipes
|
||||
*/
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the final initialization event. Register actions from other mods here
|
||||
*/
|
||||
@Mod.EventHandler
|
||||
public void postinit(FMLPostInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Forge will automatically look up and bind blocks to the fields in this class
|
||||
* based on their registry name.
|
||||
*/
|
||||
@GameRegistry.ObjectHolder(MOD_ID)
|
||||
public static class Blocks {
|
||||
/*
|
||||
public static final MySpecialBlock mySpecialBlock = null; // placeholder for special block below
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Forge will automatically look up and bind items to the fields in this class
|
||||
* based on their registry name.
|
||||
*/
|
||||
@GameRegistry.ObjectHolder(MOD_ID)
|
||||
public static class Items {
|
||||
/*
|
||||
public static final ItemBlock mySpecialBlock = null; // itemblock for the block above
|
||||
public static final MySpecialItem mySpecialItem = null; // placeholder for special item below
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a special class that listens to registry events, to allow creation of mod blocks and items at the proper time.
|
||||
*/
|
||||
@Mod.EventBusSubscriber
|
||||
public static class ObjectRegistryHandler {
|
||||
/**
|
||||
* Listen for the register event for creating custom items
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public static void addItems(RegistryEvent.Register<Item> event) {
|
||||
/*
|
||||
event.getRegistry().register(new ItemBlock(Blocks.myBlock).setRegistryName(MOD_ID, "myBlock"));
|
||||
event.getRegistry().register(new MySpecialItem().setRegistryName(MOD_ID, "mySpecialItem"));
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen for the register event for creating custom blocks
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public static void addBlocks(RegistryEvent.Register<Block> event) {
|
||||
/*
|
||||
event.getRegistry().register(new MySpecialBlock().setRegistryName(MOD_ID, "mySpecialBlock"));
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,15 +7,6 @@ import java.io.File;
|
|||
public class ConfigHandler {
|
||||
|
||||
public static Configuration config;
|
||||
public static boolean soulHealthBoost;
|
||||
public static boolean useSHRealityAbilities;
|
||||
public static boolean sizeChanging;
|
||||
public static float size;
|
||||
public static int soulWorldID;
|
||||
public static boolean snapCreative;
|
||||
public static boolean heAbilities;
|
||||
public static int powerCooldown;
|
||||
public static boolean stAbilities;
|
||||
|
||||
public static int powerStoneColor;
|
||||
public static int powerStoneShine;
|
||||
|
@ -40,18 +31,7 @@ public class ConfigHandler {
|
|||
}
|
||||
|
||||
private static void syncConfig() {
|
||||
String category = Configuration.CATEGORY_GENERAL;
|
||||
String colorcat = Configuration.CATEGORY_CLIENT;
|
||||
soulHealthBoost = config.getBoolean("Soul Stone health boost", category, true, "Should the Soul Stone have a health boost");
|
||||
useSHRealityAbilities = config.getBoolean("SH Reality Stone abilities", category, false, "Should the Reality Stone have the abilities of the Speedster Heroes Reality Stone if it is installed");
|
||||
sizeChanging = config.getBoolean("Size changing", category, true, "Should the Reality Stone be able to change the size");
|
||||
size = config.getFloat("Size", category, 0.1f, 0.1f,10, "Which size should the Reality Stone change it's user to");
|
||||
soulWorldID = config.getInt("Soul World ID", category, 10, -255, 255, "The ID of the Soul World Dimension");
|
||||
snapCreative = config.getBoolean("Can Snap change Gamemode", category, false, "Can the Snap change the Gamemode to Creative");
|
||||
heAbilities = config.getBoolean("HeroesExpansion Abilities", category, true, "Should some stones use abilities from HeroesExpansion");
|
||||
stAbilities = config.getBoolean("StarTech Abilities", category, true, "Should the Power Stone use the abilities from the StarTech Power Stone if installed");
|
||||
powerCooldown = config.getInt("Power Burst Cooldown", category, 100, 0, 1000, "How big long should the StarTech Power Stone burst cooldown be");
|
||||
|
||||
powerStoneColor = config.getInt("Power Stone color", colorcat, 0xC32AD1, 0x000000, 0xFFFFFF, "Color of the Power Stone");
|
||||
powerStoneShine = config.getInt("Power Stone shine", colorcat, 0xF12AFF, 0x000000, 0xFFFFFF, "Shine color of the Power Stone");
|
||||
realityStoneColor = config.getInt("Reality Stone color", colorcat, 0xFF0130, 0x000000, 0xFFFFFF, "Color of the Reality Stone");
|
||||
|
|
77
src/main/java/anvil/infinity/config/ModConfig.java
Normal file
77
src/main/java/anvil/infinity/config/ModConfig.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package anvil.infinity.config;
|
||||
|
||||
import anvil.infinity.Infinity;
|
||||
import net.minecraftforge.common.config.Config;
|
||||
|
||||
@Config(modid = Infinity.MOD_ID)
|
||||
public class ModConfig {
|
||||
|
||||
@Config(modid = Infinity.MOD_ID, category = "general")
|
||||
public static class General {
|
||||
|
||||
@Config.Name("Soul Stone health boost")
|
||||
@Config.Comment("Should the Soul Stone have a health boost")
|
||||
public static boolean soulHealthBoost = true;
|
||||
|
||||
@Config.Name("SH Reality Stone abilities")
|
||||
@Config.Comment("Should the Reality Stone have the abilities of the Speedster Heroes Reality Stone if it is installed")
|
||||
public static boolean useSHRealityAbilities = false;
|
||||
|
||||
@Config.Name("Size changing")
|
||||
@Config.Comment("Should the Reality Stone be able to change the size")
|
||||
public static boolean sizeChanging = false;
|
||||
|
||||
@Config.Name("Size")
|
||||
@Config.Comment("Which size should the Reality Stone change it's user to")
|
||||
@Config.RangeDouble(min = 0.1f, max = 10)
|
||||
public static float size = 0.1f;
|
||||
|
||||
|
||||
public static int soulWorldID;
|
||||
|
||||
@Config.Name("Can Snap change Gamemode")
|
||||
@Config.Comment("Can the Snap change the Gamemode to Creative")
|
||||
public static boolean snapCreative = false;
|
||||
|
||||
@Config.Name("HeroesExpansion Abilities")
|
||||
@Config.Comment("Should some stones use abilities from HeroesExpansion")
|
||||
public static boolean heAbilities = true;
|
||||
|
||||
@Config.Name("StarTech Abilities")
|
||||
@Config.Comment("Should the Power Stone use the abilities from the StarTech Power Stone if installed")
|
||||
public static boolean stAbilities = true;
|
||||
|
||||
|
||||
@Config.Name("Power Burst Cooldown")
|
||||
@Config.Comment("How big long should the StarTech Power Stone burst cooldown be")
|
||||
@Config.RangeInt(min = 0, max = 1000)
|
||||
public static int powerCooldown = 100;
|
||||
}
|
||||
|
||||
@Config(category = "worldgen", modid = Infinity.MOD_ID)
|
||||
public static class Worldgen {
|
||||
|
||||
@Config.Name("Enable Stone worldgen")
|
||||
public static boolean enable = true;
|
||||
|
||||
@Config.Name("Power Stone Dimension")
|
||||
public static int powerDim = 0;
|
||||
|
||||
@Config.Name("Space Stone Dimension")
|
||||
public static int spaceDim = 0;
|
||||
|
||||
@Config.Name("Reality Stone Dimension")
|
||||
public static int realityDim = 0;
|
||||
|
||||
@Config.Name("Soul Stone Dimension")
|
||||
public static int soulDim = 0;
|
||||
|
||||
@Config.Name("Time Stone Dimension")
|
||||
public static int timeDim = 0;
|
||||
|
||||
@Config.Name("Mind Stone Dimension")
|
||||
public static int mindDim = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import anvil.infinity.abilities.AbilityChangeSnap;
|
|||
import anvil.infinity.api.AbilityAdderHandler;
|
||||
import anvil.infinity.compat.CompatHandler;
|
||||
import anvil.infinity.config.ConfigHandler;
|
||||
import anvil.infinity.config.ModConfig;
|
||||
import lucraft.mods.lucraftcore.infinity.EnumInfinityStone;
|
||||
import lucraft.mods.lucraftcore.infinity.ModuleInfinity;
|
||||
import lucraft.mods.lucraftcore.infinity.items.ItemInfinityStone;
|
||||
|
@ -38,7 +39,7 @@ public class ItemMindStone extends ItemInfinityStone {
|
|||
public Ability.AbilityMap addStoneAbilities(EntityLivingBase entity, Ability.AbilityMap abilities, Ability.EnumAbilityContext context) {
|
||||
abilities.put("flight", new AbilityFlight(entity).setDataValue(AbilityFlight.SPEED, 1f).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.YELLOW));
|
||||
abilities.put("changesnap", new AbilityChangeSnap(entity).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.YELLOW));
|
||||
if (CompatHandler.isHeroesExpansion && ConfigHandler.heAbilities) {
|
||||
if (CompatHandler.isHeroesExpansion && ModConfig.General.heAbilities) {
|
||||
abilities.put("telekinesis", CompatHandler.HeroesExpension.getAbilityGrabEntity(entity).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.YELLOW));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import anvil.infinity.abilities.AbilitySaturation;
|
|||
import anvil.infinity.api.AbilityAdderHandler;
|
||||
import anvil.infinity.compat.CompatHandler;
|
||||
import anvil.infinity.config.ConfigHandler;
|
||||
import anvil.infinity.config.ModConfig;
|
||||
import lucraft.mods.lucraftcore.infinity.EnumInfinityStone;
|
||||
import lucraft.mods.lucraftcore.infinity.ModuleInfinity;
|
||||
import lucraft.mods.lucraftcore.infinity.items.ItemInfinityStone;
|
||||
|
@ -43,8 +44,8 @@ public class ItemPowerStone extends ItemInfinityStone implements IAbilityProvide
|
|||
abilities.put("damage", new AbilityPunch(entity).setDataValue(AbilityPunch.AMOUNT, Float.MAX_VALUE).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.PURPLE));
|
||||
abilities.put("resistance", new AbilityDamageResistance(entity).setDataValue(AbilityAttributeModifier.AMOUNT, Float.MAX_VALUE).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.PURPLE));
|
||||
abilities.put("saturation", new AbilitySaturation(entity));
|
||||
if (CompatHandler.isStarTech && ConfigHandler.stAbilities) {
|
||||
abilities.put("power_blat", CompatHandler.StarTech.getAbilityPowerBlast(entity).setMaxCooldown(ConfigHandler.powerCooldown).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.PURPLE));
|
||||
if (CompatHandler.isStarTech && ModConfig.General.stAbilities) {
|
||||
abilities.put("power_blat", CompatHandler.StarTech.getAbilityPowerBlast(entity).setMaxCooldown(ModConfig.General.powerCooldown).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.PURPLE));
|
||||
abilities.put("power_impower", CompatHandler.StarTech.getAbilityPowerImpower(entity).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.PURPLE));
|
||||
abilities.put("power_rocket_burst", CompatHandler.StarTech.getAbilityPowerRocketBurst(entity).setMaxCooldown(100).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.PURPLE));
|
||||
abilities.put("power_tendrils", CompatHandler.StarTech.getAbilityTendrils(entity).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.PURPLE));
|
||||
|
@ -67,7 +68,7 @@ public class ItemPowerStone extends ItemInfinityStone implements IAbilityProvide
|
|||
abilities.put("strength", new AbilityStrength(entity).setDataValue(AbilityAttributeModifier.AMOUNT, Float.MAX_VALUE));
|
||||
abilities.put("damage", new AbilityPunch(entity).setDataValue(AbilityPunch.AMOUNT, Float.MAX_VALUE));
|
||||
abilities.put("resistance", new AbilityDamageResistance(entity).setDataValue(AbilityAttributeModifier.AMOUNT, Float.MAX_VALUE));
|
||||
if (CompatHandler.isStarTech && ConfigHandler.stAbilities) {
|
||||
if (CompatHandler.isStarTech && ModConfig.General.stAbilities) {
|
||||
abilities.put("power_tendrils", CompatHandler.StarTech.getAbilityTendrils(entity));
|
||||
abilities.put("power_cyclone", CompatHandler.StarTech.getAbilityCyclone(entity));
|
||||
abilities.put("power_burnout", CompatHandler.StarTech.getAbilityBurnout(entity));
|
||||
|
|
|
@ -3,6 +3,7 @@ package anvil.infinity.items;
|
|||
import anvil.infinity.api.AbilityAdderHandler;
|
||||
import anvil.infinity.compat.CompatHandler;
|
||||
import anvil.infinity.config.ConfigHandler;
|
||||
import anvil.infinity.config.ModConfig;
|
||||
import lucraft.mods.lucraftcore.infinity.EnumInfinityStone;
|
||||
import lucraft.mods.lucraftcore.infinity.ModuleInfinity;
|
||||
import lucraft.mods.lucraftcore.infinity.items.ItemInfinityStone;
|
||||
|
@ -35,11 +36,11 @@ public class ItemRealityStone extends ItemInfinityStone {
|
|||
|
||||
@Override
|
||||
public Ability.AbilityMap addStoneAbilities(EntityLivingBase entity, Ability.AbilityMap abilities, Ability.EnumAbilityContext context) {
|
||||
if (ConfigHandler.sizeChanging) {
|
||||
abilities.put("size", new AbilitySizeChange(entity).setDataValue(AbilitySizeChange.SIZE, ConfigHandler.size).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.RED));
|
||||
if (ModConfig.General.sizeChanging) {
|
||||
abilities.put("size", new AbilitySizeChange(entity).setDataValue(AbilitySizeChange.SIZE, ModConfig.General.size).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.RED));
|
||||
}
|
||||
abilities.put("invisibility", new AbilityInvisibility(entity).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.RED));
|
||||
if (CompatHandler.isSpeedsterHeroes && ConfigHandler.useSHRealityAbilities) {
|
||||
if (CompatHandler.isSpeedsterHeroes && ModConfig.General.useSHRealityAbilities) {
|
||||
abilities.put("save_block", CompatHandler.SpeedsterHeroes.getAbilitySaveBlock(entity).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.RED));
|
||||
abilities.put("change_block", CompatHandler.SpeedsterHeroes.getAbilityChangeBlock(entity).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.RED));
|
||||
abilities.put("turn_into_bubbles", CompatHandler.SpeedsterHeroes.getAbilityTurnIntoBubbles(entity).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.RED));
|
||||
|
|
|
@ -5,6 +5,7 @@ import anvil.infinity.abilities.AbilitySnap;
|
|||
import anvil.infinity.api.AbilityAdderHandler;
|
||||
import anvil.infinity.conditions.ICondition;
|
||||
import anvil.infinity.config.ConfigHandler;
|
||||
import anvil.infinity.config.ModConfig;
|
||||
import anvil.infinity.helpers.GauntelHelper;
|
||||
import lucraft.mods.lucraftcore.infinity.EnumInfinityStone;
|
||||
import lucraft.mods.lucraftcore.infinity.ModuleInfinity;
|
||||
|
@ -46,7 +47,7 @@ public class ItemSoulStone extends ItemInfinityStone {
|
|||
|
||||
@Override
|
||||
public Ability.AbilityMap addStoneAbilities(EntityLivingBase entity, Ability.AbilityMap abilities, Ability.EnumAbilityContext context) {
|
||||
if (ConfigHandler.soulHealthBoost) {
|
||||
if (ModConfig.General.soulHealthBoost) {
|
||||
abilities.put("immortality", new AbilityHealth(entity).setDataValue(AbilityAttributeModifier.AMOUNT, Float.MAX_VALUE).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.ORANGE));
|
||||
}
|
||||
abilities.put("healing", new AbilityHealing(entity).setDataValue(AbilityHealing.FREQUENCY, 1).setDataValue(Ability.BAR_COLOR, EnumAbilityBarColor.ORANGE));
|
||||
|
|
|
@ -3,6 +3,7 @@ package anvil.infinity.snap;
|
|||
import anvil.infinity.capabilities.ICapabilityPlayerData;
|
||||
import anvil.infinity.config.ConfigHandler;
|
||||
import anvil.infinity.capabilities.GauntletUserInformation;
|
||||
import anvil.infinity.config.ModConfig;
|
||||
import anvil.infinity.helpers.GauntelHelper;
|
||||
import anvil.infinity.registry.Effects;
|
||||
import lucraft.mods.lucraftcore.karma.capabilities.CapabilityKarma;
|
||||
|
@ -77,7 +78,7 @@ public class SnapHelper {
|
|||
|
||||
|
||||
} else if (data.getSnapResult() == SnapResult.CREATIVE) {
|
||||
if (ConfigHandler.snapCreative) {
|
||||
if (ModConfig.General.snapCreative) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
|
||||
if (((EntityPlayer) entity).capabilities.isCreativeMode) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package anvil.infinity.snap;
|
||||
|
||||
import anvil.infinity.config.ConfigHandler;
|
||||
import anvil.infinity.config.ModConfig;
|
||||
|
||||
public enum SnapResult {
|
||||
|
||||
|
@ -24,7 +25,7 @@ public enum SnapResult {
|
|||
case DESTROYSTONES: return BRINGBACK;
|
||||
case BRINGBACK: return RECREATE;
|
||||
case RECREATE: return KILLEVIL;
|
||||
case KILLEVIL: if (ConfigHandler.snapCreative) {return CREATIVE;} else {return KILLHALF;}
|
||||
case KILLEVIL: if (ModConfig.General.snapCreative) {return CREATIVE;} else {return KILLHALF;}
|
||||
case CREATIVE: return KILLHALF;
|
||||
}
|
||||
return KILLHALF;
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
package anvil.infinity.worldgen;
|
||||
|
||||
import anvil.infinity.config.ModConfig;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
import net.minecraft.world.gen.structure.template.Template;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class InfinityWorldGenerator extends WorldGenerator implements IWorldGenerator {
|
||||
|
||||
@Override
|
||||
public boolean generate(World worldIn, Random rand, BlockPos position) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
|
||||
int dim = world.provider.getDimension();
|
||||
if ( (chunkX > 1000 || chunkX < -1000) && (chunkZ > 1000 || chunkZ < -1000) && ModConfig.Worldgen.enable ) {
|
||||
int blockX = chunkX * 16 + 8;
|
||||
int blockZ = chunkZ * 16 + 8;
|
||||
if (canGenMind(world) || canGenPower(world) || canGenReality(world) || canGenSoul(world) || canGenSpace(world) || canGenTime(world)) {
|
||||
if ((int) (Math.random() * 1000) == 0) {
|
||||
int y = getGroundFromAbove(world, blockX, blockZ);
|
||||
BlockPos pos = new BlockPos(blockX, y, blockZ);
|
||||
WorldGenerator structure = new StoneTempleGen();
|
||||
structure.generate(world, random, pos);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static int getGroundFromAbove(World world, int x, int z)
|
||||
{
|
||||
int y = 255;
|
||||
boolean foundGround = false;
|
||||
while(!foundGround && y-- >= 31)
|
||||
{
|
||||
Block blockAt = world.getBlockState(new BlockPos(x,y,z)).getBlock();
|
||||
foundGround = blockAt == Blocks.WATER||blockAt == Blocks.FLOWING_WATER||blockAt == Blocks.GRASS || blockAt == Blocks.SAND || blockAt == Blocks.SNOW || blockAt == Blocks.SNOW_LAYER || blockAt == Blocks.GLASS||blockAt == Blocks.MYCELIUM;
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
public static boolean canSpawnHere(Template template, World world, BlockPos posAboveGround)
|
||||
{
|
||||
int zwidth = template.getSize().getZ();
|
||||
int xwidth = template.getSize().getX();
|
||||
|
||||
boolean corner1 = isCornerValid(world, posAboveGround);
|
||||
boolean corner2 = isCornerValid(world, posAboveGround.add(xwidth, 0, zwidth));
|
||||
|
||||
return posAboveGround.getY() > 31 && corner1 && corner2;
|
||||
}
|
||||
|
||||
public static boolean isCornerValid(World world, BlockPos pos)
|
||||
{
|
||||
int variation = 3;
|
||||
int highestBlock = getGroundFromAbove(world, pos.getX(), pos.getZ());
|
||||
|
||||
if (highestBlock > pos.getY() - variation && highestBlock < pos.getY() + variation)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canGenPower(World w) {
|
||||
WorldData data = WorldData.get(w);
|
||||
int dim = w.provider.getDimension();
|
||||
return !data.power && ModConfig.Worldgen.powerDim == dim;
|
||||
}
|
||||
|
||||
public static boolean canGenSoul(World w) {
|
||||
WorldData data = WorldData.get(w);
|
||||
int dim = w.provider.getDimension();
|
||||
return !data.soul && ModConfig.Worldgen.soulDim == dim;
|
||||
}
|
||||
|
||||
public static boolean canGenSpace(World w) {
|
||||
WorldData data = WorldData.get(w);
|
||||
int dim = w.provider.getDimension();
|
||||
return !data.space && ModConfig.Worldgen.spaceDim == dim;
|
||||
}
|
||||
|
||||
public static boolean canGenReality(World w) {
|
||||
WorldData data = WorldData.get(w);
|
||||
int dim = w.provider.getDimension();
|
||||
return !data.reality && ModConfig.Worldgen.realityDim == dim;
|
||||
}
|
||||
|
||||
public static boolean canGenTime(World w) {
|
||||
WorldData data = WorldData.get(w);
|
||||
int dim = w.provider.getDimension();
|
||||
return !data.time && ModConfig.Worldgen.timeDim == dim;
|
||||
}
|
||||
|
||||
public static boolean canGenMind(World w) {
|
||||
WorldData data = WorldData.get(w);
|
||||
int dim = w.provider.getDimension();
|
||||
return !data.mind && ModConfig.Worldgen.mindDim == dim;
|
||||
}
|
||||
|
||||
}
|
107
src/main/java/anvil/infinity/worldgen/StoneTempleGen.java
Normal file
107
src/main/java/anvil/infinity/worldgen/StoneTempleGen.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
package anvil.infinity.worldgen;
|
||||
|
||||
import anvil.infinity.Infinity;
|
||||
import anvil.infinity.items.Items;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
||||
import net.minecraft.world.gen.structure.template.Template;
|
||||
import net.minecraft.world.gen.structure.template.TemplateManager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class StoneTempleGen extends WorldGenerator {
|
||||
|
||||
@Override
|
||||
public boolean generate(World world, Random rand, BlockPos position) {
|
||||
|
||||
if (InfinityWorldGenerator.canGenMind(world)) {
|
||||
gen(world, position, Items.MIND_STONE);
|
||||
WorldData data = WorldData.get(world);
|
||||
data.mind = true;
|
||||
data.markDirty();
|
||||
return true;
|
||||
} else if (InfinityWorldGenerator.canGenSpace(world)) {
|
||||
gen(world, position, Items.SPACE_STONE);
|
||||
WorldData data = WorldData.get(world);
|
||||
data.space = true;
|
||||
data.markDirty();
|
||||
return true;
|
||||
} else if (InfinityWorldGenerator.canGenReality(world)) {
|
||||
gen(world, position, Items.REALITY_STONE);
|
||||
WorldData data = WorldData.get(world);
|
||||
data.reality = true;
|
||||
data.markDirty();
|
||||
return true;
|
||||
} else if (InfinityWorldGenerator.canGenTime(world)) {
|
||||
gen(world, position, Items.TIME_STONE);
|
||||
WorldData data = WorldData.get(world);
|
||||
data.time = true;
|
||||
data.markDirty();
|
||||
return true;
|
||||
} else if (InfinityWorldGenerator.canGenSoul(world)) {
|
||||
gen(world, position, Items.SOUL_STONE);
|
||||
WorldData data = WorldData.get(world);
|
||||
data.soul = true;
|
||||
data.markDirty();
|
||||
return true;
|
||||
} else if (InfinityWorldGenerator.canGenPower(world)) {
|
||||
gen(world, position, Items.POWER_STONE);
|
||||
WorldData data = WorldData.get(world);
|
||||
data.power = true;
|
||||
data.markDirty();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void gen(World world, BlockPos position, Item stone) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
MinecraftServer minecraftserver = world.getMinecraftServer();
|
||||
TemplateManager templatemanager = worldserver.getStructureTemplateManager();
|
||||
Template template = templatemanager.getTemplate(minecraftserver, new ResourceLocation(Infinity.MOD_ID+":stonetemple"));
|
||||
|
||||
|
||||
IBlockState iblockstate = world.getBlockState(position);
|
||||
world.notifyBlockUpdate(position, iblockstate, iblockstate, 3);
|
||||
|
||||
PlacementSettings placementsettings = (new PlacementSettings()).setMirror(Mirror.NONE)
|
||||
.setRotation(Rotation.NONE).setIgnoreEntities(false).setChunk((ChunkPos) null)
|
||||
.setReplacedBlock((Block) null).setIgnoreStructureBlock(false);
|
||||
|
||||
template.getDataBlocks(position, placementsettings);
|
||||
template.addBlocksToWorld(world, position.add(0, 1, 0), placementsettings);
|
||||
|
||||
|
||||
Map<BlockPos, String> map = template.getDataBlocks(position, placementsettings);
|
||||
|
||||
for (Map.Entry<BlockPos, String> entry : map.entrySet()) {
|
||||
if ("chest".equals(entry.getValue())) {
|
||||
BlockPos blockpos2 = entry.getKey();
|
||||
world.setBlockState(blockpos2.up(), Blocks.AIR.getDefaultState(), 3);
|
||||
TileEntity tileentity = world.getTileEntity(blockpos2);
|
||||
|
||||
if (tileentity instanceof TileEntityChest) {
|
||||
((TileEntityChest) tileentity).getSingleChestHandler().insertItem(13, new ItemStack(stone), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
57
src/main/java/anvil/infinity/worldgen/WorldData.java
Normal file
57
src/main/java/anvil/infinity/worldgen/WorldData.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
package anvil.infinity.worldgen;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.MapStorage;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
|
||||
public class WorldData extends WorldSavedData {
|
||||
|
||||
static String NAME = "generated_stones";
|
||||
|
||||
public WorldData() {
|
||||
super(NAME);
|
||||
}
|
||||
|
||||
public boolean power;
|
||||
public boolean space;
|
||||
public boolean reality;
|
||||
public boolean soul;
|
||||
public boolean time;
|
||||
public boolean mind;
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
power = nbt.getBoolean("power");
|
||||
space = nbt.getBoolean("space");
|
||||
reality = nbt.getBoolean("reality");
|
||||
soul = nbt.getBoolean("soul");
|
||||
time = nbt.getBoolean("time");
|
||||
mind = nbt.getBoolean("mind");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setBoolean("power", power);
|
||||
compound.setBoolean("space", space);
|
||||
compound.setBoolean("reality", reality);
|
||||
compound.setBoolean("soul", soul);
|
||||
compound.setBoolean("time", time);
|
||||
compound.setBoolean("mind", mind);
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static WorldData get(World world) {
|
||||
MapStorage storage = world.getMapStorage();
|
||||
WorldData instance = (WorldData) storage.getOrLoadData(WorldData.class, NAME);
|
||||
|
||||
if (instance == null) {
|
||||
instance = new WorldData();
|
||||
storage.setData(NAME, instance);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
BIN
src/main/resources/assets/infinity/structures/stonetemple.nbt
Normal file
BIN
src/main/resources/assets/infinity/structures/stonetemple.nbt
Normal file
Binary file not shown.
Loading…
Reference in a new issue