aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/kubatech/api/LoaderReference.java1
-rw-r--r--src/main/java/kubatech/api/network/LoadConfigPacket.java2
-rw-r--r--src/main/java/kubatech/client/effect/EntityRenderer.java59
-rw-r--r--src/main/java/kubatech/config/Config.java158
-rw-r--r--src/main/java/kubatech/loaders/MobRecipeLoader.java28
-rw-r--r--src/main/java/kubatech/nei/Mob_Handler.java22
6 files changed, 177 insertions, 93 deletions
diff --git a/src/main/java/kubatech/api/LoaderReference.java b/src/main/java/kubatech/api/LoaderReference.java
index 482da4204f..289ffb5d72 100644
--- a/src/main/java/kubatech/api/LoaderReference.java
+++ b/src/main/java/kubatech/api/LoaderReference.java
@@ -13,4 +13,5 @@ public class LoaderReference {
public static final boolean GTNHCoreMod = Loader.isModLoaded("dreamcraft");
public static final boolean GTPlusPlus = Loader.isModLoaded("miscutils");
public static final boolean HarvestCraft = Loader.isModLoaded("harvestcraft");
+ public static final boolean TwilightForest = Loader.isModLoaded("TwilightForest");
}
diff --git a/src/main/java/kubatech/api/network/LoadConfigPacket.java b/src/main/java/kubatech/api/network/LoadConfigPacket.java
index 2199eb2db9..defb139151 100644
--- a/src/main/java/kubatech/api/network/LoadConfigPacket.java
+++ b/src/main/java/kubatech/api/network/LoadConfigPacket.java
@@ -61,7 +61,7 @@ public class LoadConfigPacket implements IMessage {
@Override
public void toBytes(ByteBuf buf) {
- if (!Config.mobHandlerEnabled) buf.writeBoolean(false);
+ if (!Config.MobHandler.mobHandlerEnabled) buf.writeBoolean(false);
else {
buf.writeBoolean(true);
buf.writeInt(mobsToLoad.size());
diff --git a/src/main/java/kubatech/client/effect/EntityRenderer.java b/src/main/java/kubatech/client/effect/EntityRenderer.java
index ed545b3cb6..1e211b6491 100644
--- a/src/main/java/kubatech/client/effect/EntityRenderer.java
+++ b/src/main/java/kubatech/client/effect/EntityRenderer.java
@@ -1,23 +1,29 @@
package kubatech.client.effect;
import static net.minecraft.client.renderer.entity.RenderManager.*;
-import static org.lwjgl.opengl.GL11.GL_MODELVIEW_STACK_DEPTH;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import kubatech.Tags;
import kubatech.api.utils.MobUtils;
+import kubatech.config.Config;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.world.World;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
+import org.lwjgl.util.glu.GLU;
@SideOnly(Side.CLIENT)
public class EntityRenderer extends EntityFX {
+ private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[Entity Renderer]");
private EntityLiving entityToRender = null;
public EntityRenderer(World p_i1218_1_, double x, double y, double z, int age) {
@@ -79,38 +85,36 @@ public class EntityRenderer extends EntityFX {
entityToRender.worldObj = this.worldObj;
entityToRender.setPosition(this.posX, this.posY, this.posZ);
+ Minecraft mc = Minecraft.getMinecraft();
+
double rotation;
- // double headrotation;
+ double headrotation;
{
double x1 = this.posX;
- double x2 = Minecraft.getMinecraft().thePlayer.posX;
+ double x2 = mc.thePlayer.posX;
double y1 = this.posZ;
- double y2 = Minecraft.getMinecraft().thePlayer.posZ;
+ double y2 = mc.thePlayer.posZ;
double k = Math.toDegrees(Math.atan2(x2 - x1, y1 - y2));
if (k < 0d) k += 360d;
k -= 180d;
rotation = k;
}
- /*
- {
- double y1 = this.posY;
- double y2 = Minecraft.getMinecraft().thePlayer.posY;
- double d = Minecraft.getMinecraft()
- .thePlayer
- .getDistance(this.posX, Minecraft.getMinecraft().thePlayer.posY, this.posZ);
- double k = Math.toDegrees(Math.atan2(y1 - y2, d));
- if (k < 0d) k += 360d;
- headrotation = k;
- }
-
- */
+
+ {
+ double y1 = this.posY + entityToRender.getEyeHeight();
+ double y2 = mc.thePlayer.posY + mc.thePlayer.getEyeHeight();
+ double d = mc.thePlayer.getDistance(this.posX, y2, this.posZ);
+ double k = Math.toDegrees(Math.atan2(y1 - y2, d));
+ if (k < 0d) k += 360d;
+ headrotation = k;
+ }
entityToRender.prevRotationYawHead = entityToRender.rotationYawHead;
entityToRender.prevRenderYawOffset = entityToRender.renderYawOffset;
- // entityToRender.prevRotationPitch = entityToRender.rotationPitch;
+ entityToRender.prevRotationPitch = entityToRender.rotationPitch;
entityToRender.renderYawOffset = (float) rotation;
entityToRender.rotationYawHead = (float) rotation;
- // entityToRender.rotationPitch = (float)headrotation;
+ entityToRender.rotationPitch = (float) headrotation;
float p_147936_2_ = 0.5f;
@@ -128,7 +132,10 @@ public class EntityRenderer extends EntityFX {
GL11.glColor4f(1f, 1f, 1f, 1F);
RenderHelper.enableStandardItemLighting();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
- int stackdepth = GL11.glGetInteger(GL_MODELVIEW_STACK_DEPTH);
+
+ GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
+
+ int stackdepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH);
GL11.glPushMatrix();
GL11.glTranslatef(
(float) (this.posX - renderPosX), (float) (this.posY - renderPosY), (float) (this.posZ - renderPosZ));
@@ -145,8 +152,18 @@ public class EntityRenderer extends EntityFX {
}
}
- stackdepth -= GL11.glGetInteger(GL_MODELVIEW_STACK_DEPTH);
+ GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX);
+ stackdepth -= GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH);
if (stackdepth < 0) for (; stackdepth < 0; stackdepth++) GL11.glPopMatrix();
+ if (stackdepth > 0) for (; stackdepth > 0; stackdepth--) GL11.glPushMatrix();
+
+ GL11.glPopAttrib();
+
+ int err;
+ while ((err = GL11.glGetError()) != GL11.GL_NO_ERROR)
+ if (Config.Debug.showRenderErrors)
+ LOG.error(EntityList.getEntityString(entityToRender) + " | GL ERROR: " + err + " / "
+ + GLU.gluErrorString(err));
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_COLOR_MATERIAL);
diff --git a/src/main/java/kubatech/config/Config.java b/src/main/java/kubatech/config/Config.java
index b09de66910..da6bd4a16a 100644
--- a/src/main/java/kubatech/config/Config.java
+++ b/src/main/java/kubatech/config/Config.java
@@ -25,26 +25,108 @@ import net.minecraftforge.common.config.Configuration;
public class Config {
- private static class Categories {
- public static final String mobHandler = "MobHandler";
+ private enum Category {
+ MOB_HANDLER("MobHandler"),
+ DEBUG("Debug");
+ final String categoryName;
+
+ Category(String s) {
+ categoryName = s;
+ }
+
+ public String get() {
+ return categoryName;
+ }
+
+ @Override
+ public String toString() {
+ return get();
+ }
}
- public static boolean mobHandlerEnabled = true;
+ public static class MobHandler {
+
+ public static boolean mobHandlerEnabled = true;
+
+ public enum _CacheRegenerationTrigger {
+ Never,
+ ModAdditionRemoval,
+ ModAdditionRemovalChange,
+ Always;
+
+ public static _CacheRegenerationTrigger get(int oridinal) {
+ return values()[oridinal];
+ }
+ }
+
+ public static _CacheRegenerationTrigger regenerationTrigger =
+ _CacheRegenerationTrigger.ModAdditionRemovalChange;
+ public static boolean includeEmptyMobs = true;
+ public static String[] mobBlacklist;
+
+ private static void load(Configuration configuration) {
+ Category category = Category.MOB_HANDLER;
+ mobHandlerEnabled = configuration
+ .get(
+ category.get(),
+ "Enabled",
+ true,
+ "Enable \"Mob Drops\" NEI page and Extreme Extermination Chamber")
+ .getBoolean();
+ StringBuilder c = new StringBuilder("When will cache regeneration trigger? ");
+ for (_CacheRegenerationTrigger value : _CacheRegenerationTrigger.values())
+ c.append(value.ordinal()).append(" - ").append(value.name()).append(", ");
+ regenerationTrigger = _CacheRegenerationTrigger.get(configuration
+ .get(
+ category.get(),
+ "CacheRegenerationTrigger",
+ _CacheRegenerationTrigger.ModAdditionRemovalChange.ordinal(),
+ c.toString())
+ .getInt());
+ includeEmptyMobs = configuration
+ .get(category.get(), "IncludeEmptyMobs", true, "Include mobs that have no drops in NEI")
+ .getBoolean();
+ mobBlacklist = configuration
+ .get(
+ category.get(),
+ "MobBlacklist",
+ new String[] {
+ "Giant",
+ "Thaumcraft.TravelingTrunk",
+ "chisel.snowman",
+ "OpenBlocks.Luggage",
+ "OpenBlocks.MiniMe",
+ "SpecialMobs.SpecialCreeper",
+ "SpecialMobs.SpecialZombie",
+ "SpecialMobs.SpecialPigZombie",
+ "SpecialMobs.SpecialSlime",
+ "SpecialMobs.SpecialSkeleton",
+ "SpecialMobs.SpecialEnderman",
+ "SpecialMobs.SpecialCaveSpider",
+ "SpecialMobs.SpecialGhast",
+ "SpecialMobs.SpecialWitch",
+ "SpecialMobs.SpecialSpider",
+ "TwilightForest.HydraHead",
+ "TwilightForest.RovingCube",
+ "TwilightForest.Harbinger Cube",
+ "TwilightForest.Adherent",
+ "SpecialMobs.SpecialSilverfish",
+ },
+ "These mobs will be skipped when generating recipe map")
+ .getStringList();
+ }
+ }
- public enum _CacheRegenerationTrigger {
- Never,
- ModAdditionRemoval,
- ModAdditionRemovalChange,
- Always;
+ public static class Debug {
+ public static boolean showRenderErrors = false;
- public static _CacheRegenerationTrigger get(int oridinal) {
- return values()[oridinal];
+ private static void load(Configuration configuration) {
+ Category category = Category.DEBUG;
+ showRenderErrors =
+ configuration.get(category.get(), "ShowRenderErrors", false).getBoolean();
}
}
- public static _CacheRegenerationTrigger regenerationTrigger = _CacheRegenerationTrigger.ModAdditionRemovalChange;
- public static boolean includeEmptyMobs = true;
- public static String[] mobBlacklist;
public static File configFile;
public static File configDirectory;
@@ -61,54 +143,8 @@ public class Config {
Configuration configuration = new Configuration(configFile);
configuration.load();
- mobHandlerEnabled = configuration
- .get(
- Categories.mobHandler,
- "Enabled",
- true,
- "Enable \"Mob Drops\" NEI page and Extreme Extermination Chamber")
- .getBoolean();
- StringBuilder c = new StringBuilder("When will cache regeneration trigger? ");
- for (_CacheRegenerationTrigger value : _CacheRegenerationTrigger.values())
- c.append(value.ordinal()).append(" - ").append(value.name()).append(", ");
- regenerationTrigger = _CacheRegenerationTrigger.get(configuration
- .get(
- Categories.mobHandler,
- "CacheRegenerationTrigger",
- _CacheRegenerationTrigger.ModAdditionRemovalChange.ordinal(),
- c.toString())
- .getInt());
- includeEmptyMobs = configuration
- .get(Categories.mobHandler, "IncludeEmptyMobs", true, "Include mobs that have no drops in NEI")
- .getBoolean();
- mobBlacklist = configuration
- .get(
- Categories.mobHandler,
- "MobBlacklist",
- new String[] {
- "Giant",
- "Thaumcraft.TravelingTrunk",
- "chisel.snowman",
- "OpenBlocks.Luggage",
- "OpenBlocks.MiniMe",
- "SpecialMobs.SpecialCreeper",
- "SpecialMobs.SpecialZombie",
- "SpecialMobs.SpecialPigZombie",
- "SpecialMobs.SpecialSlime",
- "SpecialMobs.SpecialSkeleton",
- "SpecialMobs.SpecialEnderman",
- "SpecialMobs.SpecialCaveSpider",
- "SpecialMobs.SpecialGhast",
- "SpecialMobs.SpecialWitch",
- "SpecialMobs.SpecialSpider",
- "TwilightForest.HydraHead",
- "TwilightForest.RovingCube",
- "TwilightForest.Harbinger Cube",
- "TwilightForest.Adherent",
- "SpecialMobs.SpecialSilverfish",
- },
- "These mobs will be skipped when generating recipe map")
- .getStringList();
+ MobHandler.load(configuration);
+ Debug.load(configuration);
if (configuration.hasChanged()) {
configuration.save();
diff --git a/src/main/java/kubatech/loaders/MobRecipeLoader.java b/src/main/java/kubatech/loaders/MobRecipeLoader.java
index 6b183aa205..62b7d819f2 100644
--- a/src/main/java/kubatech/loaders/MobRecipeLoader.java
+++ b/src/main/java/kubatech/loaders/MobRecipeLoader.java
@@ -57,6 +57,7 @@ import minetweaker.MineTweakerAPI;
import minetweaker.api.entity.IEntityDefinition;
import minetweaker.api.item.IItemStack;
import minetweaker.mc1710.item.MCItemStack;
+import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
@@ -67,6 +68,7 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.monster.IMob;
+import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -82,7 +84,7 @@ import thaumcraft.common.items.wands.ItemWandCasting;
public class MobRecipeLoader {
- private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[Mob Handler]");
+ private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[Mob Recipe Loader]");
public static final MobRecipeLoader instance = new MobRecipeLoader();
@@ -580,7 +582,7 @@ public class MobRecipeLoader {
if (alreadyGenerated) return;
alreadyGenerated = true;
- if (!Config.mobHandlerEnabled) return;
+ if (!Config.MobHandler.mobHandlerEnabled) return;
World f = new GT_DummyWorld() {
@Override
@@ -593,6 +595,17 @@ public class MobRecipeLoader {
public List getEntitiesWithinAABB(Class p_72872_1_, AxisAlignedBB p_72872_2_) {
return new ArrayList();
}
+
+ @Override
+ public Block getBlock(int aX, int aY, int aZ) {
+ if (LoaderReference.TwilightForest
+ && new Throwable()
+ .getStackTrace()[1]
+ .getClassName()
+ .equals("twilightforest.client.renderer.entity.RenderTFSnowQueenIceShield"))
+ return Blocks.packed_ice;
+ return super.getBlock(aX, aY, aZ);
+ }
};
f.isRemote = true; // quick hack to get around achievements
@@ -603,17 +616,18 @@ public class MobRecipeLoader {
Gson gson = GSONUtils.GSON_BUILDER.create();
String modlistversion;
- if (Config.regenerationTrigger == Config._CacheRegenerationTrigger.ModAdditionRemoval)
+ if (Config.MobHandler.regenerationTrigger == Config.MobHandler._CacheRegenerationTrigger.ModAdditionRemoval)
modlistversion = ModUtils.getModListVersionIgnoringModVersions();
else modlistversion = ModUtils.getModListVersion();
- if (Config.regenerationTrigger != Config._CacheRegenerationTrigger.Always && cache.exists()) {
+ if (Config.MobHandler.regenerationTrigger != Config.MobHandler._CacheRegenerationTrigger.Always
+ && cache.exists()) {
LOG.info("Parsing Cached map");
Reader reader = null;
try {
reader = Files.newReader(cache, StandardCharsets.UTF_8);
MobRecipeLoaderCacheStructure s = gson.fromJson(reader, MobRecipeLoaderCacheStructure.class);
- if (Config.regenerationTrigger == Config._CacheRegenerationTrigger.Never
+ if (Config.MobHandler.regenerationTrigger == Config.MobHandler._CacheRegenerationTrigger.Never
|| s.version.equals(modlistversion)) {
for (Map.Entry<String, ArrayList<MobDrop>> entry : s.moblist.entrySet()) {
try {
@@ -1133,7 +1147,7 @@ public class MobRecipeLoader {
for (Map.Entry<String, GeneralMappedMob> entry : GeneralMobList.entrySet()) {
String k = entry.getKey();
GeneralMappedMob v = entry.getValue();
- if (Arrays.asList(Config.mobBlacklist).contains(k)) {
+ if (Arrays.asList(Config.MobHandler.mobBlacklist).contains(k)) {
LOG.info("Entity " + k + " is blacklisted, skipping");
continue;
}
@@ -1167,7 +1181,7 @@ public class MobRecipeLoader {
if (drops.isEmpty()) {
LOG.info("Entity " + k + " doesn't drop any items, skipping EEC map");
- if (!Config.includeEmptyMobs) continue;
+ if (!Config.MobHandler.includeEmptyMobs) continue;
LoadConfigPacket.instance.mobsToLoad.add(k);
LOG.info("Registered " + k);
continue;
diff --git a/src/main/java/kubatech/nei/Mob_Handler.java b/src/main/java/kubatech/nei/Mob_Handler.java
index 3c83006e3d..a870c07a24 100644
--- a/src/main/java/kubatech/nei/Mob_Handler.java
+++ b/src/main/java/kubatech/nei/Mob_Handler.java
@@ -20,7 +20,6 @@
package kubatech.nei;
import static kubatech.nei.Mob_Handler.Translations.*;
-import static org.lwjgl.opengl.GL11.GL_MODELVIEW_STACK_DEPTH;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIClientUtils;
@@ -37,12 +36,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Random;
+import kubatech.Tags;
import kubatech.api.LoaderReference;
import kubatech.api.mobhandler.MobDrop;
import kubatech.api.utils.FastRandom;
import kubatech.api.utils.InfernalHelper;
import kubatech.api.utils.MobUtils;
import kubatech.api.utils.ModUtils;
+import kubatech.config.Config;
import kubatech.kubatech;
import kubatech.loaders.MobRecipeLoader;
import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber;
@@ -64,9 +65,12 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.lwjgl.BufferUtils;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
+import org.lwjgl.util.glu.GLU;
public class Mob_Handler extends TemplateRecipeHandler {
@@ -109,6 +113,7 @@ public class Mob_Handler extends TemplateRecipeHandler {
}
}
+ private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[Mob Handler]");
private static final Mob_Handler instance = new Mob_Handler();
private static final List<MobCachedRecipe> cachedRecipes = new ArrayList<>();
public static int cycleTicksStatic = Math.abs((int) System.currentTimeMillis());
@@ -277,7 +282,9 @@ public class Mob_Handler extends TemplateRecipeHandler {
float x = buf.get(12);
float y = buf.get(13);
- int stackdepth = GL11.glGetInteger(GL_MODELVIEW_STACK_DEPTH);
+ int stackdepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH);
+
+ GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glPushMatrix();
@@ -303,8 +310,17 @@ public class Mob_Handler extends TemplateRecipeHandler {
}
}
- stackdepth -= GL11.glGetInteger(GL_MODELVIEW_STACK_DEPTH);
+ GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX);
+ stackdepth -= GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH);
if (stackdepth < 0) for (; stackdepth < 0; stackdepth++) GL11.glPopMatrix();
+ if (stackdepth > 0) for (; stackdepth > 0; stackdepth--) GL11.glPushMatrix();
+
+ GL11.glPopAttrib();
+
+ int err;
+ while ((err = GL11.glGetError()) != GL11.GL_NO_ERROR)
+ if (Config.Debug.showRenderErrors)
+ LOG.error(currentrecipe.mobname + " | GL ERROR: " + err + " / " + GLU.gluErrorString(err));
GL11.glDisable(GL11.GL_DEPTH_TEST);
}