Working on chaos islands

This commit is contained in:
brandon3055 committed 2015-09-01 22:11:03 +10:00
1 parent 4e8c2f3673
commit b2f255d76c
27 files changed
+1529 -184

No files matched your search

@@ -8,6 +8,7 @@ import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.client.keybinding.KeyBindings;
import com.brandon3055.draconicevolution.client.keybinding.KeyInputHandler;
import com.brandon3055.draconicevolution.client.render.block.*;
import com.brandon3055.draconicevolution.client.render.entity.RenderChaosCrystal;
import com.brandon3055.draconicevolution.client.render.entity.RenderDragon;
import com.brandon3055.draconicevolution.client.render.entity.RenderDragonHeart;
import com.brandon3055.draconicevolution.client.render.entity.RenderDragonProjectile;
@@ -22,10 +23,7 @@ import com.brandon3055.draconicevolution.common.CommonProxy;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.ModItems;
import com.brandon3055.draconicevolution.common.blocks.multiblock.IIsSlave;
import com.brandon3055.draconicevolution.common.entity.EntityChaosGuardian;
import com.brandon3055.draconicevolution.common.entity.EntityCustomDragon;
import com.brandon3055.draconicevolution.common.entity.EntityDragonHeart;
import com.brandon3055.draconicevolution.common.entity.EntityDragonProjectile;
import com.brandon3055.draconicevolution.common.entity.*;
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.tileentities.*;
@@ -190,6 +188,7 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityChaosGuardian.class, new RenderDragon());
RenderingRegistry.registerEntityRenderingHandler(EntityDragonHeart.class, new RenderDragonHeart());
RenderingRegistry.registerEntityRenderingHandler(EntityDragonProjectile.class, new RenderDragonProjectile());
RenderingRegistry.registerEntityRenderingHandler(EntityChaosCrystal.class, new RenderChaosCrystal());
}
public void registerRenderIDs (){
@@ -267,6 +267,12 @@ public class ResourceHandler {
return cachedResources.get(rs);
}
public static ResourceLocation getResourceWOP(String rs)
{
if (!cachedResources.containsKey(rs)) cachedResources.put(rs, new ResourceLocation(rs));
return cachedResources.get(rs);
}
public static void bindResource(String rs)
{
bindTexture(ResourceHandler.getResource(rs));
@@ -0,0 +1,127 @@
package com.brandon3055.draconicevolution.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
/**
* ModelChaosCrystal - Mojang-(Original) modified by brandon3055
* Created using Tabula 5.0.0
*/
public class ModelChaosCrystal extends ModelBase {
public ModelRenderer base;
public ModelRenderer glass;
public ModelRenderer cube;
public ModelRenderer ringBase1;
public ModelRenderer RingSegment1;
public ModelRenderer RingSegment2;
public ModelRenderer RingSegment3;
public ModelRenderer RingSegment4;
public ModelRenderer ringBase2;
public ModelRenderer RingSegment1_1;
public ModelRenderer RingSegment2_1;
public ModelRenderer RingSegment3_1;
public ModelRenderer RingSegment4_1;
public ModelChaosCrystal(boolean hasBase) {
this.textureWidth = 64;
this.textureHeight = 64;
this.RingSegment3_1 = new ModelRenderer(this, 12, 38);
this.RingSegment3_1.setRotationPoint(0.0F, 0.0F, -10.0F);
this.RingSegment3_1.addBox(-1.0F, -1.0F, -2.0F, 2, 2, 4, 0.0F);
this.setRotateAngle(RingSegment3_1, 0.0F, 1.5707963267948966F, 0.0F);
this.RingSegment3 = new ModelRenderer(this, 12, 32);
this.RingSegment3.setRotationPoint(0.0F, 0.0F, -10.0F);
this.RingSegment3.addBox(-1.0F, -1.0F, -2.0F, 2, 2, 4, 0.0F);
this.setRotateAngle(RingSegment3, 0.0F, 1.5707963267948966F, 0.0F);
this.cube = new ModelRenderer(this, 32, 0);
this.cube.setRotationPoint(0.0F, 0.0F, 0.0F);
this.cube.addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8, 0.0F);
this.RingSegment2_1 = new ModelRenderer(this, 24, 38);
this.RingSegment2_1.setRotationPoint(-10.0F, 0.0F, 0.0F);
this.RingSegment2_1.addBox(-1.0F, -1.0F, -2.0F, 2, 2, 4, 0.0F);
this.ringBase2 = new ModelRenderer(this, 0, 0);
this.ringBase2.setRotationPoint(0.0F, 0.0F, 0.0F);
this.ringBase2.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1, 0.0F);
this.setRotateAngle(ringBase2, 0.0F, 0.7853981633974483F, 0.0F);
this.base = new ModelRenderer(this, 0, 16);
this.base.setRotationPoint(0.0F, 0.0F, 0.0F);
this.base.addBox(-6.0F, 0.0F, -6.0F, 12, 4, 12, 0.0F);
this.ringBase1 = new ModelRenderer(this, 0, 0);
this.ringBase1.setRotationPoint(0.0F, 0.0F, 0.0F);
this.ringBase1.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1, 0.0F);
this.RingSegment1 = new ModelRenderer(this, 0, 32);
this.RingSegment1.setRotationPoint(10.0F, 0.0F, 0.0F);
this.RingSegment1.addBox(-1.0F, -1.0F, -2.0F, 2, 2, 4, 0.0F);
this.glass = new ModelRenderer(this, 0, 0);
this.glass.setRotationPoint(0.0F, 0.0F, 0.0F);
this.glass.addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8, 0.0F);
this.RingSegment4_1 = new ModelRenderer(this, 36, 38);
this.RingSegment4_1.setRotationPoint(0.0F, 0.0F, 10.0F);
this.RingSegment4_1.addBox(-1.0F, -1.0F, -2.0F, 2, 2, 4, 0.0F);
this.setRotateAngle(RingSegment4_1, 0.0F, 1.5707963267948966F, 0.0F);
this.RingSegment4 = new ModelRenderer(this, 36, 32);
this.RingSegment4.setRotationPoint(0.0F, 0.0F, 10.0F);
this.RingSegment4.addBox(-1.0F, -1.0F, -2.0F, 2, 2, 4, 0.0F);
this.setRotateAngle(RingSegment4, 0.0F, 1.5707963267948966F, 0.0F);
this.RingSegment2 = new ModelRenderer(this, 24, 32);
this.RingSegment2.setRotationPoint(-10.0F, 0.0F, 0.0F);
this.RingSegment2.addBox(-1.0F, -1.0F, -2.0F, 2, 2, 4, 0.0F);
this.RingSegment1_1 = new ModelRenderer(this, 0, 38);
this.RingSegment1_1.setRotationPoint(10.0F, 0.0F, 0.0F);
this.RingSegment1_1.addBox(-1.0F, -1.0F, -2.0F, 2, 2, 4, 0.0F);
this.ringBase2.addChild(this.RingSegment3_1);
this.ringBase1.addChild(this.RingSegment3);
this.ringBase2.addChild(this.RingSegment2_1);
this.ringBase1.addChild(this.ringBase2);
this.ringBase1.addChild(this.RingSegment1);
this.ringBase2.addChild(this.RingSegment4_1);
this.ringBase1.addChild(this.RingSegment4);
this.ringBase1.addChild(this.RingSegment2);
this.ringBase2.addChild(this.RingSegment1_1);
}
public void render(Entity entity, float f1, float f2, float f3, float deathAnimation, float health, float scale) {
GL11.glPushMatrix();
GL11.glScalef(2.0F, 2.0F, 2.0F);
GL11.glTranslatef(0.0F, -0.5F, 0.0F);
if (this.base != null)
{
this.base.render(scale);
}
GL11.glPushMatrix();
float s = 1.1F + (float) Math.sin(f2 / 20) * 0.1F;
GL11.glTranslatef(0.0F, 0.1F + deathAnimation * 0.9F, 0.0F);
GL11.glRotatef(f2 * 2, 0.0F, 1.0F, 0.1F);
GL11.glScalef(s, s, s);
this.ringBase1.render(scale);
GL11.glPopMatrix();
GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(0.0F, 0.7F + deathAnimation * (0.1F + f3), 0.0F);
GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F);
this.glass.render(scale);
float f6 = 0.875F;
GL11.glScalef(f6, f6, f6);
GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F);
GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F);
this.glass.render(scale);
GL11.glScalef(f6, f6, f6);
GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F);
GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F);
this.cube.render(scale);
GL11.glPopMatrix();
}
/**
* This is a helper function from Tabula to set the rotation of model parts
*/
public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
@@ -0,0 +1,109 @@
package com.brandon3055.draconicevolution.client.render.entity;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.client.model.ModelChaosCrystal;
import com.brandon3055.draconicevolution.common.entity.EntityChaosCrystal;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityEnderCrystal;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
/**
* Created by brandon3055 on 30/8/2015.
*/
public class RenderChaosCrystal extends Render {
private ModelBase model;
public RenderChaosCrystal() {
this.shadowSize = 0.5F;
this.model = new ModelChaosCrystal(true);
}
public void doRender(EntityChaosCrystal crystal, double x, double y, double z, float f, float partialTick) {
float rotation = (float)crystal.innerRotation + (crystal.getHealth() > 0 ? partialTick : 0);
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
ResourceHandler.bindResource("textures/entity/chaosCrystal.png");
float r2 = MathHelper.sin(rotation * 0.2F) / 2.0F + 0.5F;
r2 += r2 * r2;
this.model.render(crystal, 0.0F, rotation * 3.0F, r2 * 0.2F, crystal.deathAnimation, crystal.getHealth(), 0.0625F);
GL11.glPopMatrix();
if (crystal.shieldTime > 0)
{
GL11.glPushMatrix();
GL11.glTranslated(-0.5, -1.5, -0.5);
Tessellator tessellator = Tessellator.instance;
ResourceHandler.bindTexture(ResourceHandler.getResourceWOP("textures/entity/beacon_beam.png"));
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
OpenGlHelper.glBlendFunc(770, 1, 1, 0);
float f2 = (float) crystal.ticksExisted + partialTick;
float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glDepthMask(false);
tessellator.startDrawingQuads();
tessellator.setColorRGBA(200, 0, 0, 32);
double size = 0.39F;
double d30 = 0.2D - size;
double d4 = 0.2D - size;
double d6 = 0.8D + size;
double d8 = 0.2D - size;
double d10 = 0.2D - size;
double d12 = 0.8D + size;
double d14 = 0.8D + size;
double d16 = 0.8D + size;
double d18 = (double) (256.0F);
double d20 = 0.0D;
double d22 = 1.0D;
double d24 = (double) (-1.0F + f3);
double d26 = (double) (256.0F) + d24;
tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26);
tessellator.addVertexWithUV(x + d30, y, z + d4, d22, d24);
tessellator.addVertexWithUV(x + d6, y, z + d8, d20, d24);
tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26);
tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26);
tessellator.addVertexWithUV(x + d14, y, z + d16, d22, d24);
tessellator.addVertexWithUV(x + d10, y, z + d12, d20, d24);
tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26);
tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26);
tessellator.addVertexWithUV(x + d6, y, z + d8, d22, d24);
tessellator.addVertexWithUV(x + d14, y, z + d16, d20, d24);
tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26);
tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26);
tessellator.addVertexWithUV(x + d10, y, z + d12, d22, d24);
tessellator.addVertexWithUV(x + d30, y, z + d4, d20, d24);
tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26);
tessellator.draw();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(true);
GL11.glPopMatrix();
}
}
protected ResourceLocation getEntityTexture(EntityEnderCrystal p_110775_1_)
{
return ResourceHandler.getResource("textures/entity/chaosCrystal.png");
}
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
return this.getEntityTexture((EntityChaosCrystal)p_110775_1_);
}
public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) {
this.doRender((EntityChaosCrystal)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
}
}
@@ -103,19 +103,19 @@ public class RenderDragon extends RenderLiving
* (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
*/
public void doRender(EntityDragon p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
public void doRender(EntityDragon dragon, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
{
BossStatus.setBossStatus(p_76986_1_, false);
super.doRender((EntityLiving)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
BossStatus.setBossStatus(dragon, false);
super.doRender((EntityLiving)dragon, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
if (p_76986_1_.healingEnderCrystal != null)
if (dragon.healingEnderCrystal != null)
{
float f2 = (float)p_76986_1_.healingEnderCrystal.innerRotation + p_76986_9_;
float f2 = (float)dragon.healingEnderCrystal.innerRotation + p_76986_9_;
float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F;
f3 = (f3 * f3 + f3) * 0.2F;
float f4 = (float)(p_76986_1_.healingEnderCrystal.posX - p_76986_1_.posX - (p_76986_1_.prevPosX - p_76986_1_.posX) * (double)(1.0F - p_76986_9_));
float f5 = (float)((double)f3 + p_76986_1_.healingEnderCrystal.posY - 1.0D - p_76986_1_.posY - (p_76986_1_.prevPosY - p_76986_1_.posY) * (double)(1.0F - p_76986_9_));
float f6 = (float)(p_76986_1_.healingEnderCrystal.posZ - p_76986_1_.posZ - (p_76986_1_.prevPosZ - p_76986_1_.posZ) * (double)(1.0F - p_76986_9_));
float f4 = (float)(dragon.healingEnderCrystal.posX - dragon.posX - (dragon.prevPosX - dragon.posX) * (double)(1.0F - p_76986_9_));
float f5 = (float)((double)f3 + dragon.healingEnderCrystal.posY - 1.0D - dragon.posY - (dragon.prevPosY - dragon.posY) * (double)(1.0F - p_76986_9_));
float f6 = (float)(dragon.healingEnderCrystal.posZ - dragon.posZ - (dragon.prevPosZ - dragon.posZ) * (double)(1.0F - p_76986_9_));
float f7 = MathHelper.sqrt_float(f4 * f4 + f6 * f6);
float f8 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6);
GL11.glPushMatrix();
@@ -127,8 +127,8 @@ public class RenderDragon extends RenderLiving
GL11.glDisable(GL11.GL_CULL_FACE);
this.bindTexture(enderDragonCrystalBeamTextures);
GL11.glShadeModel(GL11.GL_SMOOTH);
float f9 = 0.0F - ((float)p_76986_1_.ticksExisted + p_76986_9_) * 0.01F;
float f10 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6) / 32.0F - ((float)p_76986_1_.ticksExisted + p_76986_9_) * 0.01F;
float f9 = 0.0F - ((float)dragon.ticksExisted + p_76986_9_) * 0.01F;
float f10 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6) / 32.0F - ((float)dragon.ticksExisted + p_76986_9_) * 0.01F;
tessellator.startDrawing(5);
byte b0 = 8;
@@ -143,6 +143,46 @@ public class RenderDragon extends RenderLiving
tessellator.addVertexWithUV((double)f11, (double)f12, (double)f8, (double)f13, (double)f9);
}
tessellator.draw();
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_FLAT);
RenderHelper.enableStandardItemLighting();
GL11.glPopMatrix();
} else if (dragon instanceof EntityChaosGuardian && ((EntityChaosGuardian) dragon).healingChaosCrystal != null){
float f2 = (float)((EntityChaosGuardian) dragon).healingChaosCrystal.innerRotation + p_76986_9_;
float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F;
f3 = (f3 * f3 + f3) * 0.2F;
float f4 = (float)(((EntityChaosGuardian) dragon).healingChaosCrystal.posX - dragon.posX - (dragon.prevPosX - dragon.posX) * (double)(1.0F - p_76986_9_));
float f5 = (float)((double)f3 + ((EntityChaosGuardian) dragon).healingChaosCrystal.posY - 1.0D - dragon.posY - (dragon.prevPosY - dragon.posY) * (double)(1.0F - p_76986_9_));
float f6 = (float)(((EntityChaosGuardian) dragon).healingChaosCrystal.posZ - dragon.posZ - (dragon.prevPosZ - dragon.posZ) * (double)(1.0F - p_76986_9_));
float f7 = MathHelper.sqrt_float(f4 * f4 + f6 * f6);
float f8 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6);
GL11.glPushMatrix();
GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_ + 2.0F, (float)p_76986_6_);
GL11.glRotatef((float)(-Math.atan2((double)f6, (double)f4)) * 180.0F / (float)Math.PI - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef((float)(-Math.atan2((double)f7, (double)f5)) * 180.0F / (float)Math.PI - 90.0F, 1.0F, 0.0F, 0.0F);
Tessellator tessellator = Tessellator.instance;
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_CULL_FACE);
this.bindTexture(enderDragonCrystalBeamTextures);
GL11.glShadeModel(GL11.GL_SMOOTH);
float f9 = 0.0F - ((float)dragon.ticksExisted + p_76986_9_) * 0.01F;
float f10 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6) / 32.0F - ((float)dragon.ticksExisted + p_76986_9_) * 0.01F;
tessellator.startDrawing(5);
byte b0 = 8;
for (int i = 0; i <= b0; ++i)
{
float f11 = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.0F / (float)b0) * 0.75F;
float f12 = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.0F / (float)b0) * 0.75F;
float f13 = (float)(i % b0) * 1.0F / (float)b0;
tessellator.setColorOpaque_I(0);
tessellator.addVertexWithUV((double)(f11 * 0.2F), (double)(f12 * 0.2F), 0.0D, (double)f13, (double)f10);
tessellator.setColorOpaque_I(0xFF0000);
tessellator.addVertexWithUV((double)f11, (double)f12, (double)f8, (double)f13, (double)f9);
}
tessellator.draw();
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_FLAT);
@@ -1,6 +1,7 @@
package com.brandon3055.draconicevolution.client.render.entity;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.common.entity.EntityDragonProjectile;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
@@ -14,21 +15,48 @@ import org.lwjgl.opengl.GL12;
public class RenderDragonProjectile extends Render {
@Override
public void doRender(Entity entity, double x, double y, double z, float f, float f1) {
public void doRender(Entity entity, double x, double y, double z, float f, float partialTick) {
doRender((EntityDragonProjectile) entity, x, y, z, f, partialTick);
}
private void doRender(EntityDragonProjectile entity, double x, double y, double z, float f, float partialTick){
GL11.glPushMatrix();
ResourceHandler.bindResource("textures/entity/projectileEnergy.png");
GL11.glTranslatef((float)x, (float)y, (float)z);
float height = (entity.ticksExisted) % 8 * 1F / 8F;
switch (entity.type){
case EntityDragonProjectile.FIREBOMB:
case EntityDragonProjectile.FIRE_CHASER:
ResourceHandler.bindResource("textures/entity/projectileFire.png");
height = 0;
break;
case EntityDragonProjectile.TELEPORT:
height = 0;
ResourceHandler.bindTexture(ResourceHandler.getResourceWOP("textures/items/ender_pearl.png"));
break;
case EntityDragonProjectile.ENERGY_CHASER:
ResourceHandler.bindResource("textures/entity/projectileEnergy.png");
break;
case EntityDragonProjectile.CHAOS_CHASER:
case EntityDragonProjectile.MINI_CHAOS_CHASER:
ResourceHandler.bindResource("textures/entity/projectileChaos.png");
break;
case EntityDragonProjectile.IGNITION_CHARGE:
ResourceHandler.bindResource("textures/entity/projectileIgnition.png");
break;
default: ResourceHandler.bindResource("textures/entity/projectileFire.png");
}
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glAlphaFunc(GL11.GL_GREATER, 0F);
float f2 = 2; //Size?
GL11.glDisable(GL11.GL_LIGHTING);
// GL11.glDepthMask(false);
// GL11.glEnable(GL11.GL_CULL_FACE);
float f2 = entity.type == EntityDragonProjectile.MINI_CHAOS_CHASER ? entity.power / 10 : entity.power / 5;
GL11.glScalef(f2 / 1.0F, f2 / 1.0F, f2 / 1.0F);
Tessellator tessellator = Tessellator.instance;
float height = (entity.ticksExisted/2) % 8 * 1F / 8F;
float f3 = 0;
float f4 = 1;
float f5 = height;
@@ -36,18 +64,33 @@ public class RenderDragonProjectile extends Render {
float f7 = 1.0F;
float f8 = 0.5F;
float f9 = 0.25F;
GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
if (entity.type == EntityDragonProjectile.FIREBOMB || entity.type == EntityDragonProjectile.FIRE_CHASER){
GL11.glTranslated(0, 0.25, 0);
GL11.glRotatef((entity.ticksExisted * 40 + partialTick * 40), 0, 0, 1);
GL11.glTranslated(0, -0.25, 0);
}
else if (entity.type == EntityDragonProjectile.TELEPORT){
f5 = 0;
f6 = 1;
}
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.setBrightness(200);
tessellator.addVertexWithUV((double)(0.0F - f8), (double)(0.0F - f9), 0.0D, (double)f3, (double)f6);
tessellator.addVertexWithUV((double)(f7 - f8), (double)(0.0F - f9), 0.0D, (double)f4, (double)f6);
tessellator.addVertexWithUV((double)(f7 - f8), (double)(1.0F - f9), 0.0D, (double)f4, (double)f5);
tessellator.addVertexWithUV((double)(0.0F - f8), (double)(1.0F - f9), 0.0D, (double)f3, (double)f5);
tessellator.draw();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
//GL11.glDepthMask(true);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
@@ -57,4 +100,5 @@ public class RenderDragonProjectile extends Render {
protected ResourceLocation getEntityTexture(Entity entity) {
return null;
}
}
@@ -2,6 +2,7 @@ package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.brandonscore.common.utills.Utills;
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
import com.brandon3055.draconicevolution.common.entity.EntityDragonProjectile;
import com.brandon3055.draconicevolution.common.lib.References;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -776,6 +777,92 @@ public class Particles {
tessellator.startDrawingQuads();
}
}
public static class DragonProjectileParticle extends EntityFX
{
private EntityDragonProjectile entity;
private int particleColour;
public DragonProjectileParticle(World world, double x, double y, double z, int colour) {
super(world, x, y, z);
this.particleMaxAge = 50;
this.noClip = true;
this.particleColour = colour;
this.particleRed = this.particleGreen = this.particleBlue = 1.0f;
}
public DragonProjectileParticle(World world, double x, double y, double z, EntityDragonProjectile projectile) {
super(world, x, y, z);
this.particleMaxAge = 50;
this.noClip = true;
this.entity = projectile;
this.particleColour = projectile.getParticleColour();
this.particleRed = this.particleGreen = this.particleBlue = 1.0f;
}
@Override
public void onUpdate() {
//super.onUpdate();
if (particleAge >= particleMaxAge) setDead();
//
// double d1 = Utills.getDistanceAtoB(startX, startY, startZ, targetX, targetY, targetZ);
// double d2 = Utills.getDistanceAtoB(posX, posY, posZ, targetX, targetY, targetZ);
//particleScale = ((float) (d2 / d1)) * baseScale;
particleAlpha = (1F - (float)((double)particleAge / particleMaxAge));
particleScale = 1F * (1F - (float)((double)particleAge / particleMaxAge));
particleAge ++;
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
moveEntity(motionX, motionY, motionZ);
}
@Override
@SideOnly(Side.CLIENT)
public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y
tesselator.draw();
ResourceHandler.bindParticles();
tesselator.startDrawingQuads();
tesselator.setBrightness(200);
//GL11.glDepthMask(true);
int uIndex = 7;
int vIndex = 0;
float minU = uIndex * 0.125F;
float maxU = (uIndex+1) * 0.125F;
float minV = vIndex * 0.125F;
float maxV = (vIndex+1) * 0.125F;
float drawScale = 0.1F * this.particleScale;
if (this.particleIcon != null) {
minU = this.particleIcon.getMinU();
maxU = this.particleIcon.getMaxU();
minV = this.particleIcon.getMinV();
maxV = this.particleIcon.getMaxV();
}
float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX);
float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY);
float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ);
//tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha);
tesselator.setColorRGBA_I(particleColour, 0xFF);
tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV);
tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV);
tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV);
tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV);
tesselator.draw();
ResourceHandler.bindDefaultParticles();
tesselator.startDrawingQuads();
}
}
}
//int uIndex = 0;
//int vIndex = 0;
@@ -126,6 +126,7 @@ public class CommonProxy {
DraconicEvolution.network.registerMessage(SpeedRequestPacket.Handler.class, SpeedRequestPacket.class, 12, Side.SERVER);
DraconicEvolution.network.registerMessage(SpeedRequestPacket.Handler.class, SpeedRequestPacket.class, 13, Side.CLIENT);
DraconicEvolution.network.registerMessage(ToolModePacket.Handler.class, ToolModePacket.class, 14, Side.SERVER);
DraconicEvolution.network.registerMessage(GenericParticlePacket.Handler.class, GenericParticlePacket.class, 15, Side.CLIENT);
}
public void registerTileEntities() {
@@ -180,14 +181,15 @@ public class CommonProxy {
}
public void registerEntities() {
EntityRegistry.registerModEntity(EntityCustomDragon.class, "EnderDragon", 0, DraconicEvolution.instance, 500, 3, true);
EntityRegistry.registerModEntity(EntityCustomDragon.class, "EnderDragon", 0, DraconicEvolution.instance, 256, 3, true);
EntityRegistry.registerModEntity(EntityPersistentItem.class, "Persistent Item", 1, DraconicEvolution.instance, 32, 5, true);
EntityRegistry.registerModEntity(EntityDraconicArrow.class, "Arrow", 2, DraconicEvolution.instance, 32, 5, true);
EntityRegistry.registerModEntity(EntityEnderArrow.class, "Ender Arrow", 3, DraconicEvolution.instance, 32, 5, true);
EntityRegistry.registerModEntity(EntityChaosDrill.class, "Chaos Drill", 4, DraconicEvolution.instance, 10, 5, false);
EntityRegistry.registerModEntity(EntityEnderArrow.class, "Ender Arrow", 3, DraconicEvolution.instance, 32, 1, true);
//EntityRegistry.registerModEntity(EntityChaosDrill.class, "Chaos Drill", 4, DraconicEvolution.instance, 10, 5, false);
EntityRegistry.registerModEntity(EntityDragonHeart.class, "Dragon Heart Item", 5, DraconicEvolution.instance, 32, 5, true);
EntityRegistry.registerModEntity(EntityChaosGuardian.class, "ChaosGuardian", 6, DraconicEvolution.instance, 500, 3, true);
EntityRegistry.registerModEntity(EntityDragonProjectile.class, "DragonProjectile", 7, DraconicEvolution.instance, 32, 5, true);
EntityRegistry.registerModEntity(EntityChaosGuardian.class, "ChaosGuardian", 6, DraconicEvolution.instance, 256, 1, true);
EntityRegistry.registerModEntity(EntityDragonProjectile.class, "DragonProjectile", 7, DraconicEvolution.instance, 256, 1, true);
EntityRegistry.registerModEntity(EntityChaosCrystal.class, "ChaosCrystal", 8, DraconicEvolution.instance, 256, 5, false);
}
public ParticleEnergyBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz, int powerFlow, boolean advanced, ParticleEnergyBeam oldBeam, boolean render, int beamType)
@@ -0,0 +1,162 @@
package com.brandon3055.draconicevolution.common.entity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderEnd;
import java.util.List;
/**
* Created by brandon3055 on 30/8/2015.
*/
public class EntityChaosCrystal extends EntityLivingBase {
public int innerRotation;
public float deathAnimation = 1F;
public int shieldTime = 0;
public EntityChaosGuardian guardian;
public EntityChaosCrystal(World p_i1698_1_) {
super(p_i1698_1_);
this.preventEntitySpawning = true;
this.setSize(2.0F, 2.0F);
//this.yOffset = -2;
this.innerRotation = this.rand.nextInt(100000);
this.setHealth(getMaxHealth());
this.ignoreFrustumCheck = true;
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(50F);
}
@Override
public boolean canTriggerWalking() {
return false;
}
@Override
public void entityInit() {
super.entityInit();
dataWatcher.addObject(20, (short)shieldTime);
}
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (!worldObj.isRemote)dataWatcher.updateObject(20, (short)shieldTime);
else shieldTime = (int)dataWatcher.getWatchableObjectShort(20);
//setHealth(0);
if (getHealth() > 0){
if (shieldTime > 0) shieldTime--;
if (deathAnimation < 1F) deathAnimation += 0.1F;
++this.innerRotation;
int i = MathHelper.floor_double(this.posX);
int j = MathHelper.floor_double(this.posY);
int k = MathHelper.floor_double(this.posZ);
if (this.worldObj.provider instanceof WorldProviderEnd && this.worldObj.getBlock(i, j, k) != Blocks.fire)
{
this.worldObj.setBlock(i, j, k, Blocks.fire);
}
}else if (deathAnimation > 0) deathAnimation -= 0.1F;
}
@Override
public void writeEntityToNBT(NBTTagCompound compound) {
super.writeEntityToNBT(compound);
}
@Override
public void readEntityFromNBT(NBTTagCompound compound) {
super.readEntityFromNBT(compound);
}
@Override
@SideOnly(Side.CLIENT)
public float getShadowSize() {
return 0.0F;
}
@Override
public boolean canBeCollidedWith() {
return true;
}
@Override
public boolean attackEntityFrom(DamageSource source, float dmg) {
if (this.isEntityInvulnerable())
{
return false;
} else if (source.getEntity() instanceof EntityPlayer)
{
if (shieldTime <= 0 && getHealth() > 0 && !this.worldObj.isRemote)
{
setHealth(getHealth() - Math.min(getHealth(), dmg));
if (getHealth() <= 0) worldObj.createExplosion(null, this.posX, this.posY, this.posZ, 6.0F, false);
else shieldTime = 100 + rand.nextInt(100);
worldObj.playSoundEffect(posX + 0.5D, posY + 0.5D, posZ + 0.5D, "mob.blaze.hit", 10.0F, rand.nextFloat() * 0.1F + 1.055F);
if (getGuardian() != null) getGuardian().onCrystalTargeted((EntityPlayer)source.getEntity(), getHealth() <= 0);
return true;
}else if (shieldTime > 0) shieldTime = 100 + rand.nextInt(100);
}
return false;
}
private EntityChaosGuardian getGuardian(){
if (guardian == null) {
@SuppressWarnings("unchecked") List<EntityChaosGuardian> list = worldObj.getEntitiesWithinAABB(EntityChaosGuardian.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX, posY, posZ).expand(512, 512, 512));
if (list.size() > 0) guardian = list.get(0);
if (guardian != null && !guardian.crystals.contains(this)) {
guardian.crystals.add(this);
guardian.updateCrystals();
}
}
return guardian;
}
public void revive(){
setHealth(getMaxHealth());
shieldTime = 50;
worldObj.createExplosion(null, this.posX, this.posY, this.posZ, 6.0F, false);
if (getGuardian() != null) getGuardian().updateCrystals();
}
public boolean isAlive() { return getHealth() > 0F; }
@Override
public ItemStack getHeldItem() {
return null;
}
@Override
public ItemStack getEquipmentInSlot(int p_71124_1_) {
return null;
}
@Override
public void setCurrentItemOrArmor(int p_70062_1_, ItemStack p_70062_2_) {
}
@Override
public ItemStack[] getLastActiveItems() {
return new ItemStack[0];
}
}
@@ -2,24 +2,22 @@ package com.brandon3055.draconicevolution.common.entity;
import com.brandon3055.brandonscore.common.utills.Utills;
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import com.brandon3055.draconicevolution.common.utills.DamageSourceChaos;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.boss.EntityDragonPart;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.item.EntityEnderCrystal;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.util.*;
import net.minecraft.world.World;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;
/**
@@ -31,11 +29,35 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
/**The spawn coordinates of this dragon*/
public int homeX = 0;
public int homeY = 67;
public int homeY = -1;
public int homeZ = 0;
public boolean homeSet = false;
/**How long until the next attack sequence*/
private int nextAttackTimer = 100;
/**The current attack. -1 = not attacking*/
private int attackInProgress = -1;
/**How long until the current attack sequence ends*/
private int attackTimer = 0;
/**The behaviour before the attack started (used to reset to previous behaviour after charge attacks)*/
private EnumBehaviour previousBehaviour = EnumBehaviour.ROAMING;
/**How long until a new ignition charge can be fired*/
private int ignitionChargeTimer = 0;
/**A list of all Chaos Crystals in range*/
public List<EntityChaosCrystal> crystals = null;
/**Number of crystals that are still active*/
public int activeCrystals = 0;
public EntityChaosCrystal healingChaosCrystal;
public int connectedCrystalID = -1;
private static final int ATTACK_FIREBALL_CHARGE = 0;
private static final int ATTACK_FIREBALL_CHASER = 1;
private static final int ATTACK_ENERGY_CHASER = 2;
private static final int ATTACK_CHAOS_CHASER = 3;
private static final int ATTACK_TELEPORT = 4;
public int timer1 = 0;
public int timer2 = 0;
public float circlePosition = 0;
public float circleDirection = 1;
@@ -45,16 +67,10 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
super(par1World);
}
// public EntityChaosGuardian(World world, double health, float attack){
// this(world);
// this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(health);
// this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(health);
// }//todo set base health
@Override
protected void entityInit() {
super.entityInit();
//this.dataWatcher.addObject(12, (isUber ? (byte)1 : (byte)0));
dataWatcher.addObject(20, connectedCrystalID);
}
@Override
@@ -65,31 +81,33 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(200D);
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(2000);
}
@Override
public void onLivingUpdate() {
//Set home position when spawned
if (ticksExisted == 1) {
if (!homeSet) {
homeX = (int) posX;
homeY = (int) posY;
homeZ = (int) posZ;
targetX = homeX;
targetZ = homeZ;
homeSet = true;
}
if (crystals == null) updateCrystals();
float f;
float f1;
float moveSpeedMultiplier = behaviour.dragonSpeed;//getCurrentMovementSpeed();
float moveSpeedMultiplier = behaviour.dragonSpeed;
if (this.worldObj.isRemote) {
connectedCrystalID = dataWatcher.getWatchableObjectInt(20);
if (ticksExisted % 10 == 0 && connectedCrystalID != -1 && worldObj.getEntityByID(connectedCrystalID) instanceof EntityChaosCrystal) healingChaosCrystal = (EntityChaosCrystal)worldObj.getEntityByID(connectedCrystalID);
else if (connectedCrystalID == -1 && healingChaosCrystal != null) healingChaosCrystal = null;
f = MathHelper.cos(this.animTime * (float) Math.PI * 2.0F);
f1 = MathHelper.cos(this.prevAnimTime * (float) Math.PI * 2.0F);
@@ -102,8 +120,10 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
float f2;
if (!worldObj.isRemote) {
dataWatcher.updateObject(20, connectedCrystalID);
updateTarget();
customAIUpdate();
if (behaviour == EnumBehaviour.FIREBOMB && Utills.getDistanceAtoB(posX, posY, posZ, homeX, homeY + 30, homeZ) <= 3) moveSpeedMultiplier = 0;
}
if (this.getHealth() <= 0.0F) {
@@ -114,7 +134,7 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
} else {
this.updateDragonEnderCrystal();
f = 0.2F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F);
f *= moveSpeedMultiplier;
f *= moveSpeedMultiplier == 0 ? 1 : moveSpeedMultiplier;
f *= (float) Math.pow(2.0D, this.motionY);
if (this.slowed) {
@@ -168,7 +188,6 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
this.targetX = this.target.posX + (int)(Math.cos(circlePosition) * 60);
this.targetZ = this.target.posZ + (int)(Math.sin(circlePosition) * 60);
moveSpeedMultiplier = 1F + Math.min(((float) Utills.getDistanceAtoB(targetX, targetZ, posX, posZ) / 50) * 3F, 3F);
LogHelper.info((int)(Math.sin(circlePosition) * 60) + " " + (int)(Math.cos(circlePosition) * 60)+" "+moveSpeedMultiplier);
}else {
this.targetX = this.target.posX;
this.targetZ = this.target.posZ;
@@ -183,8 +202,8 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
d8 = 10.0D;
}
this.targetY = this.target.boundingBox.minY + d8 + (behaviour == EnumBehaviour.CIRCLE_PLAYER ? 20 : 0);
} else {
this.targetY = this.target.boundingBox.minY + d8 + (behaviour == EnumBehaviour.CIRCLE_PLAYER ? 25 : 0);
} else if (behaviour != EnumBehaviour.FIREBOMB){
this.targetX += this.rand.nextGaussian() * 2.0D;
this.targetZ += this.rand.nextGaussian() * 2.0D;
}
@@ -324,37 +343,256 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
}
public void onCrystalTargeted(EntityPlayer player, boolean destroyed) {
target = player;
if (destroyed || behaviour == EnumBehaviour.LOW_HEALTH_STRATEGY)
{
attackInProgress = ATTACK_CHAOS_CHASER;
behaviour = EnumBehaviour.CHARGING;
nextAttackTimer = 20;
attackTimer = 100;
updateCrystals();
}else
{
attackInProgress = ATTACK_FIREBALL_CHARGE;
previousBehaviour = behaviour;
behaviour = EnumBehaviour.CHARGING;
nextAttackTimer = 20;
attackTimer = 1000;
}
this.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "mob.enderdragon.growl", 20.0F, 0.8F + this.rand.nextFloat() * 0.3F);
}
public void updateCrystals(){
if (crystals == null) crystals = new ArrayList<EntityChaosCrystal>();
List<EntityChaosCrystal> list = worldObj.getEntitiesWithinAABB(EntityChaosCrystal.class, AxisAlignedBB.getBoundingBox(homeX, homeY, homeZ, homeX, homeY, homeZ).expand(200, 200, 200));
activeCrystals = 0;
for (EntityChaosCrystal crystal : list) {
if (!crystals.contains(crystal)) crystals.add(crystal);
if (crystal.isAlive()) activeCrystals++;
}
}
private void customAIUpdate(){
//LogHelper.info(homeX+" "+homeZ);
if (getHealth() < getMaxHealth() * 0.2F) behaviour = EnumBehaviour.LOW_HEALTH_STRATEGY;
switch (behaviour){
case ROAMING:
if (worldObj.getClosestPlayer(homeX, homeY, homeZ, 200) != null) behaviour = EnumBehaviour.CIRCLE_PLAYER;
if (worldObj.getClosestPlayer(homeX, homeY, homeZ, 200) != null) selectNewBehaviour();
break;
case GO_HOME:
if (Utills.getDistanceAtoB(posX, posZ, homeX, homeZ) < 70 ) behaviour = EnumBehaviour.ROAMING;
if (Utills.getDistanceAtoB(posX, posZ, homeX, homeZ) < 70 ) selectNewBehaviour();
break;
case GUARDING:
break;
case CHARGING:
if (Utills.getDistanceAtoB(posX, posZ, homeX, homeZ) > 300) behaviour = EnumBehaviour.GO_HOME;
break;
case CIRCLE_PLAYER:
circlePosition += (0.02F * circleDirection);
if (Utills.getDistanceAtoB(posX, posZ, homeX, homeZ) > 300) behaviour = EnumBehaviour.GO_HOME;
break;
case LOW_HEALTH_STRATEGY:
if (worldObj.getClosestPlayer(targetX, targetY, targetZ, 60) != null && attackInProgress != ATTACK_TELEPORT){
int escape = 0;
boolean flag = false;
while (!flag && escape < 50){
targetX = homeX + ((rand.nextDouble() - 0.5D) * 220D);
targetY = homeY + 20 + rand.nextDouble() * 20D;
targetZ = homeZ + ((rand.nextDouble() - 0.5D) * 220D);
if (worldObj.getClosestPlayer(targetX, targetY, targetZ, 60D) == null) flag = true;
escape++;
}
target = null;
}
break;
case AVOID_PLAYERS:
break;
case RETREAT:
break;
//todo Death event
case DEAD:
break;
}
//ignitionChargeTimer = 10;
if (ignitionChargeTimer > 1 || (ignitionChargeTimer == 1 && ticksExisted % 20 == 0))ignitionChargeTimer--;
if (ignitionChargeTimer <= 0 && !worldObj.isRemote){
if ((ticksExisted - 19) % 20 == 0) ignitionChargeTimer = (behaviour == EnumBehaviour.LOW_HEALTH_STRATEGY ? 1000 : 2000) + rand.nextInt(600);
if (activeCrystals < crystals.size() && ticksExisted % 10 == 0){
EntityChaosCrystal closest = null;
for (EntityChaosCrystal crystal : crystals) if (!crystal.isAlive() && (closest == null || getDistanceToEntity(crystal) < getDistanceToEntity(closest))) closest = crystal;
if (closest != null){
EntityDragonProjectile charge = new EntityDragonProjectile(worldObj, EntityDragonProjectile.IGNITION_CHARGE, closest, 0, this);
charge.setPosition(dragonPartHead.posX + Math.cos((rotationYaw - 90) / 180.0F * (float)Math.PI) * 2, dragonPartHead.posY + 1.5, dragonPartHead.posZ + Math.sin((rotationYaw - 90) / 180.0F * (float)Math.PI) * 2);
worldObj.spawnEntityInWorld(charge);
}
}
}
updateAttack();
}
private void updateAttack(){
if (worldObj.isRemote || getHealth() <= 0) return;
if (behaviour == EnumBehaviour.FIREBOMB && Utills.getDistanceAtoB(posX, posY, posZ, homeX, homeY + 30, homeZ) <= 3){
if (target == null || ticksExisted % 100 == 0) setNewTarget();
if (target != null){
double distance = Utills.getDistanceAtoB(target.posX, target.posZ, dragonPartHead.posX, dragonPartHead.posZ);
if (Utills.getDistanceAtoB(target.posX, target.posZ, posX, posZ) < 5) distance *= -1;
float anglePitch = (float)Math.toDegrees(Math.atan2(target.posY - dragonPartHead.posY, distance)) * -1F;
float angleYaw = (float)Math.toDegrees(Math.atan2(target.posX - dragonPartHead.posX, target.posZ - posZ)) * -1F;
rotationPitch = anglePitch;
if (Utills.getDistanceAtoB(target.posX, target.posZ, posX, posZ) > 8) rotationYaw = angleYaw + 180;
if (ticksExisted % 2 == 0)
{
EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.FIREBOMB, target instanceof EntityLivingBase ? (EntityLivingBase) target : null, 5F + (rand.nextFloat() * 8F), this);
projectile.setPosition(dragonPartHead.posX + Math.cos((rotationYaw - 90) / 180.0F * (float)Math.PI) * 2, dragonPartHead.posY + 1.5, dragonPartHead.posZ + Math.sin((rotationYaw - 90) / 180.0F * (float)Math.PI) * 2);
worldObj.spawnEntityInWorld(projectile);
}
}
}
else if (nextAttackTimer > 0) nextAttackTimer--;
else if (nextAttackTimer == 0){
Entity attackTarget = target;
@SuppressWarnings("unchecked")
List<EntityPlayer> targets = attackTarget == null ? worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(homeX, homeY, homeZ, homeX, homeY, homeZ).expand(100, 100, 100)) : null;
if (attackTarget == null && targets.size() > 0) attackTarget = targets.get(rand.nextInt(targets.size()));
if (attackTarget == null) return;
//Select an attack
if (attackInProgress == -1){
selectNewAttack();
switch (attackInProgress){
case ATTACK_FIREBALL_CHARGE: {
attackTimer = 90 + rand.nextInt(80);
previousBehaviour = behaviour;
behaviour = EnumBehaviour.CHARGING;
} break;
case ATTACK_FIREBALL_CHASER: attackTimer = 10 + rand.nextInt(80); break;
case ATTACK_ENERGY_CHASER: attackTimer = 10 + rand.nextInt(80); break;
case ATTACK_CHAOS_CHASER: attackTimer = 10 + rand.nextInt(80); break;
case ATTACK_TELEPORT: attackTimer = 90 + rand.nextInt(80); break;
}
}
switch (attackInProgress){
case ATTACK_FIREBALL_CHARGE:
if (target == null && behaviour == EnumBehaviour.CHARGING) target = attackTarget;
if (Utills.getDistanceAtoB(posX, posY, posZ, attackTarget.posX, attackTarget.posY, attackTarget.posZ) > 10)
{
if (attackTimer % 2 == 0)
{
EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.FIREBOMB, attackTarget instanceof EntityLivingBase ? (EntityLivingBase) attackTarget : null, 5F + (rand.nextFloat() * 8F), this);
projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ);
worldObj.spawnEntityInWorld(projectile);
}
double distance = Utills.getDistanceAtoB(attackTarget.posX, attackTarget.posZ, dragonPartHead.posX, dragonPartHead.posZ);
float angle = (float)Math.toDegrees(Math.atan2(attackTarget.posY - dragonPartHead.posY, distance)) * -1F;
rotationPitch = angle;
}else attackTimer = 0;
break;
case ATTACK_FIREBALL_CHASER:
if (attackTimer % 10 == 0) {
EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.FIRE_CHASER, attackTarget instanceof EntityLivingBase ? (EntityLivingBase)attackTarget : null, 5F + (rand.nextFloat() * 8F), this);
projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ);
worldObj.spawnEntityInWorld(projectile);
}
break;
case ATTACK_ENERGY_CHASER:
if (attackTimer % 10 == 0) {
EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.ENERGY_CHASER, attackTarget instanceof EntityLivingBase ? (EntityLivingBase)attackTarget : null, 5F + (rand.nextFloat() * 10F), this);
projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ);
worldObj.spawnEntityInWorld(projectile);
}
break;
case ATTACK_CHAOS_CHASER:
if (attackTimer % 10 == 0) {
EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.CHAOS_CHASER, attackTarget instanceof EntityLivingBase ? (EntityLivingBase)attackTarget : null, 5F + (rand.nextFloat() * 12F), this);
projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ);
worldObj.spawnEntityInWorld(projectile);
}
break;
case ATTACK_TELEPORT:
if (target == null) target = worldObj.getClosestPlayerToEntity(this, 100);
if (target == null){
attackInProgress = -1;
return;
}
if (Utills.getDistanceAtoB(posX, posY, posZ, attackTarget.posX, attackTarget.posY, attackTarget.posZ) > 15)
{
if (attackTimer % 2 == 0)
{
EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.TELEPORT, attackTarget instanceof EntityLivingBase ? (EntityLivingBase) attackTarget : null, 5F + (rand.nextFloat() * 8F), this);
projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ);
worldObj.spawnEntityInWorld(projectile);
}
double distance = Utills.getDistanceAtoB(attackTarget.posX, attackTarget.posZ, dragonPartHead.posX, dragonPartHead.posZ);
float angle = (float)Math.toDegrees(Math.atan2(attackTarget.posY - dragonPartHead.posY, distance)) * -1F;
rotationPitch = angle;
}else attackTimer = 0;
break;
}
attackTimer--;
if (attackTimer <= -1){
if (attackInProgress == ATTACK_FIREBALL_CHARGE) behaviour = previousBehaviour;
attackInProgress = -1;
nextAttackTimer = -1;
}
}
else nextAttackTimer = behaviour == EnumBehaviour.LOW_HEALTH_STRATEGY ? 10 + rand.nextInt(50) : 60 + rand.nextInt(200);
}
private static final WeightedRandom.Item[] weightedAttacks = new WeightedRandom.Item[] {
new WeightedAttack(16, ATTACK_FIREBALL_CHARGE),
new WeightedAttack(14, ATTACK_FIREBALL_CHASER),
new WeightedAttack(12, ATTACK_ENERGY_CHASER),
new WeightedAttack(10, ATTACK_CHAOS_CHASER),
};
private static final WeightedRandom.Item[] weightedLowHealthAttaxks = new WeightedRandom.Item[] {
new WeightedAttack(5, ATTACK_FIREBALL_CHASER),
new WeightedAttack(5, ATTACK_TELEPORT),
new WeightedAttack(10, ATTACK_ENERGY_CHASER),
new WeightedAttack(15, ATTACK_CHAOS_CHASER),
};
private static final WeightedRandom.Item[] weightedBehaviours = new WeightedRandom.Item[] {
new WeightedBehaviour(1, EnumBehaviour.LOW_HEALTH_STRATEGY),
new WeightedBehaviour(10, EnumBehaviour.GUARDING),
new WeightedBehaviour(4, EnumBehaviour.CHARGING),
new WeightedBehaviour(12, EnumBehaviour.FIREBOMB),
new WeightedBehaviour(20, EnumBehaviour.CIRCLE_PLAYER),
};
private void selectNewAttack(){
if (behaviour == EnumBehaviour.LOW_HEALTH_STRATEGY) attackInProgress = ((WeightedAttack)WeightedRandom.getRandomItem(rand, weightedLowHealthAttaxks)).attack;
else if (behaviour != EnumBehaviour.FIREBOMB) attackInProgress = ((WeightedAttack)WeightedRandom.getRandomItem(rand, weightedAttacks)).attack;
else attackInProgress = ATTACK_ENERGY_CHASER;
}
private void selectNewBehaviour(){
if (worldObj.isRemote) return;
EnumBehaviour newBehaviour = behaviour;
while (newBehaviour == behaviour) newBehaviour = ((WeightedBehaviour)WeightedRandom.getRandomItem(rand, weightedBehaviours)).randomBehaviour;
behaviour = newBehaviour;
previousBehaviour = behaviour;
}
private void updateTarget(){
@@ -374,22 +612,28 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
case CHARGING:
break;
case FIREBOMB:
if (Utills.getDistanceAtoB(posX, posY, posZ, homeX, homeY + 30, homeZ) > 3){
targetX = homeX;
targetY = homeY + 30;
targetZ = homeZ;
}
break;
case CIRCLE_PLAYER:
break;
case AVOID_PLAYERS:
break;
case RETREAT:
case LOW_HEALTH_STRATEGY:
break;
case DEAD:
this.targetX = homeX;
this.targetY = homeY;
this.targetZ = homeZ;
this.target = null;
break;
}
}
@@ -431,12 +675,19 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
if (worldObj.getClosestPlayer(homeX, homeY, homeZ, 200) != null) this.target = worldObj.getClosestPlayer(homeX, homeY, homeZ, 200);
break;
case AVOID_PLAYERS:
case LOW_HEALTH_STRATEGY:
break;
case RETREAT:
case FIREBOMB:
@SuppressWarnings("unchecked")
List<EntityPlayer> targets = worldObj.getEntitiesWithinAABB(EntityPlayer.class, boundingBox.expand(150, 150, 150));
target = null;
while (targets.size() > 0 && target == null){
EntityPlayer potentialTarget = targets.get(rand.nextInt(targets.size()));
if (worldObj.rayTraceBlocks(Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(potentialTarget.posX, potentialTarget.posY, potentialTarget.posZ)) == null) target = potentialTarget;
else targets.remove(potentialTarget);
}
break;
case DEAD:
@@ -447,24 +698,110 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
}
@Override
public boolean attackEntityFromPart(EntityDragonPart part, DamageSource damageSource, float dmg) {
if (part != this.dragonPartHead)
{
dmg = dmg / 4.0F + 1.0F;
}
switch (behaviour){
case ROAMING:
break;
case GO_HOME:
break;
case GUARDING:
if (rand.nextInt(5) == 0) selectNewBehaviour();
break;
case CHARGING:
if (rand.nextInt(6) == 0) selectNewBehaviour();
break;
case CIRCLE_PLAYER:
if (rand.nextInt(6) == 0) selectNewBehaviour();
else if (rand.nextInt(4) == 0) circleDirection *= -1;
break;
case LOW_HEALTH_STRATEGY:
if (rand.nextInt(6) == 0 && getHealth() >= getMaxHealth() * 0.2F) selectNewBehaviour();
if (damageSource.getEntity() instanceof EntityPlayer && attackInProgress != ATTACK_TELEPORT)
{
int escape = 0;
boolean flag = false;
while (!flag && escape < 50)
{
targetX = homeX + ((rand.nextDouble() - 0.5D) * 260D);
targetY = homeY + 20 + (rand.nextDouble() - 0.5D) * 50D;
targetZ = homeZ + ((rand.nextDouble() - 0.5D) * 260D);
if (this.getDistanceToEntity(damageSource.getEntity()) >= 70 ) flag = true;
escape++;
}
target = null;
}
break;
case FIREBOMB:
if ((target == null && Utills.getDistanceAtoB(posX, posY, posZ, homeX, homeY + 30, homeZ) <= 3) || rand.nextInt(5) == 0) selectNewBehaviour();
if (damageSource.getEntity() instanceof EntityPlayer && damageSource.getEntity() != target && worldObj.rayTraceBlocks(Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(damageSource.getEntity().posX, damageSource.getEntity().posY, damageSource.getEntity().posZ)) == null){
target = damageSource.getEntity();
}
break;
case DEAD:
break;
}
// float f1 = this.rotationYaw * (float)Math.PI / 180.0F;
// float f2 = MathHelper.sin(f1);
// float f3 = MathHelper.cos(f1);
// this.targetX = this.posX + (double)(f2 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F);
// this.targetY = this.posY + (double)(this.rand.nextFloat() * 3.0F) + 1.0D;
// this.targetZ = this.posZ - (double)(f3 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F);
// this.target = null;
if ((damageSource.getEntity() instanceof EntityPlayer || damageSource.isExplosion()) && healingChaosCrystal == null)
{
this.func_82195_e(damageSource, dmg);
}
return true;
}
private static enum EnumBehaviour {
/**Will roam around home until a player is spotted*/
ROAMING(1F),
GO_HOME(1F),
GUARDING(1F),
CHARGING(1F),
/**Will head home*/
GO_HOME(1.3F),
/**Will will fly around above home attacking players*/
GUARDING(0.8F),
/**Will charge players as the vanilla dragon dose*/
CHARGING(2F),
/**Will fly to centre of island and unleash hell*/
FIREBOMB(1.5F),
/**Will circle a player and shoot at that player*/
CIRCLE_PLAYER(1.2F),
AVOID_PLAYERS(1F),
RETREAT(1F),
DEAD(1F);
/**Will try to avoid players, will try to teleport players, will try to relight crystals*/
LOW_HEALTH_STRATEGY(2F),
/**will die...*/
DEAD(2F);
public float dragonSpeed;
private EnumBehaviour(float dragonSpeed) {this.dragonSpeed = dragonSpeed;}
}
private static class WeightedAttack extends WeightedRandom.Item {
public int attack;
public WeightedAttack(int weight, int attack) {
super(weight);
this.attack = attack;
}
}
private static class WeightedBehaviour extends WeightedRandom.Item {
public EnumBehaviour randomBehaviour;
public WeightedBehaviour(int weight, EnumBehaviour randomBehaviour) {
super(weight);
this.randomBehaviour = randomBehaviour;
}
}
@Override
protected void onDeathUpdate() {
@@ -566,52 +903,43 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
}
private void attackEntitiesInList(List par1List) {
// for (int i = 0; i < par1List.size(); ++i) {
// Entity entity = (Entity) par1List.get(i);
//
// if (entity instanceof EntityLivingBase && !isUber) {
// ((EntityLivingBase)entity).setLastAttacker(this);
// entity.attackEntityFrom(DamageSource.causeMobDamage(this), attackDamage);
// }
// if (entity instanceof EntityLivingBase && isUber){
// ((EntityLivingBase)entity).setLastAttacker(this);
// entity.attackEntityFrom(new DamageSourceChaos(this), 50F);
// }
// }
}
if (behaviour == EnumBehaviour.CHARGING)
{
boolean hasAttacked = false;
for (int i = 0; i < par1List.size(); ++i)
{
Entity entity = (Entity) par1List.get(i);
private void updateDragonEnderCrystal() {
// if (this.healingEnderCrystal != null) {
// if (this.healingEnderCrystal.isDead) {
// if (!this.worldObj.isRemote) {
// this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource((Explosion) null), 10.0F);
// }
//
// this.healingEnderCrystal = null;
// } else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
// if (isUber) this.setHealth(this.getHealth() + 10.0F);
// else this.setHealth(this.getHealth() + 1.0F);
// }
// }
if (this.rand.nextInt(10) == 0) {
float f = 32.0F;
List list = this.worldObj.getEntitiesWithinAABB(EntityEnderCrystal.class, this.boundingBox.expand((double) f, (double) f, (double) f));
EntityEnderCrystal entityendercrystal = null;
double d0 = Double.MAX_VALUE;
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal) iterator.next();
double d1 = entityendercrystal1.getDistanceSqToEntity(this);
if (d1 < d0) {
d0 = d1;
entityendercrystal = entityendercrystal1;
if (entity instanceof EntityLivingBase)
{
((EntityLivingBase) entity).setLastAttacker(this);
entity.attackEntityFrom(new DamageSourceChaos(this), 50F);
hasAttacked = true;
}
}
this.healingEnderCrystal = entityendercrystal;
if (hasAttacked && rand.nextInt(2) == 0) behaviour = EnumBehaviour.GUARDING;
}
}
private void updateDragonEnderCrystal() {
if (worldObj.isRemote) return;
if (this.healingChaosCrystal != null) {
if (!healingChaosCrystal.isAlive()){
this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource(null), 10.0F);
healingChaosCrystal = null;
}else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth())
{
this.setHealth(this.getHealth() + 2F);
}
}
if (this.rand.nextInt(10) == 0) {
EntityChaosCrystal closest = null;
for (EntityChaosCrystal crystal : crystals) if (crystal.isAlive() && (closest == null || getDistanceToEntity(crystal) < getDistanceToEntity(closest))) closest = crystal;
healingChaosCrystal = closest;
if (healingChaosCrystal != null) connectedCrystalID = healingChaosCrystal.getEntityId();
else connectedCrystalID = -1;
}
}
@@ -750,20 +1078,23 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
compound.setInteger("HomeX", homeX);
compound.setInteger("HomeY", homeY);
compound.setInteger("HomeZ", homeZ);
compound.setInteger("HomeXCoord", homeX);
compound.setInteger("HomeYCoord", homeY);
compound.setInteger("HomeZCoord", homeZ);
compound.setString("Behaviour", behaviour.name());
compound.setBoolean("HomeSet", homeSet);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
homeX = compound.getInteger("HomeX");
homeY = compound.getInteger("HomeY");
homeZ = compound.getInteger("HomeZ");
homeX = compound.getInteger("HomeXCoord");
homeY = compound.getInteger("HomeYCoord");
homeZ = compound.getInteger("HomeZCoord");
if (compound.hasKey("Behaviour")) behaviour = EnumBehaviour.valueOf(compound.getString("Behaviour"));
homeSet = compound.getBoolean("HomeSet");
targetX = homeX;
targetZ = homeZ;
}
@Override
@@ -778,20 +1109,8 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio
@Override
public boolean attackEntityFrom(DamageSource damageSource, float dmg) {
// if (damageSource.getEntity() != null && getDistanceToEntity(damageSource.getEntity()) > 100) {
// LogHelper.info("cancel attack");
// return false;
// }
return super.attackEntityFrom(damageSource, dmg);
}
@Override
public boolean attackEntityFromPart(EntityDragonPart p_70965_1_, DamageSource damageSource, float p_70965_3_) {
// if (damageSource.getEntity() != null && Utills.getDistanceAtoB(damageSource.getEntity().posX)getDistanceToEntity(damageSource.getEntity()) > 100) {
// LogHelper.info("cancel attack");
// return false;
// }
return super.attackEntityFromPart(p_70965_1_, damageSource, p_70965_3_);
return super.attackEntityFrom(damageSource, dmg);
}
@Override
@@ -1,22 +1,48 @@
package com.brandon3055.draconicevolution.common.entity;
import cofh.api.energy.IEnergyContainerItem;
import com.brandon3055.brandonscore.common.utills.Teleporter;
import com.brandon3055.brandonscore.common.utills.Utills;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
import com.brandon3055.draconicevolution.client.render.particle.Particles;
import com.brandon3055.draconicevolution.common.network.GenericParticlePacket;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.boss.EntityDragonPart;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.world.World;
import java.util.List;
/**
* Created by brandon3055 on 23/8/2015.
*/
public class EntityDragonProjectile extends Entity {
public int type;
public Entity target;
public int type = 0;
public EntityLivingBase target;
public Entity shooter;
public float power;
public boolean isChaser;
private double lastTickTargetDistance = 100;
private float heath = 5F;
private DamageSource damageFireball = new DamageSource("de.GuardianFireball").setDamageAllowedInCreativeMode().setMagicDamage().setExplosion();
private DamageSource damageEnergy = new DamageSource("de.GuardianEnergyBall").setDamageAllowedInCreativeMode().setDamageBypassesArmor();
private DamageSource damageChaos = new DamageSource("de.GuardianChaosBall").setDamageAllowedInCreativeMode().setDamageBypassesArmor().setDamageIsAbsolute();
//public static final int FIREBALL = 0; /** Generic fireball a lot more powerful then ghast fireball */
public static final int FIREBOMB = 1; /** Large fireball with a trail and large fiery AOE */
public static final int ENDER_PORT = 2; /** Ender pearl which teleports the player away if it hits. */
public static final int TELEPORT = 2; /** Ender pearl which teleports the player away if it hits. */
public static final int FIRE_CHASER = 3; /** Fireball that chases the player it is fired at (Explodes on impact with blocks) */
public static final int ENERGY_CHASER = 4; /** Energy gall that chases the player. (Can pass through blocks) */
public static final int CHAOS_CHASER = 5; /** Chases player. On impact splits into mini chaos charges which lock on to other or the same player (can pass through blocks) */
@@ -24,26 +50,273 @@ public class EntityDragonProjectile extends Entity {
public static final int IGNITION_CHARGE = 7; /** Reignites Crystals */
public EntityDragonProjectile(World world){
this(world, 1, null, 5);
this(world, 0, null, 10, null);
}
public EntityDragonProjectile(World world, int type, Entity target, float power) {
public EntityDragonProjectile(World world, int type, EntityLivingBase target, float power, Entity shooter) {
super(world);
this.type = type;
this.target = target;
this.shooter = shooter;
this.power = power;
this.isChaser = type == FIRE_CHASER || type == ENERGY_CHASER || type == CHAOS_CHASER || type == MINI_CHAOS_CHASER || type == IGNITION_CHARGE;
this.setSize(0.5F, 0.5F);
this.setSize(1F, 1F);
if (shooter != null){
worldObj.playSoundEffect(shooter.posX + 0.5D, shooter.posY + 0.5D, shooter.posZ + 0.5D, "mob.ghast.fireball", 10.0F, rand.nextFloat() * 0.3F + 0.85F);
this.rotationYaw = shooter instanceof EntityDragon ? shooter.rotationYaw + 180F : shooter.rotationYaw;
this.rotationPitch = shooter.rotationPitch;
if (type == FIREBOMB || type == TELEPORT){
rotationPitch += (rand.nextFloat() - 0.5F) * 20F;
rotationYaw += (rand.nextFloat() - 0.5F) * 20F;
}
this.yOffset = 0.0F;
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
double speed = 5;
this.motionX *= speed;
this.motionY *= speed;
this.motionZ *= speed;
}
}
@SideOnly(Side.CLIENT)
public boolean isInRangeToRenderDist(double p_70112_1_)
{
double d1 = this.boundingBox.getAverageEdgeLength() * 80.0D;
d1 *= 64.0D;
return p_70112_1_ < d1 * d1;
}
@Override
protected void entityInit() {
if (type == ENERGY_CHASER || type == CHAOS_CHASER || type == MINI_CHAOS_CHASER || type == IGNITION_CHARGE || worldObj.isRemote) noClip = true;
dataWatcher.addObject(10, (byte) type);
}
@Override
public void onUpdate() {
super.onUpdate();
if (!worldObj.isRemote && ticksExisted == 1) dataWatcher.updateObject(10, (byte)type);
if (worldObj.isRemote) {
if (type == 0) type = dataWatcher.getWatchableObjectByte(10);
spawnParticle();
}
//Check that there is still a target available and if not kills the projectile.
if (target == null){
if (worldObj.getClosestPlayer(posX, posY, posZ, 60) != null) target = worldObj.getClosestPlayer(posX, posY, posZ, 60);
else {
if (!worldObj.isRemote)setDead();
return;
}
}
if (isChaser && !worldObj.isRemote){
double tDist = Utills.getDistanceAtoB(target.posX, target.posY, target.posZ, posX, posY, posZ);
if (tDist <= 0) tDist = 0.1;
double x = (target.posX - posX) / tDist;
double y = (target.posY - posY - -1) / tDist;
double z = (target.posZ - posZ) / tDist;
double speed = type == CHAOS_CHASER ? 0.15D : 0.1D;
motionX /= 1.1;
motionY /= 1.1;
motionZ /= 1.1;
motionX += x * speed;
motionY += y * speed;
motionZ += z * speed;
}
moveEntity(motionX, motionY, motionZ);
checkTargetCondition();
}
private boolean checkTargetCondition(){
if (worldObj.isRemote) return false;
double targetDistance = Utills.getDistanceAtoB(posX, posY, posZ, target.posX, target.posY, target.posZ);
Entity entityHit = getHitEntity();
if (entityHit instanceof EntityDragonPart) entityHit = null;
boolean genericHit = entityHit != null || targetDistance <= 1;
switch (type){
case FIREBOMB:
if (genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power) || isCollided || ticksExisted > 600 || heath <= 0){
setDead();
worldObj.newExplosion(shooter, this.posX, this.posY, this.posZ, 2F, true, true);
damageEntitiesInRadius(damageFireball, power, power*2);
}
break;
case TELEPORT:
if (genericHit){
setDead();
Entity hit = entityHit != null ? entityHit : target;
LogHelper.info(hit);
int r = rand.nextInt();
if (shooter != null) new Teleporter.TeleportLocation(shooter.posX + (Math.cos(r) * 600), rand.nextInt(255), shooter.posZ + (Math.sin(r) * 600), hit.dimension).sendEntityToCoords(hit);
else new Teleporter.TeleportLocation(posX + (Math.cos(r) * 600), rand.nextInt(255), posZ + (Math.sin(r) * 600), hit.dimension).sendEntityToCoords(hit);
hit.attackEntityFrom(DamageSource.fall, 10F);
}else if (isCollided || ticksExisted > 400 || heath <= 0) setDead();
break;
case FIRE_CHASER:
noClip = ticksExisted < 60;
if (genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power/2) || (isCollided && ticksExisted > 60) || ticksExisted > 400 || heath <= 0){
setDead();
worldObj.newExplosion(shooter, this.posX, this.posY, this.posZ, 2F, true, true);
damageEntitiesInRadius(damageFireball, power, power * 2);
}
break;
case ENERGY_CHASER:
if (genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power) || ticksExisted > 800 || heath <= 0){
setDead();
DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.ENERGY_BALL_KILL, posX, posY, posZ), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 128));
damageEntitiesInRadius(damageEnergy, power, power * 3);
worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 4.0F, (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F);
}
break;
case CHAOS_CHASER:
if (genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power) || ticksExisted > 800 || heath <= 0){
setDead();
DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.CHAOS_BALL_KILL, posX, posY, posZ), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 128));
damageEntitiesInRadius(damageChaos, power, power * 3);
worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 4.0F, (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F);
int i = 3 + rand.nextInt(3);
EntityDragonProjectile newProjectile;
@SuppressWarnings("unchecked")
List<EntityLivingBase> list = worldObj.getEntitiesWithinAABBExcludingEntity(shooter, boundingBox.expand(60, 60, 60), Utills.selectPlayer);
for (i=i; i > 0; i--){
newProjectile = new EntityDragonProjectile(worldObj, MINI_CHAOS_CHASER, list.size() > 0 ? list.get(rand.nextInt(list.size())) : null, power/2F, shooter);
newProjectile.motionY = 0;
int randDir = rand.nextInt();
double speed = 1 + rand.nextDouble() * 5;
newProjectile.motionX = Math.sin(randDir) * speed;
newProjectile.motionZ = Math.cos(randDir) * speed;
newProjectile.setPosition(posX, posY, posZ);
worldObj.spawnEntityInWorld(newProjectile);
}
}
break;
case MINI_CHAOS_CHASER:
if ((genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power) || ticksExisted > 800 || heath <= 0) && ticksExisted > 5)
{
setDead();
DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.CHAOS_BALL_KILL, posX, posY, posZ), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 128));
damageEntitiesInRadius(damageChaos, power, power * 3);
worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 4.0F, (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F);
}
break;
case IGNITION_CHARGE:
if (targetDistance < 1){
if (target instanceof EntityChaosCrystal) ((EntityChaosCrystal) target).revive();
setDead();
}
break;
}
lastTickTargetDistance = targetDistance;
return false;
}
private Entity getHitEntity(){
Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
Entity entityHit = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
int i;
float f1;
for (i = 0; i < list.size(); ++i) {
Entity entity1 = (Entity) list.get(i);
if (entity1.canBeCollidedWith() && (entity1 != this.shooter || this.ticksExisted >= 5)) {
f1 = 1F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
if (movingobjectposition1 != null) {
double d1 = vec31.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D) {
entityHit = entity1;
d0 = d1;
}
}
}
}
return entityHit instanceof EntityDragonProjectile ? null : entityHit;
}
private void damageEntitiesInRadius(DamageSource source, double radius, float damage){
if (worldObj.isRemote) return;
@SuppressWarnings("unchecked")
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX, posY, posZ).expand(radius, radius, radius));
for (EntityLivingBase entityLivingBase : entities) {
if (entityLivingBase == shooter) continue;
entityLivingBase.hurtResistantTime = 0;
entityLivingBase.attackEntityFrom(source, damage / (float)(Utills.getDistanceAtoB(entityLivingBase.posX, entityLivingBase.posY, entityLivingBase.posZ, posX, posY, posZ) / radius));
if (source == damageChaos && entityLivingBase instanceof EntityPlayer){
for (ItemStack stack : ((EntityPlayer) entityLivingBase).inventory.armorInventory) {
if (stack != null && stack.getItem() instanceof IEnergyContainerItem){
((IEnergyContainerItem) stack.getItem()).extractEnergy(stack, ((IEnergyContainerItem) stack.getItem()).getMaxEnergyStored(stack) / (50 + rand.nextInt(50)), false);
}
}
}
}
}
@Override
public boolean attackEntityFrom(DamageSource source, float dmg) {
if (heath <= 0) return false;
if ((source.getEntity() instanceof EntityPlayer || source.getEntity() instanceof EntityArrow) && ticksExisted > 5) heath -= dmg;
if (source.getSourceOfDamage() instanceof EntityArrow) source.getSourceOfDamage().setDead();
if (heath <= 0){
worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 2F, false, false);
setDead();
}
return true;
}
@SideOnly(Side.CLIENT)
private void spawnParticle(){
if (getParticleColour() == 0) return;
Particles.DragonProjectileParticle particle = new Particles.DragonProjectileParticle(worldObj, posX - 0.25 + rand.nextDouble() * 0.5, posY + rand.nextDouble() * 0.5, posZ - 0.25 + rand.nextDouble() * 0.5, this);
double mm = 0.2;
particle.motionX = (rand.nextDouble() - 0.5) * mm;
particle.motionY = (rand.nextDouble() - 0.5) * mm;
particle.motionZ = (rand.nextDouble() - 0.5) * mm;
ParticleHandler.spawnCustomParticle(particle, 64);
}
public int getParticleColour(){
switch (type){
case FIREBOMB: return 0xFF6600;
case TELEPORT: return 0;
case FIRE_CHASER: return 0xFF6600;
case ENERGY_CHASER: return 0x00FFFF;
case CHAOS_CHASER: return 0x440000;
case MINI_CHAOS_CHASER: return 0x440000;
case IGNITION_CHARGE: return 0xFFFFFF;
}
return 0;
}
@Override
@@ -52,12 +325,25 @@ public class EntityDragonProjectile extends Entity {
}
@Override
protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {
public boolean canBeCollidedWith() {
return true;
}
public float getCollisionBorderSize()
{
return 1.0F;
}
@Override
protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {
protected void readEntityFromNBT(NBTTagCompound compound) {
type = compound.getInteger("Type");
if (!worldObj.isRemote) dataWatcher.updateObject(10, (byte)type);
noClip = type == ENERGY_CHASER || type == CHAOS_CHASER || type == MINI_CHAOS_CHASER || type == IGNITION_CHARGE;
isChaser = type == FIRE_CHASER || type == ENERGY_CHASER || type == CHAOS_CHASER || type == MINI_CHAOS_CHASER || type == IGNITION_CHARGE;
}
@Override
protected void writeEntityToNBT(NBTTagCompound compound) {
compound.setInteger("Type", type);
}
}
@@ -76,7 +76,7 @@ public class CraftingHandler {
//aesthetic
add(ModBlocks.particleGenerator, "RBR", "BCB", "RBR", 'R', Blocks.redstone_block, 'B', Items.blaze_rod, 'C', ModItems.draconicCore);
addOre(ModBlocks.infusedObsidian, "BOB", "ODO", "BOB", 'B', Items.blaze_powder, 'O', Blocks.obsidian, 'D', "dustDraconium");
addOre(new ItemStack(ModBlocks.infusedObsidian, 4), "BOB", "ODO", "BOB", 'B', Items.blaze_powder, 'O', Blocks.obsidian, 'D', "dustDraconium");
//machines
addOre(ModBlocks.potentiometer, "ITI", "QCQ", "IRI", 'I', "ingotIron", 'T', Blocks.redstone_torch, 'Q', "gemQuartz", 'C', Items.comparator, 'R', Blocks.redstone_block);
@@ -1,20 +1,21 @@
package com.brandon3055.draconicevolution.common.items;
import com.brandon3055.brandonscore.common.handlers.ProcessHandler;
import com.brandon3055.draconicevolution.client.render.particle.Particles;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.ModItems;
import com.brandon3055.draconicevolution.common.entity.EntityChaosCrystal;
import com.brandon3055.draconicevolution.common.items.tools.baseclasses.ToolHandler;
import com.brandon3055.draconicevolution.common.lib.Strings;
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.ReactorExplosion;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
@@ -108,25 +109,62 @@ public class Tclogo extends ItemDE {
}
private static int lts = 0;
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
// if ((int)System.currentTimeMillis() < lts + 10) return stack;
// else lts = (int)System.currentTimeMillis();
//world.playSound(player.posX, player.posY, player.posZ, "DraconicEvolution:fusionExplosion", 1F, 1F, false);
LogHelper.info(GameRegistry.findBlock("ThermalDynamics", "ThermalDynamics_0"));
if (player.inventory.getStackInSlot(0) != null) LogHelper.info(GameRegistry.findUniqueIdentifierFor(player.inventory.getStackInSlot(0).getItem()));
// LogHelper.info(GameRegistry.findBlock("ThermalDynamics", "ThermalDynamics_0"));
// if (player.inventory.getStackInSlot(0) != null) LogHelper.info(GameRegistry.findUniqueIdentifierFor(player.inventory.getStackInSlot(0).getItem()));
//
// if (world.isRemote){
// particle(world, player);
// //if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) ProcessHandler.addProcess(new ReactorExplosion(world, mop.blockX, mop.blockY, mop.blockZ, 10F));
// }
// else {
// MovingObjectPosition mop = ToolHandler.raytraceFromEntity(world, player, 10000);
// //LogHelper.info(mop);
// //FMLClientHandler.instance().getClient().effectRenderer.addEffect(new Particles.ReactorExplosionParticle(world, mop.blockX, mop.blockY, mop.blockZ));
// if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) ProcessHandler.addProcess(new ReactorExplosion(world, mop.blockX, mop.blockY, mop.blockZ, 20F));
// }
if (world.isRemote){
particle(world, player);
//if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) ProcessHandler.addProcess(new ReactorExplosion(world, mop.blockX, mop.blockY, mop.blockZ, 10F));
}
else {
MovingObjectPosition mop = ToolHandler.raytraceFromEntity(world, player, 10000);
//LogHelper.info(mop);
//FMLClientHandler.instance().getClient().effectRenderer.addEffect(new Particles.ReactorExplosionParticle(world, mop.blockX, mop.blockY, mop.blockZ));
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) ProcessHandler.addProcess(new ReactorExplosion(world, mop.blockX, mop.blockY, mop.blockZ, 20F));
//EntityDragonProjectile projectile = new EntityDragonProjectile(world, 6, null, 10, player);
//projectile.setPosition(player.posX, player.posY, player.posZ);
if (!world.isRemote)
{
int x1 = (int)player.posX;
int y1 = (int)player.posY;
int z1 = (int)player.posZ;
world.setBlock(x1, y1 + 20, z1, ModBlocks.infusedObsidian, 0, 2);
if (!world.isRemote) {
EntityChaosCrystal crystal = new EntityChaosCrystal(world);
crystal.setPosition(x1 + 0.5, y1 + 21, z1 + 0.5);
world.spawnEntityInWorld(crystal);
}
for (int y = y1; y < y1 + 20; y++) {
world.setBlock(x1, y, z1, Blocks.obsidian, 0, 2);
world.setBlock(x1 + 1, y, z1, Blocks.obsidian, 0, 2);
world.setBlock(x1 - 1, y, z1, Blocks.obsidian, 0, 2);
world.setBlock(x1, y, z1 + 1, Blocks.obsidian, 0, 2);
world.setBlock(x1, y, z1 - 1, Blocks.obsidian, 0, 2);
world.setBlock(x1 + 1, y, z1 + 1, Blocks.obsidian, 0, 2);
world.setBlock(x1 - 1, y, z1 - 1, Blocks.obsidian, 0, 2);
world.setBlock(x1 + 1, y, z1 - 1, Blocks.obsidian, 0, 2);
world.setBlock(x1 - 1, y, z1 + 1, Blocks.obsidian, 0, 2);
}
//world.spawnEntityInWorld(projectile);
}
List<Entity> l = world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(player.posX, player.posY, player.posZ, player.posX, player.posY, player.posZ).expand(500, 500, 500));
//for (Entity e : l) if (!(e instanceof EntityPlayer)) e.setDead();
if (1==1) return stack;
/*if (player instanceof EntityPlayerMP) {
for (int i = 0; i < 10; i++)
@@ -0,0 +1,85 @@
package com.brandon3055.draconicevolution.common.network;
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
import com.brandon3055.draconicevolution.client.render.particle.Particles;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
public class GenericParticlePacket implements IMessage
{
public static final byte ENERGY_BALL_KILL = 0;
public static final byte CHAOS_BALL_KILL = 1;
byte particleId = 0;
double posX;
double posY;
double posZ;
public GenericParticlePacket() {}
public GenericParticlePacket(byte particleId, double posX, double posY, double posZ) {
this.particleId = particleId;
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
}
@Override
public void fromBytes(ByteBuf bytes){
this.particleId = bytes.readByte();
this.posX = (double)bytes.readFloat();
this.posY = (double)bytes.readFloat();
this.posZ = (double)bytes.readFloat();
}
@Override
public void toBytes(ByteBuf bytes){
bytes.writeByte(particleId);
bytes.writeFloat((float)posX);
bytes.writeFloat((float)posY);
bytes.writeFloat((float)posZ);
}
public static class Handler implements IMessageHandler<GenericParticlePacket, IMessage> {
@Override
public IMessage onMessage(GenericParticlePacket message, MessageContext ctx) {
switch (message.particleId) {
case ENERGY_BALL_KILL:
{
Particles.DragonProjectileParticle particle;
for (int i = 0; i < 100; i++){
particle = new Particles.DragonProjectileParticle(FMLClientHandler.instance().getWorldClient(), message.posX, message.posY, message.posZ, 0x00FFFF);
double m = 0.5D;
particle.motionX = (particle.worldObj.rand.nextDouble() - 0.5) * m;
particle.motionY = (particle.worldObj.rand.nextDouble() - 0.5) * m;
particle.motionZ = (particle.worldObj.rand.nextDouble() - 0.5) * m;
ParticleHandler.spawnCustomParticle(particle);
}
break;
}
case CHAOS_BALL_KILL:
{
Particles.DragonProjectileParticle particle;
for (int i = 0; i < 100; i++){
particle = new Particles.DragonProjectileParticle(FMLClientHandler.instance().getWorldClient(), message.posX, message.posY, message.posZ, 0x440000);
double m = 0.5D;
particle.motionX = (particle.worldObj.rand.nextDouble() - 0.5) * m;
particle.motionY = (particle.worldObj.rand.nextDouble() - 0.5) * m;
particle.motionZ = (particle.worldObj.rand.nextDouble() - 0.5) * m;
ParticleHandler.spawnCustomParticle(particle);
}
break;
}
default:
break;
}
return null;
}
}
}
@@ -1,9 +1,8 @@
package com.brandon3055.draconicevolution.common.world;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.entity.EntityCustomDragon;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import net.minecraft.entity.item.EntityEnderCrystal;
import com.brandon3055.draconicevolution.common.entity.EntityChaosCrystal;
import com.brandon3055.draconicevolution.common.entity.EntityChaosGuardian;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
@@ -29,10 +28,10 @@ public class WorldGenEnderIsland extends WorldGenerator {
@Override
public boolean generate(World world, Random random, int x, int y, int z) {
LogHelper.info("Generate");
//LogHelper.info("Generate");
for (int y1 = y - 10; y1 < y + 10; y1++) {
if (world.getBlock(x, y1, z) == Blocks.end_stone) {
LogHelper.info("cancel");
//LogHelper.info("cancel");
return false;
}
}
@@ -40,15 +39,8 @@ public class WorldGenEnderIsland extends WorldGenerator {
generateCentre(world, random);
generateBelt(world, random, size + 50, size + 200);
generateObelisks(world, random);
EntityCustomDragon dragon = new EntityCustomDragon(world, 500F, 100F);
EntityChaosGuardian dragon = new EntityChaosGuardian(world);
dragon.setPositionAndUpdate(x, 180, z);
dragon.setUber(true);
dragon.portalX = x;
dragon.portalY = y+20;
dragon.portalZ = z;
dragon.setCustomNameTag("Chaos Guardian");
//two dragons?dragon.onSpawnWithEgg(null);
LogHelper.info("Spawn dragon");
world.spawnEntityInWorld(dragon);
return true;
}
@@ -150,9 +142,9 @@ public class WorldGenEnderIsland extends WorldGenerator {
private void generateObelisk(World world, int x1, int y1, int z1, boolean outer, Random rand) {
if (!outer) {
world.setBlock(x1, y1 + 20, z1, Blocks.bedrock, 0, 2);
world.setBlock(x1, y1 + 20, z1, ModBlocks.infusedObsidian, 0, 2);
if (!world.isRemote) {
EntityEnderCrystal crystal = new EntityEnderCrystal(world);
EntityChaosCrystal crystal = new EntityChaosCrystal(world);
crystal.setPosition(x1 + 0.5, y1 + 21, z1 + 0.5);
world.spawnEntityInWorld(crystal);
}
@@ -168,9 +160,9 @@ public class WorldGenEnderIsland extends WorldGenerator {
world.setBlock(x1 - 1, y, z1 + 1, Blocks.obsidian, 0, 2);
}
} else {
world.setBlock(x1, y1 + 40, z1, Blocks.bedrock, 0, 2);
world.setBlock(x1, y1 + 40, z1, ModBlocks.infusedObsidian, 0, 2);
if (!world.isRemote) {
EntityEnderCrystal crystal = new EntityEnderCrystal(world);
EntityChaosCrystal crystal = new EntityChaosCrystal(world);
crystal.setPosition(x1 + 0.5, y1 + 41, z1 + 0.5);
world.spawnEntityInWorld(crystal);
}