diff --git a/MODSRC/vazkii/botania/client/core/proxy/ClientProxy.java b/MODSRC/vazkii/botania/client/core/proxy/ClientProxy.java index 2734889e6..be6dfb628 100644 --- a/MODSRC/vazkii/botania/client/core/proxy/ClientProxy.java +++ b/MODSRC/vazkii/botania/client/core/proxy/ClientProxy.java @@ -33,6 +33,7 @@ import vazkii.botania.client.render.block.RenderPool; import vazkii.botania.client.render.block.RenderPylon; import vazkii.botania.client.render.block.RenderSpecialFlower; import vazkii.botania.client.render.block.RenderSpreader; +import vazkii.botania.client.render.entity.RenderPixie; import vazkii.botania.client.render.item.RenderLens; import vazkii.botania.client.render.item.RenderLexicon; import vazkii.botania.client.render.tile.RenderTileAlfPortal; @@ -53,6 +54,7 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.core.proxy.CommonProxy; import vazkii.botania.common.core.version.VersionChecker; +import vazkii.botania.common.entity.EntityPixie; import vazkii.botania.common.item.ModItems; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; @@ -101,7 +103,9 @@ public class ClientProxy extends CommonProxy { ClientRegistry.bindTileEntitySpecialRenderer(TilePylon.class, new RenderTilePylon()); ClientRegistry.bindTileEntitySpecialRenderer(TileEnchanter.class, new RenderTileEnchanter()); ClientRegistry.bindTileEntitySpecialRenderer(TileAlfPortal.class, new RenderTileAlfPortal()); - + + RenderingRegistry.registerEntityRenderingHandler(EntityPixie.class, new RenderPixie()); + ShaderHelper.initShaders(); } diff --git a/MODSRC/vazkii/botania/client/lib/LibResources.java b/MODSRC/vazkii/botania/client/lib/LibResources.java index 02d7c1725..6fb9f30bc 100644 --- a/MODSRC/vazkii/botania/client/lib/LibResources.java +++ b/MODSRC/vazkii/botania/client/lib/LibResources.java @@ -68,7 +68,8 @@ public final class LibResources { public static final String MODEL_TERRASTEEL_1 = PREFIX_MODEL + "terrasteel1.png"; public static final String MODEL_ELEMENTIUM_0 = PREFIX_MODEL + "elementium0.png"; public static final String MODEL_ELEMENTIUM_1 = PREFIX_MODEL + "elementium1.png"; - + public static final String MODEL_PIXIE = PREFIX_MODEL + "pixie.png"; + public static final String MODEL_CAPE = "/assets/botania/textures/model/cape.png"; public static final String MISC_PARTICLES = PREFIX_MISC + "particles.png"; diff --git a/MODSRC/vazkii/botania/client/model/ModelPixie.java b/MODSRC/vazkii/botania/client/model/ModelPixie.java new file mode 100644 index 000000000..7b46a7dad --- /dev/null +++ b/MODSRC/vazkii/botania/client/model/ModelPixie.java @@ -0,0 +1,72 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [? (GMT)] + */ +package vazkii.botania.client.model; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +public class ModelPixie extends ModelBase { + + ModelRenderer Body; + ModelRenderer LeftWing; + ModelRenderer RightWing; + + public ModelPixie() { + textureWidth = 64; + textureHeight = 32; + + Body = new ModelRenderer(this, 0, 0); + Body.addBox(0F, 0F, 0F, 4, 4, 4); + Body.setRotationPoint(-2F, 16F, -2F); + Body.setTextureSize(64, 32); + Body.mirror = true; + setRotation(Body, 0F, 0F, 0F); + LeftWing = new ModelRenderer(this, 32, 0); + LeftWing.addBox(0F, 0F, -1F, 0, 4, 7); + LeftWing.setRotationPoint(2F, 15F, 2F); + LeftWing.setTextureSize(64, 32); + LeftWing.mirror = true; + setRotation(LeftWing, 0F, 0F, 0F); + RightWing = new ModelRenderer(this, 50, 0); + RightWing.addBox(0F, 0F, -1F, 0, 4, 7); + RightWing.setRotationPoint(-2F, 15F, 2F); + RightWing.setTextureSize(64, 32); + RightWing.mirror = true; + setRotation(RightWing, 0F, 0F, 0F); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + Body.render(f5); + LeftWing.render(f5); + RightWing.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + @Override + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + + RightWing.rotateAngleY = -(MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.5F); + LeftWing.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.5F; + } + +} \ No newline at end of file diff --git a/MODSRC/vazkii/botania/client/render/entity/RenderPixie.java b/MODSRC/vazkii/botania/client/render/entity/RenderPixie.java new file mode 100644 index 000000000..94468d537 --- /dev/null +++ b/MODSRC/vazkii/botania/client/render/entity/RenderPixie.java @@ -0,0 +1,67 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [? (GMT)] + */ +package vazkii.botania.client.render.entity; + +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import vazkii.botania.client.lib.LibResources; +import vazkii.botania.client.model.ModelPixie; +import vazkii.botania.common.entity.EntityPixie; + +public class RenderPixie extends RenderLiving { + public RenderPixie() { + super(new ModelPixie(), 0.25F); + setRenderPassModel(new ModelPixie()); + shadowSize = 0.0F; + } + + @Override + protected ResourceLocation getEntityTexture(Entity entity) { + return new ResourceLocation(LibResources.MODEL_PIXIE); + } + + protected int setPixieBrightness(EntityPixie par1EntityPixie, int par2, float par3) { + if (par2 != 0) + return -1; + else { + bindTexture(getEntityTexture(par1EntityPixie)); + float f1 = 1.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + + if (par1EntityPixie.isInvisible()) + GL11.glDepthMask(false); + else + GL11.glDepthMask(true); + + char c0 = 61680; + int j = c0 % 65536; + int k = c0 / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); + return 1; + } + } + + @Override + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) { + return setPixieBrightness((EntityPixie)par1EntityLivingBase, par2, par3); + } +} \ No newline at end of file diff --git a/MODSRC/vazkii/botania/common/entity/EntityFlyingCreature.java b/MODSRC/vazkii/botania/common/entity/EntityFlyingCreature.java new file mode 100644 index 000000000..5ec8b6215 --- /dev/null +++ b/MODSRC/vazkii/botania/common/entity/EntityFlyingCreature.java @@ -0,0 +1,90 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [? (GMT)] + */ +package vazkii.botania.common.entity; + +import net.minecraft.block.Block; +import net.minecraft.entity.passive.EntityAmbientCreature; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityFlyingCreature extends EntityAmbientCreature { + + public EntityFlyingCreature(World par1World) { + super(par1World); + } + + @Override + protected void fall(float par1) { + // NO-OP + } + + @Override + protected void updateFallState(double par1, boolean par3) { + // NO-OP + } + + @Override + public void moveEntityWithHeading(float par1, float par2) { + if(isInWater()) { + moveFlying(par1, par2, 0.02F); + moveEntity(motionX, motionY, motionZ); + motionX *= 0.800000011920929D; + motionY *= 0.800000011920929D; + motionZ *= 0.800000011920929D; + } else if(handleLavaMovement()) { + moveFlying(par1, par2, 0.02F); + moveEntity(motionX, motionY, motionZ); + motionX *= 0.5D; + motionY *= 0.5D; + motionZ *= 0.5D; + } else { + float f2 = 0.91F; + + if (onGround) { + f2 = 0.54600006F; + Block block = worldObj.getBlock(MathHelper.floor_double(posX), MathHelper.floor_double(boundingBox.minY) - 1, MathHelper.floor_double(posZ)); + f2 = block.slipperiness * 0.91F; + } + + float f3 = 0.16277136F / (f2 * f2 * f2); + moveFlying(par1, par2, onGround ? 0.1F * f3 : 0.02F); + f2 = 0.91F; + + if (onGround) { + f2 = 0.54600006F; + Block block = worldObj.getBlock(MathHelper.floor_double(posX), MathHelper.floor_double(boundingBox.minY) - 1, MathHelper.floor_double(posZ)); + f2 = block.slipperiness * 0.91F; + } + + moveEntity(motionX, motionY, motionZ); + motionX *= f2; + motionY *= f2; + motionZ *= f2; + } + + prevLimbSwingAmount = limbSwingAmount; + double d0 = posX - prevPosX; + double d1 = posZ - prevPosZ; + float f4 = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F; + + if(f4 > 1.0F) + f4 = 1.0F; + + limbSwingAmount += (f4 - limbSwingAmount) * 0.4F; + limbSwing += limbSwingAmount; + } + + @Override + public boolean isOnLadder() { + return false; + } +} \ No newline at end of file diff --git a/MODSRC/vazkii/botania/common/entity/EntityPixie.java b/MODSRC/vazkii/botania/common/entity/EntityPixie.java new file mode 100644 index 000000000..ec8121d5e --- /dev/null +++ b/MODSRC/vazkii/botania/common/entity/EntityPixie.java @@ -0,0 +1,89 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [? (GMT)] + */ +package vazkii.botania.common.entity; + +import vazkii.botania.common.Botania; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.World; + +public class EntityPixie extends EntityFlyingCreature { + + public int courseChangeCooldown; + public double waypointX; + public double waypointY; + public double waypointZ; + + public EntityPixie(World world) { + super(world); + setSize(1.0F, 1.0F); + } + + @Override + protected void updateEntityActionState() { + double d0 = waypointX - posX; + double d1 = waypointY - posY; + double d2 = waypointZ - posZ; + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + + if(d3 < 1.0D || d3 > 3600.0D) { + waypointX = posX + (double)((rand.nextFloat() * 4.0F - 2.0F) * 2.0F); + waypointY = posY + (double)((rand.nextFloat() * 4.0F - 2.0F) * 2.0F); + waypointZ = posZ + (double)((rand.nextFloat() * 4.0F - 2.0F) * 2.0F); + } + + if(courseChangeCooldown-- <= 0) { + courseChangeCooldown += rand.nextInt(2) + 2; + d3 = (double)MathHelper.sqrt_double(d3); + + if(isCourseTraversable(waypointX, waypointY, waypointZ, d3)) { + motionX += d0 / d3 * 0.1D; + motionY += d1 / d3 * 0.1D; + motionZ += d2 / d3 * 0.1D; + } else { + waypointX = posX; + waypointY = posY; + waypointZ = posZ; + } + } + + renderYawOffset = rotationYaw = -((float)Math.atan2(motionX, motionZ)) * 180.0F / (float)Math.PI; + } + + private boolean isCourseTraversable(double par1, double par3, double par5, double par7) { + double d4 = (waypointX - posX) / par7; + double d5 = (waypointY - posY) / par7; + double d6 = (waypointZ - posZ) / par7; + AxisAlignedBB axisalignedbb = boundingBox.copy(); + + for (int i = 1; (double)i < par7; ++i) { + axisalignedbb.offset(d4, d5, d6); + + if (!worldObj.getCollidingBoundingBoxes(this, axisalignedbb).isEmpty()) + return false; + } + + return true; + } + + @Override + public void onEntityUpdate() { + super.onEntityUpdate(); + + if(worldObj.isRemote) + for(int i = 0; i < 4; i++) + Botania.proxy.sparkleFX(worldObj, posX + (Math.random() - 0.5) * 0.25, posY + 0.5 + (Math.random() - 0.5) * 0.25, posZ + (Math.random() - 0.5) * 0.25, 1F, 0.25F, 0.9F, 0.1F + (float) Math.random() * 0.25F, 12); + } + +} \ No newline at end of file diff --git a/MODSRC/vazkii/botania/common/entity/ModEntities.java b/MODSRC/vazkii/botania/common/entity/ModEntities.java index 17d6e0a54..64341d1dc 100644 --- a/MODSRC/vazkii/botania/common/entity/ModEntities.java +++ b/MODSRC/vazkii/botania/common/entity/ModEntities.java @@ -21,6 +21,7 @@ public final class ModEntities { int id = 0; EntityRegistry.registerModEntity(EntityManaBurst.class, LibEntityNames.MANA_BURST, id++, Botania.instance, 64, 10, true); EntityRegistry.registerModEntity(EntitySignalFlare.class, LibEntityNames.SIGNAL_FLARE, id++, Botania.instance, 2048, 10, false); + EntityRegistry.registerModEntity(EntityPixie.class, LibEntityNames.PIXIE, id++, Botania.instance, 80, 3, true); } } diff --git a/MODSRC/vazkii/botania/common/item/ItemFertilizer.java b/MODSRC/vazkii/botania/common/item/ItemFertilizer.java index 0b4b6008d..410a76491 100644 --- a/MODSRC/vazkii/botania/common/item/ItemFertilizer.java +++ b/MODSRC/vazkii/botania/common/item/ItemFertilizer.java @@ -20,6 +20,7 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; +import vazkii.botania.common.entity.EntityPixie; import vazkii.botania.common.lib.LibItemNames; public class ItemFertilizer extends ItemMod { diff --git a/MODSRC/vazkii/botania/common/lib/LibEntityNames.java b/MODSRC/vazkii/botania/common/lib/LibEntityNames.java index 5fc8167c9..b39a28b82 100644 --- a/MODSRC/vazkii/botania/common/lib/LibEntityNames.java +++ b/MODSRC/vazkii/botania/common/lib/LibEntityNames.java @@ -17,5 +17,6 @@ public final class LibEntityNames { public static final String MANA_BURST = LibResources.PREFIX_MOD + "manaBurst"; public static final String SIGNAL_FLARE = LibResources.PREFIX_MOD + "signalFlare"; + public static final String PIXIE = LibResources.PREFIX_MOD + "pixie"; } diff --git a/resources/assets/botania/textures/model/pixie.png b/resources/assets/botania/textures/model/pixie.png new file mode 100644 index 000000000..9ccd05c4f Binary files /dev/null and b/resources/assets/botania/textures/model/pixie.png differ