Skip to content

Commit

Permalink
rewrites the api and some registries, #22, #23, #24
Browse files Browse the repository at this point in the history
  • Loading branch information
way2muchnoise committed Jan 25, 2016
1 parent 86d16a1 commit 87642c3
Show file tree
Hide file tree
Showing 90 changed files with 887 additions and 2,489 deletions.
45 changes: 0 additions & 45 deletions examples/ores.json

This file was deleted.

10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version_forge=11.15.0.1707
version_forge=11.15.1.1722
version_minecraft=1.8.9
version_major=0
version_minor=2
version_revis=1
version_minor=3
version_revis=0
version_mappings=snapshot_20160101
version_jei=2.21+
version_thaumcraft=5.1.0
version_jei=2.22+
version_thaumcraft=5.1.4
14 changes: 3 additions & 11 deletions src/main/java/jeresources/JEResources.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package jeresources;

import jeresources.compatibility.JERAPI;
import jeresources.config.ConfigHandler;
import jeresources.config.Settings;
import jeresources.profiling.ProfileCommand;
import jeresources.proxy.CommonProxy;
import jeresources.reference.MetaData;
import jeresources.reference.Reference;
import jeresources.registry.MessageRegistry;
import jeresources.utils.LogHelper;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
Expand Down Expand Up @@ -42,17 +42,9 @@ public void preInit(FMLPreInitializationEvent event)

LogHelper.info("Registering Events...");
PROXY.registerEvents();
}

@Mod.EventHandler
public void imcCallback(FMLInterModComms.IMCEvent event)
{
for (final FMLInterModComms.IMCMessage imcMessage : event.getMessages())
{
LogHelper.debug("Message Received - Sender: " + imcMessage.getSender() + " - Message Type: " + imcMessage.key);
if (imcMessage.isNBTMessage())
MessageRegistry.registerMessage(imcMessage.key, imcMessage.getNBTValue());
}
LogHelper.info("Init API...");
JERAPI.init(event.getAsmData());
}

@Mod.EventHandler
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/jeresources/api/IJERAPI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package jeresources.api;

public interface IJERAPI
{
IMobRegistry getMobRegistry();
IWorldGenRegistry getWorldGenRegistry();
}
6 changes: 6 additions & 0 deletions src/main/java/jeresources/api/IJERPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package jeresources.api;

public interface IJERPlugin
{
void APIDelivery(IJERAPI ijerapi);
}
19 changes: 19 additions & 0 deletions src/main/java/jeresources/api/IMobRegistry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package jeresources.api;

import jeresources.api.conditionals.LightLevel;
import jeresources.api.drop.DropItem;
import jeresources.api.render.IMobRenderHook;
import net.minecraft.entity.EntityLivingBase;

public interface IMobRegistry
{
void registerMob(EntityLivingBase entity, LightLevel lightLevel, int minExp, int maxExp, String[] biomes, DropItem... drops);
void registerMob(EntityLivingBase entity, LightLevel lightLevel, String[] biomes, DropItem... drops);
void registerMob(EntityLivingBase entity, LightLevel lightLevel, int exp, String[] biomes, DropItem... drops);
void registerMob(EntityLivingBase entity, LightLevel lightLevel, int exp, DropItem... drops);
void registerMob(EntityLivingBase entity, LightLevel lightLevel, int minExp, int maxExp, DropItem... drops);

void registerDrops(Class<? extends EntityLivingBase> entity, DropItem... drops);

void registerRenderHook(Class<? extends EntityLivingBase> entity, IMobRenderHook renderHook);
}
16 changes: 16 additions & 0 deletions src/main/java/jeresources/api/IWorldGenRegistry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package jeresources.api;

import jeresources.api.distributions.DistributionBase;
import jeresources.api.drop.DropItem;
import jeresources.api.restrictions.Restriction;
import net.minecraft.item.ItemStack;

public interface IWorldGenRegistry
{
void register(ItemStack block, DistributionBase distribution, DropItem... drops);
void register(ItemStack block, DistributionBase distribution, Restriction restriction, DropItem... drops);
void register(ItemStack block, DistributionBase distribution, boolean silktouch, DropItem... drops);
void register(ItemStack block, DistributionBase distribution, Restriction restriction, boolean silktouch, DropItem... drops);

void registerDrops(ItemStack block, DropItem... drops);
}
8 changes: 8 additions & 0 deletions src/main/java/jeresources/api/JERPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package jeresources.api;

/**
* Implement {@link IJERPlugin} on a class with this interface
*/
public @interface JERPlugin
{
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package jeresources.api.utils.conditionals;
package jeresources.api.conditionals;

import jeresources.api.utils.Modifier;
import jeresources.api.render.TextModifier;
import net.minecraft.util.StatCollector;

import java.util.LinkedHashMap;
Expand All @@ -10,49 +10,49 @@ public class Conditional
{
public static final Map<Conditional, Conditional> reverse = new LinkedHashMap<Conditional, Conditional>();

public static final Conditional magmaCream = new Conditional("jer.magmaCream.text", Modifier.darkRed);
public static final Conditional slimeBall = new Conditional("jer.slimeBall.text", Modifier.lightGreen);
public static final Conditional rareDrop = new Conditional("jer.rareDrop.text", Modifier.purple);
public static final Conditional silkTouch = new Conditional("jer.ore.silkTouch", Modifier.darkCyan);
public static final Conditional equipmentDrop = new Conditional("jer.equipmentDrop.text", Modifier.lightCyan);
public static final Conditional magmaCream = new Conditional("jer.magmaCream.text", TextModifier.darkRed);
public static final Conditional slimeBall = new Conditional("jer.slimeBall.text", TextModifier.lightGreen);
public static final Conditional rareDrop = new Conditional("jer.rareDrop.text", TextModifier.purple);
public static final Conditional silkTouch = new Conditional("jer.worldgen.silkTouch", TextModifier.darkCyan);
public static final Conditional equipmentDrop = new Conditional("jer.equipmentDrop.text", TextModifier.lightCyan);

public static final Conditional burning = new Conditional("jer.burning.text", Modifier.lightRed);
public static final Conditional burning = new Conditional("jer.burning.text", TextModifier.lightRed);
public static final Conditional notBurning = new Conditional("jer.notBurning.text", burning);
public static final Conditional wet = new Conditional("jer.wet.text", Modifier.lightCyan);
public static final Conditional wet = new Conditional("jer.wet.text", TextModifier.lightCyan);
public static final Conditional notWet = new Conditional("jer.notWet.text", wet);
public static final Conditional hasPotion = new Conditional("jer.hasPotion.text", Modifier.pink);
public static final Conditional hasPotion = new Conditional("jer.hasPotion.text", TextModifier.pink);
public static final Conditional hasNoPotion = new Conditional("jer.hasNoPotion.text", hasPotion);
public static final Conditional beyond = new Conditional("jer.beyond.text", Modifier.darkGreen);
public static final Conditional beyond = new Conditional("jer.beyond.text", TextModifier.darkGreen);
public static final Conditional nearer = new Conditional("jer.nearer.text", beyond);
public static final Conditional raining = new Conditional("jer.raining.text", Modifier.lightGrey);
public static final Conditional raining = new Conditional("jer.raining.text", TextModifier.lightGrey);
public static final Conditional dry = new Conditional("jer.dry.text", raining);
public static final Conditional thundering = new Conditional("jer.thundering.text", Modifier.darkGrey);
public static final Conditional thundering = new Conditional("jer.thundering.text", TextModifier.darkGrey);
public static final Conditional notThundering = new Conditional("jer.notThundering.text", thundering);
public static final Conditional moonPhase = new Conditional("jer.moonPhase.text");
public static final Conditional notMoonPhase = new Conditional("jer.notMoonPhase.text", moonPhase);
public static final Conditional pastTime = new Conditional("jer.pastTime.text", Modifier.lilac);
public static final Conditional pastTime = new Conditional("jer.pastTime.text", TextModifier.lilac);
public static final Conditional beforeTime = new Conditional("jer.beforeTime.text", pastTime);
public static final Conditional pastWorldTime = new Conditional("jer.pastWorldTime.text", Modifier.purple);
public static final Conditional pastWorldTime = new Conditional("jer.pastWorldTime.text", TextModifier.purple);
public static final Conditional beforeWorldTime = new Conditional("jer.beforeWorldTime.text", pastWorldTime);
public static final Conditional pastWorldDifficulty = new Conditional("jer.pastWorldDifficulty.text", Modifier.orange);
public static final Conditional pastWorldDifficulty = new Conditional("jer.pastWorldDifficulty.text", TextModifier.orange);
public static final Conditional beforeWorldDifficulty = new Conditional("jer.beforeWorldDifficulty.text", pastWorldDifficulty);
public static final Conditional gameDifficulty = new Conditional("jer.gameDifficulty.text", Modifier.orange);
public static final Conditional gameDifficulty = new Conditional("jer.gameDifficulty.text", TextModifier.orange);
public static final Conditional notGameDifficulty = new Conditional("jer.notGameDifficulty.text", gameDifficulty);
public static final Conditional inDimension = new Conditional("jer.inDimension.text", Modifier.yellow);
public static final Conditional inDimension = new Conditional("jer.inDimension.text", TextModifier.yellow);
public static final Conditional notInDimension = new Conditional("jer.notInDimension.text", inDimension);
public static final Conditional inBiome = new Conditional("jer.inBiome.text", Modifier.orange);
public static final Conditional inBiome = new Conditional("jer.inBiome.text", TextModifier.orange);
public static final Conditional notInBiome = new Conditional("jer.notInBiome.text", inBiome);
public static final Conditional onBlock = new Conditional("jer.onBlock.text", Modifier.lightRed);
public static final Conditional onBlock = new Conditional("jer.onBlock.text", TextModifier.lightRed);
public static final Conditional notOnBlock = new Conditional("jer.notOnBlock.text", onBlock);
public static final Conditional below = new Conditional("jer.below.text", Modifier.darkGreen);
public static final Conditional below = new Conditional("jer.below.text", TextModifier.darkGreen);
public static final Conditional above = new Conditional("jer.above.text", below);
public static final Conditional playerOnline = new Conditional("jer.playerOnline.text", Modifier.bold);
public static final Conditional playerOnline = new Conditional("jer.playerOnline.text", TextModifier.bold);
public static final Conditional playerOffline = new Conditional("jer.playerOffline.text", playerOnline);
public static final Conditional playerKill = new Conditional("jer.playerKill.text");
public static final Conditional notPlayerKill = new Conditional("jer.notPlayerKill.text", playerKill);
public static final Conditional aboveLooting = new Conditional("jer.aboveLooting.text", Modifier.darkBlue);
public static final Conditional aboveLooting = new Conditional("jer.aboveLooting.text", TextModifier.darkBlue);
public static final Conditional belowLooting = new Conditional("jer.belowLooting.text", aboveLooting);
public static final Conditional killedBy = new Conditional("jer.killedBy.text", Modifier.darkRed);
public static final Conditional killedBy = new Conditional("jer.killedBy.text", TextModifier.darkRed);
public static final Conditional notKilledBy = new Conditional("jer.notKilledBy.text", killedBy);

protected String text;
Expand All @@ -63,11 +63,11 @@ public Conditional()
{
}

public Conditional(String text, Modifier... modifiers)
public Conditional(String text, TextModifier... textModifiers)
{
this.text = text;
for (Modifier modifier : modifiers)
colour += modifier.toString();
for (TextModifier textModifier : textModifiers)
colour += textModifier.toString();
}

public Conditional(String text, Conditional opposite)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jeresources.api.utils.conditionals;
package jeresources.api.conditionals;

public class ExtendedConditional extends Conditional
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jeresources.api.utils;
package jeresources.api.conditionals;

import net.minecraft.util.StatCollector;

Expand All @@ -14,49 +14,16 @@ public class LightLevel

/**
* @param level the level of light
* @param relative an {@link jeresources.api.utils.LightLevel.Relative}
* @param relative an {@link LightLevel.Relative}
*/
LightLevel(int level, Relative relative)
{
this.lightLevel = level;
this.relative = relative;
}

public static LightLevel decodeLightLevel(String string)
{
if (string == null || string.equals("") || !string.contains(":")) return any;
String[] splitString = string.split(":");

if (splitString.length != 2) return any;
int level;
try
{
level = Integer.valueOf(splitString[0]);
} catch (Exception e)
{
return any;
}
if (level < 0 || level > 15) return any;
return new LightLevel(level, splitString[1].equals("a") ? Relative.above : Relative.below);
}

public String encode()
{
return this.lightLevel + ":" + (relative == Relative.above ? "a" : "b");
}

/**
* @param level the level of light
* @param relative the relative positive is above, negative is below. Zero will also be below.
*/
LightLevel(int level, int relative)
{
this.lightLevel = level;
this.relative = relative > 0 ? Relative.above : Relative.below;
}

/**
* @param level the maximum level light the mob can spawn (the {@link jeresources.api.utils.LightLevel.Relative} will be below)
* @param level the maximum level light the mob can spawn (the {@link LightLevel.Relative} will be below)
*/
LightLevel(int level)
{
Expand All @@ -72,7 +39,7 @@ public String toString()
}

/**
* The {@link jeresources.api.utils.LightLevel.Relative} enum holding an above and below entry
* The {@link LightLevel.Relative} enum holding an above and below entry
*/
public enum Relative
{
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/jeresources/api/distributions/DistributionBase.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package jeresources.api.distributions;

import jeresources.api.messages.utils.MessageHelper;
import jeresources.api.messages.utils.MessageKeys;
import net.minecraft.nbt.NBTTagCompound;

public abstract class DistributionBase
{
private float[] distribution;
Expand All @@ -23,11 +19,4 @@ public int getBestHeight()
{
return bestHeight;
}

public NBTTagCompound writeToNBT(NBTTagCompound result)
{
result.setIntArray(MessageKeys.distribution, MessageHelper.getIntArray(distribution));
result.setInteger(MessageKeys.bestHeight, bestHeight);
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package jeresources.api.distributions;

import jeresources.api.utils.DistributionHelpers;

public class DistributionCustom extends DistributionBase
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jeresources.api.utils;
package jeresources.api.distributions;

import java.util.Collections;
import java.util.Set;
Expand Down Expand Up @@ -134,6 +134,11 @@ public static float[] addDistribution(float[] base, float[] add)
return addDistribution(base, add, 0);
}

public static DistributionBase addDistribution(DistributionBase base, DistributionBase add)
{
return new DistributionCustom(addDistribution(base.getDistribution(), add.getDistribution()));
}

/**
* @param base base distribution
* @param add the to add distribution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package jeresources.api.distributions;

import jeresources.api.utils.DistributionHelpers;

public class DistributionSquare extends DistributionBase
{
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package jeresources.api.distributions;

import jeresources.api.utils.DistributionHelpers;

public class DistributionTriangular extends DistributionBase
{
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package jeresources.api.distributions;

import jeresources.api.utils.DistributionHelpers;

public class DistributionUnderWater extends DistributionBase
{

Expand Down
Loading

0 comments on commit 87642c3

Please sign in to comment.