mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-22 05:02:30 +00:00
So much formatting cleaning. Still, no one suggested decapitation, so an improvement!
This commit is contained in:
1 parent
fee1b8cc96
commit
2044198d2d
5 files changed
+50
-114
No files matched your search
@@ -150,13 +150,11 @@ public final class ConfigHandler {
|
||||
config.save();
|
||||
}
|
||||
|
||||
public static void loadPostInit()
|
||||
{
|
||||
public static void loadPostInit() {
|
||||
SheddingTracker.loadFromConfig(config);
|
||||
|
||||
if(config.hasChanged())
|
||||
config.save();
|
||||
|
||||
}
|
||||
|
||||
public static int loadPropInt(String propName, String desc, int default_) {
|
||||
|
||||
@@ -11,17 +11,8 @@
|
||||
*/
|
||||
package vazkii.botania.common.core.handler;
|
||||
|
||||
import vazkii.botania.common.shedding.SheddingTracker;
|
||||
import net.minecraft.entity.monster.EntityBlaze;
|
||||
import net.minecraft.entity.monster.EntityGhast;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.monster.EntitySlime;
|
||||
import net.minecraft.entity.monster.EntitySpider;
|
||||
import net.minecraft.entity.passive.EntityChicken;
|
||||
import net.minecraft.entity.passive.EntitySquid;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import vazkii.botania.common.shedding.SheddingTracker;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public final class SheddingHandler {
|
||||
@@ -33,7 +24,7 @@ public final class SheddingHandler {
|
||||
|
||||
SheddingTracker.ShedPattern pattern = SheddingTracker.getShedPattern(event.entity);
|
||||
|
||||
if(pattern != null){
|
||||
if(pattern != null) {
|
||||
if(event.entity.worldObj.rand.nextInt(pattern.getRate()) == 0)
|
||||
event.entity.entityDropItem(pattern.getItemStack(), 0.0F);
|
||||
}
|
||||
|
||||
@@ -619,6 +619,7 @@ public final class LexiconData {
|
||||
starfield = new ALexiconEntry(LibLexicon.MISC_STARFIELD, categoryMisc);
|
||||
starfield.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCrafingRecipes.recipeStarfield));
|
||||
}
|
||||
|
||||
public static void postInit() {
|
||||
if(SheddingTracker.hasShedding()) {
|
||||
shedding = new BLexiconEntry(LibLexicon.MISC_SHEDDING, categoryMisc);
|
||||
|
||||
@@ -1,70 +1,36 @@
|
||||
package vazkii.botania.common.lexicon.page;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.api.internal.IGuiLexiconEntry;
|
||||
import vazkii.botania.api.lexicon.LexiconPage;
|
||||
import vazkii.botania.api.lexicon.LexiconRecipeMappings;
|
||||
import vazkii.botania.api.lexicon.LexiconRecipeMappings.EntryData;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexiconEntry;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PageEntity extends LexiconPage{
|
||||
|
||||
Entity dummyEntity;
|
||||
|
||||
int relativeMouseX, relativeMouseY;
|
||||
|
||||
boolean tooltipEntity;
|
||||
|
||||
int size;
|
||||
|
||||
|
||||
public PageEntity(String unlocalizedName, String entity, int size) {
|
||||
super(unlocalizedName);
|
||||
Class EntityClass=(Class) EntityList.stringToClassMapping.get(entity);
|
||||
this.size=size;
|
||||
try {
|
||||
dummyEntity = (Entity)EntityClass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {null});
|
||||
} catch (InstantiationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -72,65 +38,55 @@ public class PageEntity extends LexiconPage{
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderScreen(IGuiLexiconEntry gui, int mx, int my) {
|
||||
|
||||
int text_x = gui.getLeft() + 16;
|
||||
int text_y = gui.getTop() + gui.getHeight() - 40;
|
||||
|
||||
int entity_scale = getEntityScale(size);
|
||||
|
||||
int entity_x = gui.getLeft() + gui.getWidth() / 2;
|
||||
int entity_y = gui.getTop() + gui.getHeight() / 2 + MathHelper.floor_float(dummyEntity.height * entity_scale / 2);
|
||||
|
||||
|
||||
tickEntity(dummyEntity);
|
||||
|
||||
renderEntity(gui, dummyEntity, entity_x, entity_y, entity_scale, dummyEntity.ticksExisted * 2);
|
||||
|
||||
|
||||
renderEntity(gui, dummyEntity, entity_x, entity_y, entity_scale, dummyEntity.ticksExisted * 2);
|
||||
|
||||
PageText.renderText(text_x, text_y, gui.getWidth() - 30, gui.getHeight(), getUnlocalizedName());
|
||||
|
||||
}
|
||||
|
||||
public int getEntityScale(int targetSize)
|
||||
{
|
||||
public int getEntityScale(int targetSize) {
|
||||
float entity_size = dummyEntity.width;
|
||||
|
||||
if(dummyEntity.width < dummyEntity.height)
|
||||
{
|
||||
entity_size = dummyEntity.height;
|
||||
}
|
||||
|
||||
|
||||
return MathHelper.floor_float(size / entity_size);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void tickEntity(Entity entity)
|
||||
{
|
||||
|
||||
public void tickEntity(Entity entity) {
|
||||
dummyEntity.ticksExisted++;
|
||||
}
|
||||
|
||||
public void renderEntity(IGuiLexiconEntry gui, Entity entity, int x, int y, int scale, float rotation)
|
||||
{
|
||||
dummyEntity.worldObj = (Minecraft.getMinecraft() != null) ? Minecraft.getMinecraft().theWorld : null;
|
||||
|
||||
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)x, (float)y, 50.0F);
|
||||
GL11.glScalef((float)(-scale), (float)scale, (float)scale);
|
||||
GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glTranslatef(0.0F, entity.yOffset, 0.0F);
|
||||
RenderManager.instance.playerViewY = 180.0F;
|
||||
RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
public void renderEntity(IGuiLexiconEntry gui, Entity entity, int x, int y, int scale, float rotation) {
|
||||
dummyEntity.worldObj = (Minecraft.getMinecraft() != null) ? Minecraft.getMinecraft().theWorld : null;
|
||||
|
||||
if(relativeMouseX >= x - (dummyEntity.width * scale / 2) - 10 && relativeMouseY >= y - (dummyEntity.height * scale) - 20 && relativeMouseX <= x + (dummyEntity.width * scale / 2) + 10 && relativeMouseY <= y + 20) {
|
||||
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)x, (float)y, 50.0F);
|
||||
GL11.glScalef((float)(-scale), (float)scale, (float)scale);
|
||||
GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glTranslatef(0.0F, entity.yOffset, 0.0F);
|
||||
RenderManager.instance.playerViewY = 180.0F;
|
||||
RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
|
||||
if(relativeMouseX >= x - (dummyEntity.width * scale / 2) - 10 && relativeMouseY >= y - (dummyEntity.height * scale) - 20 && relativeMouseX <= x + (dummyEntity.width * scale / 2) + 10 && relativeMouseY <= y + 20)
|
||||
tooltipEntity = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,6 @@ package vazkii.botania.common.shedding;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lexicon.page.PageShedding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
@@ -23,6 +19,8 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lexicon.page.PageShedding;
|
||||
|
||||
public class SheddingTracker {
|
||||
|
||||
@@ -40,22 +38,18 @@ public class SheddingTracker {
|
||||
this.rate = rate;
|
||||
this.lexiconSize=lexiconSize;
|
||||
}
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack.copy();
|
||||
}
|
||||
public int getRate()
|
||||
{
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
public String getEntityString()
|
||||
{
|
||||
public String getEntityString() {
|
||||
return (String)EntityList.classToStringMapping.get(EntityClass);
|
||||
}
|
||||
}
|
||||
|
||||
public static ShedPattern getShedPattern(Entity entity)
|
||||
{
|
||||
public static ShedPattern getShedPattern(Entity entity) {
|
||||
for(ShedPattern pattern : patterns)
|
||||
{
|
||||
if(pattern.EntityClass.isInstance(entity))
|
||||
@@ -64,13 +58,11 @@ public class SheddingTracker {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasShedding()
|
||||
{
|
||||
public static boolean hasShedding() {
|
||||
return patterns.size() > 0;
|
||||
}
|
||||
|
||||
public static void addToLexicon()
|
||||
{
|
||||
public static void addToLexicon() {
|
||||
if(!hasShedding())
|
||||
return;
|
||||
int i = 1;
|
||||
@@ -94,13 +86,11 @@ public class SheddingTracker {
|
||||
|
||||
ArrayList<String> defaultNames = new ArrayList<String>();
|
||||
|
||||
for(ShedPattern pattern : defaultPatterns)
|
||||
{
|
||||
for(ShedPattern pattern : defaultPatterns) {
|
||||
loadFromConfig(config, pattern.getEntityString(), pattern);
|
||||
defaultNames.add(pattern.getEntityString());
|
||||
}
|
||||
for(Object o : EntityList.stringToClassMapping.entrySet())
|
||||
{
|
||||
for(Object o : EntityList.stringToClassMapping.entrySet()) {
|
||||
Entry<String, Class> entry = (Entry<String, Class>)o;
|
||||
if(EntityLiving.class.isAssignableFrom(entry.getValue())) {
|
||||
String name = entry.getKey();
|
||||
@@ -109,8 +99,8 @@ public class SheddingTracker {
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void loadFromConfig(Configuration config, String key, ShedPattern defaultPattern)
|
||||
{
|
||||
|
||||
public static void loadFromConfig(Configuration config, String key, ShedPattern defaultPattern) {
|
||||
String itemName = "";
|
||||
int metadata = 0;
|
||||
int rate = -1;
|
||||
|
||||
Reference in new issue
Block a user