diff --git a/src/main/java/electroblob/wizardry/client/ClientProxy.java b/src/main/java/electroblob/wizardry/client/ClientProxy.java index b910152f..63c5e1ad 100644 --- a/src/main/java/electroblob/wizardry/client/ClientProxy.java +++ b/src/main/java/electroblob/wizardry/client/ClientProxy.java @@ -829,18 +829,18 @@ public class ClientProxy extends CommonProxy { // Runes on ground RenderingRegistry.registerEntityRenderingHandler(EntityHealAura.class, - manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/healing_aura.png"), 5.0f, false)); + manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/healing_aura.png"), 0.3f, false)); RenderingRegistry.registerEntityRenderingHandler(EntityFireSigil.class, - manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/fire_sigil.png"), 2.0f, true)); + manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/fire_sigil.png"), 0, true)); RenderingRegistry.registerEntityRenderingHandler(EntityFrostSigil.class, - manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/frost_sigil.png"), 2.0f, true)); + manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/frost_sigil.png"), 0, true)); RenderingRegistry.registerEntityRenderingHandler(EntityLightningSigil.class, - manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/lightning_sigil.png"), 2.0f, true)); + manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/lightning_sigil.png"), 0, true)); RenderingRegistry.registerEntityRenderingHandler(EntityFireRing.class, - manager -> new RenderFireRing(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/ring_of_fire.png"), 5.0f)); + manager -> new RenderFireRing(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/ring_of_fire.png"))); RenderingRegistry.registerEntityRenderingHandler(EntityDecay.class, RenderDecay::new); RenderingRegistry.registerEntityRenderingHandler(EntityCombustionRune.class, - manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/combustion_rune.png"), 2.0f, true)); + manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/combustion_rune.png"), 0, true)); // TESRs ClientRegistry.bindTileEntitySpecialRenderer(TileEntityArcaneWorkbench.class, new RenderArcaneWorkbench()); diff --git a/src/main/java/electroblob/wizardry/client/renderer/entity/RenderBlackHole.java b/src/main/java/electroblob/wizardry/client/renderer/entity/RenderBlackHole.java index d1339090..247c3606 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/entity/RenderBlackHole.java +++ b/src/main/java/electroblob/wizardry/client/renderer/entity/RenderBlackHole.java @@ -18,6 +18,7 @@ import java.util.Collections; public class RenderBlackHole extends Render { + // TODO: Remove RayHelper and the ray texture entirely and use colours with depth mask off (like imbuement altar) private static final ResourceLocation RAY_TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/entity/black_hole/ray.png"); private static final ResourceLocation CENTRE_TEXTURE = new ResourceLocation(Wizardry.MODID, @@ -65,20 +66,20 @@ public class RenderBlackHole extends Render { for(int j = 0; j < 30; j++){ - float scale = 3.0f; + float radius = 3.0f * entity.getSizeMultiplier(); int a = entity.randomiser[j]; int b = entity.randomiser2[j]; int sliceAngle = 20 + a; - double x1 = scale * MathHelper.sin((entity.ticksExisted + 40 * j) * ((float)Math.PI / 180f)); + double x1 = radius * MathHelper.sin((entity.ticksExisted + 40 * j) * ((float)Math.PI / 180f)); // double y1 = 0.7*MathHelper.cos((blackhole.timer - 40*j)*(Math.PI/180))*j/10; - double z1 = scale * MathHelper.cos((entity.ticksExisted + 40 * j) * ((float)Math.PI / 180)); + double z1 = radius * MathHelper.cos((entity.ticksExisted + 40 * j) * ((float)Math.PI / 180)); - double x2 = scale * MathHelper.sin((entity.ticksExisted + 40 * j - sliceAngle) * ((float)Math.PI / 180)); + double x2 = radius * MathHelper.sin((entity.ticksExisted + 40 * j - sliceAngle) * ((float)Math.PI / 180)); // double y2 = 0.7*MathHelper.sin((blackhole.timer - 40*j)*(Math.PI/180))*j/10; - double z2 = scale * MathHelper.cos((entity.ticksExisted + 40 * j - sliceAngle) * ((float)Math.PI / 180)); + double z2 = radius * MathHelper.cos((entity.ticksExisted + 40 * j - sliceAngle) * ((float)Math.PI / 180)); double absoluteX = x1 * MathHelper.cos(31 * b); double absoluteY = z1 * MathHelper.sin(31 * a) + x1 * MathHelper.cos(31 * a) * MathHelper.sin(31 * b); diff --git a/src/main/java/electroblob/wizardry/client/renderer/entity/RenderFireRing.java b/src/main/java/electroblob/wizardry/client/renderer/entity/RenderFireRing.java index 146722a3..b25446b2 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/entity/RenderFireRing.java +++ b/src/main/java/electroblob/wizardry/client/renderer/entity/RenderFireRing.java @@ -19,12 +19,10 @@ import org.lwjgl.opengl.GL11; public class RenderFireRing extends Render { private final ResourceLocation texture; - private float scale; - public RenderFireRing(RenderManager renderManager, ResourceLocation texture, float scale){ + public RenderFireRing(RenderManager renderManager, ResourceLocation texture){ super(renderManager); this.texture = texture; - this.scale = scale; } @Override @@ -48,7 +46,7 @@ public class RenderFireRing extends Render { GlStateManager.rotate(-90, 1, 0, 0); float s = DrawingUtils.smoothScaleFactor(entity.lifetime, entity.ticksExisted, partialTicks, 10, 10); - GlStateManager.scale(scale * s, scale * s, scale * s); + GlStateManager.scale(entity.width * s, entity.width * s, entity.width * s); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.getBuffer(); @@ -66,20 +64,21 @@ public class RenderFireRing extends Render { GlStateManager.popMatrix(); // Fire + // TODO: Bleeeuuurugh this is disgusting must fix :0 if(s >= 1){ GlStateManager.disableLighting(); TextureAtlasSprite icon = Minecraft.getMinecraft().getBlockRendererDispatcher() .getModelForState(Blocks.FIRE.getDefaultState()).getParticleTexture(); - int sides = 16; + float s1 = entity.width/5; + int sides = (int)(16 * s1); float height = 1.0f; for(int k = 0; k < sides; k++){ GlStateManager.pushMatrix(); GlStateManager.translate((float)x, (float)y + 0.05f, (float)z); - float f1 = 1.0f; - GlStateManager.scale(f1, f1, f1); +// GlStateManager.scale(s1, s1, s1); float f2 = 0.5F; float f3 = 0.0F; float f4 = 0.2f; @@ -89,7 +88,7 @@ public class RenderFireRing extends Render { int i = 0; GlStateManager.rotate((360f / (float)sides) * k, 0, 1, 0); - GlStateManager.translate(0, 0, -2.3f); + GlStateManager.translate(0, 0, -2.3f * s1); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); @@ -126,8 +125,7 @@ public class RenderFireRing extends Render { GlStateManager.pushMatrix(); GlStateManager.translate((float)x, (float)y + 0.05f, (float)z); - float f1 = 1.0f; - GlStateManager.scale(f1, f1, f1); +// GlStateManager.scale(s1, s1, s1); float f2 = 0.5F; float f3 = 0.0F; float f4 = 0.2f; @@ -137,7 +135,7 @@ public class RenderFireRing extends Render { int i = 0; GlStateManager.rotate((360f / (float)sides) * k, 0, 1, 0); - GlStateManager.translate(0, 0, 2.3f); + GlStateManager.translate(0, 0, 2.3f * s1); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); diff --git a/src/main/java/electroblob/wizardry/client/renderer/entity/RenderRadiantTotem.java b/src/main/java/electroblob/wizardry/client/renderer/entity/RenderRadiantTotem.java index 8ecbe2b7..7a87c26f 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/entity/RenderRadiantTotem.java +++ b/src/main/java/electroblob/wizardry/client/renderer/entity/RenderRadiantTotem.java @@ -107,9 +107,9 @@ public class RenderRadiantTotem extends Render { float age = entity.ticksExisted + partialTicks; float rotationSpeed = 2; -// GlStateManager.rotate(age * rotationSpeed/2, 0.0F, 1.0F, 0.0F); -// GlStateManager.rotate(60.0F, 0.7071F, 0.0F, 0.7071F); -// GlStateManager.rotate(age * rotationSpeed, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(age * rotationSpeed/2, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(60.0F, 0.7071F, 0.0F, 0.7071F); + GlStateManager.rotate(age * rotationSpeed, 0.0F, 1.0F, 0.0F); GlStateManager.scale(0.5, 0.5, 0.5); diff --git a/src/main/java/electroblob/wizardry/client/renderer/entity/RenderSigil.java b/src/main/java/electroblob/wizardry/client/renderer/entity/RenderSigil.java index 3e58323f..8310d968 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/entity/RenderSigil.java +++ b/src/main/java/electroblob/wizardry/client/renderer/entity/RenderSigil.java @@ -1,7 +1,6 @@ package electroblob.wizardry.client.renderer.entity; import electroblob.wizardry.client.DrawingUtils; -import electroblob.wizardry.entity.construct.EntityHealAura; import electroblob.wizardry.entity.construct.EntityMagicConstruct; import electroblob.wizardry.util.AllyDesignationSystem; import net.minecraft.client.Minecraft; @@ -19,13 +18,13 @@ import org.lwjgl.opengl.GL11; public class RenderSigil extends Render { private final ResourceLocation texture; - private float scale; + private float rotationSpeed; private boolean invisibleToEnemies; - public RenderSigil(RenderManager renderManager, ResourceLocation texture, float scale, boolean invisibleToEnemies){ + public RenderSigil(RenderManager renderManager, ResourceLocation texture, float rotationSpeed, boolean invisibleToEnemies){ super(renderManager); this.texture = texture; - this.scale = scale; + this.rotationSpeed = rotationSpeed; this.invisibleToEnemies = invisibleToEnemies; } @@ -35,8 +34,8 @@ public class RenderSigil extends Render { // Makes the sigil invisible to enemies of the player that created it if(this.invisibleToEnemies){ // Unfortunately we can't access the caster's allies if they're not online, it only works the other way round - if(entity.getCaster() instanceof EntityPlayer && !AllyDesignationSystem - .isPlayerAlly((EntityPlayer)entity.getCaster(), Minecraft.getMinecraft().player)){ + if(entity.getCaster() != Minecraft.getMinecraft().player && entity.getCaster() instanceof EntityPlayer + && !AllyDesignationSystem.isPlayerAlly((EntityPlayer)entity.getCaster(), Minecraft.getMinecraft().player)){ return; } } @@ -59,10 +58,10 @@ public class RenderSigil extends Render { GlStateManager.rotate(-90, 1, 0, 0); // Healing aura rotates slowly - if(entity instanceof EntityHealAura) GlStateManager.rotate(entity.ticksExisted / 3.0f, 0, 0, 1); + if(rotationSpeed != 0) GlStateManager.rotate(entity.ticksExisted * rotationSpeed, 0, 0, 1); - float s = DrawingUtils.smoothScaleFactor(entity.lifetime, entity.ticksExisted, partialTicks, 10, 10); - GlStateManager.scale(scale * s, scale * s, scale * s); + float s = entity.width * DrawingUtils.smoothScaleFactor(entity.lifetime, entity.ticksExisted, partialTicks, 10, 10); + GlStateManager.scale(s, s, s); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.getBuffer(); diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityArrowRain.java b/src/main/java/electroblob/wizardry/entity/construct/EntityArrowRain.java index 9f26e85b..98033d36 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityArrowRain.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityArrowRain.java @@ -1,17 +1,23 @@ package electroblob.wizardry.entity.construct; +import electroblob.wizardry.registry.Spells; +import electroblob.wizardry.spell.Spell; import net.minecraft.entity.projectile.EntityTippedArrow; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -public class EntityArrowRain extends EntityMagicConstruct { +public class EntityArrowRain extends EntityScaledConstruct { public EntityArrowRain(World world){ super(world); - this.height = 3.0f; - this.width = 5.0f; + setSize(Spells.arrow_rain.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 5); + } + + @Override + protected boolean shouldScaleHeight(){ + return false; } public void onUpdate(){ @@ -19,14 +25,21 @@ public class EntityArrowRain extends EntityMagicConstruct { super.onUpdate(); if(!this.world.isRemote){ - EntityTippedArrow arrow = new EntityTippedArrow(world, this.posX + rand.nextDouble() * 6 - 3, - this.posY + rand.nextDouble() * 4 - 2, this.posZ + rand.nextDouble() * 6 - 3); + + double x = posX + (world.rand.nextDouble() - 0.5D) * (double)width; + double y = posY + world.rand.nextDouble() * (double)height; + double z = posZ + (world.rand.nextDouble() - 0.5D) * (double)width; + + EntityTippedArrow arrow = new EntityTippedArrow(world, x, y, z); + arrow.motionX = MathHelper.cos((float)Math.toRadians(this.rotationYaw + 90)); arrow.motionY = -0.6; arrow.motionZ = MathHelper.sin((float)Math.toRadians(this.rotationYaw + 90)); + arrow.shootingEntity = this.getCaster(); arrow.setDamage(7.0d * damageMultiplier); arrow.setPotionEffect(new ItemStack(Items.ARROW)); + this.world.spawnEntity(arrow); } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityBlackHole.java b/src/main/java/electroblob/wizardry/entity/construct/EntityBlackHole.java index 2e1b3663..27938bd4 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityBlackHole.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityBlackHole.java @@ -3,8 +3,10 @@ package electroblob.wizardry.entity.construct; import electroblob.wizardry.Wizardry; import electroblob.wizardry.entity.EntityLevitatingBlock; import electroblob.wizardry.item.ItemArtefact; +import electroblob.wizardry.registry.Spells; import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.registry.WizardrySounds; +import electroblob.wizardry.spell.Spell; import electroblob.wizardry.util.BlockUtils; import electroblob.wizardry.util.EntityUtils; import electroblob.wizardry.util.MagicDamage; @@ -27,7 +29,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class EntityBlackHole extends EntityMagicConstruct { +public class EntityBlackHole extends EntityScaledConstruct { private static final double SUCTION_STRENGTH = 0.075; /** The maximum number of blocks that can be unhooked each tick, reduces lag from excessive numbers of entities. */ @@ -38,8 +40,8 @@ public class EntityBlackHole extends EntityMagicConstruct { public EntityBlackHole(World world){ super(world); - this.width = 6.0f; - this.height = 3.0f; + float r = Spells.black_hole.getProperty(Spell.EFFECT_RADIUS).floatValue(); + setSize(r * 2, r); randomiser = new int[30]; for(int i = 0; i < randomiser.length; i++){ randomiser[i] = this.rand.nextInt(10); @@ -91,7 +93,7 @@ public class EntityBlackHole extends EntityMagicConstruct { if(!this.world.isRemote){ - double radius = 6; // TODO: Support for spell properties and modifiers + double radius = 6 * sizeMultiplier; // TODO: Support for spell properties boolean suckInBlocks = getCaster() instanceof EntityPlayer && EntityUtils.canDamageBlocks(getCaster(), world) && ItemArtefact.isArtefactActive((EntityPlayer)getCaster(), WizardryItems.charm_black_hole); diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityBlizzard.java b/src/main/java/electroblob/wizardry/entity/construct/EntityBlizzard.java index a60621f5..d03760b2 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityBlizzard.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityBlizzard.java @@ -16,12 +16,18 @@ import net.minecraft.world.World; import java.util.List; -public class EntityBlizzard extends EntityMagicConstruct { +public class EntityBlizzard extends EntityScaledConstruct { public EntityBlizzard(World world){ super(world); - this.height = 1.0f; - this.width = 1.0f; + // TODO: Set the size properly and do whatever forcefield does to allow block and entity interaction inside it + // (Probably need to do this for several others too) + setSize(Spells.blizzard.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 3); + } + + @Override + protected boolean shouldScaleHeight(){ + return false; } public void onUpdate(){ @@ -34,7 +40,7 @@ public class EntityBlizzard extends EntityMagicConstruct { // This is a good example of why you might define a spell base property without necessarily using it in the // spell - in fact, blizzard doesn't even have a spell class (yet) - double radius = Spells.blizzard.getProperty(Spell.EFFECT_RADIUS).doubleValue(); + double radius = Spells.blizzard.getProperty(Spell.EFFECT_RADIUS).doubleValue() * sizeMultiplier; if(!this.world.isRemote){ @@ -64,13 +70,13 @@ public class EntityBlizzard extends EntityMagicConstruct { for(int i=0; i<6; i++){ double speed = (rand.nextBoolean() ? 1 : -1) * (0.1 + 0.05 * rand.nextDouble()); - ParticleBuilder.create(Type.SNOW).pos(this.posX, this.posY + rand.nextDouble() * 3, this.posZ).vel(0, 0, 0) + ParticleBuilder.create(Type.SNOW).pos(this.posX, this.posY + rand.nextDouble() * height, this.posZ).vel(0, 0, 0) .time(100).scale(2).spin(rand.nextDouble() * (radius - 0.5) + 0.5, speed).shaded(true).spawn(world); } for(int i=0; i<3; i++){ double speed = (rand.nextBoolean() ? 1 : -1) * (0.05 + 0.02 * rand.nextDouble()); - ParticleBuilder.create(Type.CLOUD).pos(this.posX, this.posY + rand.nextDouble() * 2.5, this.posZ) + ParticleBuilder.create(Type.CLOUD).pos(this.posX, this.posY + rand.nextDouble() * (height - 0.5), this.posZ) .clr(0xffffff).shaded(true).spin(rand.nextDouble() * (radius - 1) + 0.5, speed).spawn(world); } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityCombustionRune.java b/src/main/java/electroblob/wizardry/entity/construct/EntityCombustionRune.java index 68205f57..5930b2dd 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityCombustionRune.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityCombustionRune.java @@ -10,12 +10,21 @@ import net.minecraft.world.World; import java.util.List; -public class EntityCombustionRune extends EntityMagicConstruct { +public class EntityCombustionRune extends EntityScaledConstruct { public EntityCombustionRune(World world){ super(world); - this.height = 0.2f; - this.width = 2.0f; + setSize(2, 0.2f); + } + + @Override + protected boolean shouldScaleWidth(){ + return false; // We're using the blast modifier for an actual explosion here, rather than the entity size + } + + @Override + protected boolean shouldScaleHeight(){ + return false; } @Override @@ -31,7 +40,7 @@ public class EntityCombustionRune extends EntityMagicConstruct { if(this.isValidTarget(target)){ - float strength = Spells.combustion_rune.getProperty(Spell.BLAST_RADIUS).floatValue(); + float strength = Spells.combustion_rune.getProperty(Spell.BLAST_RADIUS).floatValue() * sizeMultiplier; world.newExplosion(this.getCaster(), this.posX, this.posY, this.posZ, strength, true, getCaster() != null && EntityUtils.canDamageBlocks(getCaster(), world)); @@ -48,9 +57,6 @@ public class EntityCombustionRune extends EntityMagicConstruct { } } - @Override - protected void entityInit(){} - @Override public boolean canRenderOnFire(){ return false; diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityDecay.java b/src/main/java/electroblob/wizardry/entity/construct/EntityDecay.java index 98fe3839..6a35a03e 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityDecay.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityDecay.java @@ -17,7 +17,7 @@ import java.util.List; public class EntityDecay extends EntityMagicConstruct { - public int textureIndex = 0; + public int textureIndex; public EntityDecay(World world){ super(world); @@ -62,8 +62,7 @@ public class EntityDecay extends EntityMagicConstruct { } } - @Override protected void entityInit(){} - + // TESTME: What the heck are these two doing?! (Are they a throwback to when this was not a construct?) @Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound){} @Override protected void writeEntityToNBT(NBTTagCompound nbttagcompound){} diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityEarthquake.java b/src/main/java/electroblob/wizardry/entity/construct/EntityEarthquake.java index 0e6c4426..d97c191b 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityEarthquake.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityEarthquake.java @@ -18,12 +18,11 @@ import net.minecraft.world.World; import java.util.List; -public class EntityEarthquake extends EntityMagicConstruct { +public class EntityEarthquake extends EntityMagicConstruct { // NOT a scaled construct, the size is controlled by time public EntityEarthquake(World world){ super(world); - this.height = 1.0f; - this.width = 1.0f; + setSize(1, 1); // This one probably should be small } public void onUpdate(){ diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityFireRing.java b/src/main/java/electroblob/wizardry/entity/construct/EntityFireRing.java index de2f7134..b23a744b 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityFireRing.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityFireRing.java @@ -12,14 +12,16 @@ import net.minecraft.world.World; import java.util.List; -public class EntityFireRing extends EntityMagicConstruct { - - // TODO: Implement blast modifiers +public class EntityFireRing extends EntityScaledConstruct { public EntityFireRing(World world){ super(world); - this.height = 1.0f; - this.width = 5.0f; + setSize(Spells.ring_of_fire.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 1); + } + + @Override + protected boolean shouldScaleHeight(){ + return false; } public void onUpdate(){ @@ -32,8 +34,7 @@ public class EntityFireRing extends EntityMagicConstruct { if(!this.world.isRemote){ - List targets = EntityUtils.getLivingWithinRadius(2.5d, this.posX, this.posY, - this.posZ, this.world); + List targets = EntityUtils.getLivingWithinRadius(width/2, this.posX, this.posY, this.posZ, this.world); for(EntityLivingBase target : targets){ diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityFireSigil.java b/src/main/java/electroblob/wizardry/entity/construct/EntityFireSigil.java index 87a624af..de3de2b6 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityFireSigil.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityFireSigil.java @@ -14,12 +14,17 @@ import net.minecraft.world.World; import java.util.List; -public class EntityFireSigil extends EntityMagicConstruct { +// TODO: Try to collect sigils into one superclass +public class EntityFireSigil extends EntityScaledConstruct { public EntityFireSigil(World world){ super(world); - this.height = 0.2f; - this.width = 2.0f; + setSize(Spells.fire_sigil.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 0.2f); + } + + @Override + protected boolean shouldScaleHeight(){ + return false; } @Override @@ -59,16 +64,13 @@ public class EntityFireSigil extends EntityMagicConstruct { } } }else if(this.rand.nextInt(15) == 0){ - double radius = 0.5 + rand.nextDouble() * 0.3; - float angle = rand.nextFloat() * (float)Math.PI * 2;; + double radius = (0.5 + rand.nextDouble() * 0.3) * width/2; + float angle = rand.nextFloat() * (float)Math.PI * 2; world.spawnParticle(EnumParticleTypes.FLAME, this.posX + radius * MathHelper.cos(angle), this.posY + 0.1, this.posZ + radius * MathHelper.sin(angle), 0, 0, 0); } } - @Override - protected void entityInit(){} - @Override public boolean canRenderOnFire(){ return false; diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityForcefield.java b/src/main/java/electroblob/wizardry/entity/construct/EntityForcefield.java index b06de2a2..d118d016 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityForcefield.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityForcefield.java @@ -6,16 +6,19 @@ import electroblob.wizardry.entity.projectile.EntityMagicArrow; import electroblob.wizardry.item.ItemArtefact; import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.registry.WizardrySounds; -import electroblob.wizardry.util.*; +import electroblob.wizardry.util.EntityUtils; +import electroblob.wizardry.util.GeometryUtils; +import electroblob.wizardry.util.MagicDamage; +import electroblob.wizardry.util.ParticleBuilder; import electroblob.wizardry.util.ParticleBuilder.Type; import io.netty.buffer.ByteBuf; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.SPacketEntityVelocity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.MathHelper; @@ -32,6 +35,7 @@ import java.util.Arrays; import java.util.Comparator; import java.util.List; +// TODO: Possibly convert this to EntityScaledConstruct @Mod.EventBusSubscriber public class EntityForcefield extends EntityMagicConstruct implements ICustomHitbox { @@ -63,16 +67,6 @@ public class EntityForcefield extends EntityMagicConstruct implements ICustomHit return radius; } - @Override - public boolean canBeCollidedWith(){ - return false;//!this.isDead; - } - - @Override - public AxisAlignedBB getCollisionBox(Entity entity){ - return null;//entity.getEntityBoundingBox(); - } - @Nullable @Override public AxisAlignedBB getCollisionBoundingBox(){ @@ -244,31 +238,28 @@ public class EntityForcefield extends EntityMagicConstruct implements ICustomHit return closestPoint.subtract(line.normalize().scale(MathHelper.sqrt(rsquared - dsquared))); } - // Need to sync the caster because we're now dealing with client-side motion - @Override public void writeSpawnData(ByteBuf data){ super.writeSpawnData(data); data.writeFloat(getRadius()); - if(getCaster() != null) data.writeInt(getCaster().getEntityId()); } @Override public void readSpawnData(ByteBuf data){ - super.readSpawnData(data); - setRadius(data.readFloat()); + } - if(!data.isReadable()) return; + @Override + protected void writeEntityToNBT(NBTTagCompound nbt){ + super.writeEntityToNBT(nbt); + nbt.setFloat("radius", radius); + } - Entity entity = world.getEntityByID(data.readInt()); - - if(entity instanceof EntityLivingBase){ - setCaster((EntityLivingBase)entity); - }else{ - Wizardry.logger.warn("Forcefield caster with ID in spawn data not found"); - } + @Override + protected void readEntityFromNBT(NBTTagCompound nbt){ + super.readEntityFromNBT(nbt); + radius = nbt.getFloat("radius"); } @Override diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityFrostSigil.java b/src/main/java/electroblob/wizardry/entity/construct/EntityFrostSigil.java index a32cb98b..fc08e7d9 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityFrostSigil.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityFrostSigil.java @@ -17,12 +17,16 @@ import net.minecraft.world.World; import java.util.List; -public class EntityFrostSigil extends EntityMagicConstruct { +public class EntityFrostSigil extends EntityScaledConstruct { public EntityFrostSigil(World world){ super(world); - this.height = 0.2f; - this.width = 2.0f; + setSize(Spells.frost_sigil.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 0.2f); + } + + @Override + protected boolean shouldScaleHeight(){ + return false; } @Override @@ -32,7 +36,7 @@ public class EntityFrostSigil extends EntityMagicConstruct { if(!this.world.isRemote){ - List targets = EntityUtils.getLivingWithinRadius(1.0d, this.posX, this.posY, + List targets = EntityUtils.getLivingWithinRadius(width/2, this.posX, this.posY, this.posZ, this.world); for(EntityLivingBase target : targets){ @@ -56,8 +60,8 @@ public class EntityFrostSigil extends EntityMagicConstruct { } } }else if(this.rand.nextInt(15) == 0){ - double radius = 0.5 + rand.nextDouble() * 0.3; - float angle = rand.nextFloat() * (float)Math.PI * 2;; + double radius = (0.5 + rand.nextDouble() * 0.3) * width/2; + float angle = rand.nextFloat() * (float)Math.PI * 2; ParticleBuilder.create(Type.SNOW) .pos(this.posX + radius * MathHelper.cos(angle), this.posY + 0.1, this.posZ + radius * MathHelper.sin(angle)) .vel(0, 0, 0) // Required since default for snow is not stationary @@ -65,9 +69,6 @@ public class EntityFrostSigil extends EntityMagicConstruct { } } - @Override - protected void entityInit(){} - @Override public boolean canRenderOnFire(){ return false; diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityHailstorm.java b/src/main/java/electroblob/wizardry/entity/construct/EntityHailstorm.java index f792d4ef..599ae80f 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityHailstorm.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityHailstorm.java @@ -1,15 +1,21 @@ package electroblob.wizardry.entity.construct; import electroblob.wizardry.entity.projectile.EntityIceShard; +import electroblob.wizardry.registry.Spells; +import electroblob.wizardry.spell.Spell; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -public class EntityHailstorm extends EntityMagicConstruct { +public class EntityHailstorm extends EntityScaledConstruct { public EntityHailstorm(World world){ super(world); - this.height = 3.0f; - this.width = 5.0f; + setSize(Spells.hailstorm.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 5); + } + + @Override + protected boolean shouldScaleHeight(){ + return false; } public void onUpdate(){ @@ -17,15 +23,21 @@ public class EntityHailstorm extends EntityMagicConstruct { super.onUpdate(); if(!this.world.isRemote){ - // System.out.println(this.rotationYaw); + + double x = posX + (world.rand.nextDouble() - 0.5D) * (double)width; + double y = posY + world.rand.nextDouble() * (double)height; + double z = posZ + (world.rand.nextDouble() - 0.5D) * (double)width; + EntityIceShard iceshard = new EntityIceShard(world); - iceshard.setPosition(this.posX + rand.nextDouble() * 6 - 3, this.posY + rand.nextDouble() * 4 - 2, - this.posZ + rand.nextDouble() * 6 - 3); + iceshard.setPosition(x, y, z); + iceshard.motionX = MathHelper.cos((float)Math.toRadians(this.rotationYaw + 90)); iceshard.motionY = -0.6; iceshard.motionZ = MathHelper.sin((float)Math.toRadians(this.rotationYaw + 90)); + iceshard.setCaster(this.getCaster()); iceshard.damageMultiplier = this.damageMultiplier; + this.world.spawnEntity(iceshard); } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityHealAura.java b/src/main/java/electroblob/wizardry/entity/construct/EntityHealAura.java index 0901896d..d887eabe 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityHealAura.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityHealAura.java @@ -15,14 +15,11 @@ import net.minecraft.world.World; import java.util.List; -public class EntityHealAura extends EntityMagicConstruct { - - // TODO: Implement blast modifiers +public class EntityHealAura extends EntityScaledConstruct { public EntityHealAura(World world){ super(world); - this.height = 1.0f; - this.width = 5.0f; + setSize(Spells.healing_aura.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 1); } @Override @@ -36,7 +33,7 @@ public class EntityHealAura extends EntityMagicConstruct { if(!this.world.isRemote){ - List targets = EntityUtils.getLivingWithinRadius(2.5, posX, posY, posZ, world); + List targets = EntityUtils.getLivingWithinRadius(width/2, posX, posY, posZ, world); for(EntityLivingBase target : targets){ @@ -69,8 +66,8 @@ public class EntityHealAura extends EntityMagicConstruct { }else{ for(int i=1; i<3; i++){ float brightness = 0.5f + (rand.nextFloat() * 0.5f); - double radius = rand.nextDouble() * 2.0; - float angle = rand.nextFloat() * (float)Math.PI * 2;; + double radius = rand.nextDouble() * (width/2); + float angle = rand.nextFloat() * (float)Math.PI * 2; ParticleBuilder.create(Type.SPARKLE) .pos(this.posX + radius * MathHelper.cos(angle), this.posY, this.posZ + radius * MathHelper.sin(angle)) .vel(0, 0.05, 0) diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityIceSpike.java b/src/main/java/electroblob/wizardry/entity/construct/EntityIceSpike.java index 1a3d29d5..dcccb4cd 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityIceSpike.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityIceSpike.java @@ -63,7 +63,8 @@ public class EntityIceSpike extends EntityMagicConstruct { for(Object entity : this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox())){ if(entity instanceof EntityLivingBase && this.isValidTarget((EntityLivingBase)entity)){ DamageSource source = this.getCaster() == null ? DamageSource.MAGIC : MagicDamage.causeDirectMagicDamage(this.getCaster(), DamageType.FROST); - // Potion effect only gets added if the damage succeeded. + // Potion effect only gets added if the damage succeeded + // We DO want knockback here or the entity gets stuck on the spike, which is a bit of a cheat if(((EntityLivingBase)entity).attackEntityFrom(source, Spells.ice_spikes.getProperty(Spell.DAMAGE).floatValue() * this.damageMultiplier)) ((EntityLivingBase)entity).addPotionEffect(new PotionEffect(WizardryPotions.frost, Spells.ice_spikes.getProperty(Spell.EFFECT_DURATION).intValue(), diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityLightningSigil.java b/src/main/java/electroblob/wizardry/entity/construct/EntityLightningSigil.java index f8159198..197497f7 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityLightningSigil.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityLightningSigil.java @@ -15,14 +15,19 @@ import net.minecraft.world.World; import java.util.List; -public class EntityLightningSigil extends EntityMagicConstruct { +public class EntityLightningSigil extends EntityScaledConstruct { + public static final String SECONDARY_RANGE = "secondary_range"; public static final String SECONDARY_MAX_TARGETS = "secondary_max_targets"; public EntityLightningSigil(World world){ super(world); - this.height = 0.2f; - this.width = 2.0f; + setSize(Spells.frost_sigil.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 0.2f); + } + + @Override + protected boolean shouldScaleHeight(){ + return false; } @Override @@ -34,7 +39,7 @@ public class EntityLightningSigil extends EntityMagicConstruct { this.setDead(); } - List targets = EntityUtils.getLivingWithinRadius(1.0d, this.posX, this.posY, + List targets = EntityUtils.getLivingWithinRadius(width/2, this.posX, this.posY, this.posZ, this.world); for(EntityLivingBase target : targets){ @@ -58,7 +63,7 @@ public class EntityLightningSigil extends EntityMagicConstruct { this.playSound(WizardrySounds.ENTITY_LIGHTNING_SIGIL_TRIGGER, 1.0f, 1.0f); // Secondary chaining effect - double seekerRange = Spells.lightning_sigil.getProperty(Spell.EFFECT_RADIUS).doubleValue(); + double seekerRange = Spells.lightning_sigil.getProperty(SECONDARY_RANGE).doubleValue(); List secondaryTargets = EntityUtils.getLivingWithinRadius(seekerRange, target.posX, target.posY + target.height / 2, target.posZ, world); @@ -96,8 +101,8 @@ public class EntityLightningSigil extends EntityMagicConstruct { } if(this.world.isRemote && this.rand.nextInt(15) == 0){ - double radius = 0.5 + rand.nextDouble() * 0.3; - float angle = rand.nextFloat() * (float)Math.PI * 2;; + double radius = (0.5 + rand.nextDouble() * 0.3) * width/2; + float angle = rand.nextFloat() * (float)Math.PI * 2; ParticleBuilder.create(Type.SPARK) .pos(this.posX + radius * MathHelper.cos(angle), this.posY + 0.1, this.posZ + radius * MathHelper.sin(angle)) .spawn(world); diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityMagicConstruct.java b/src/main/java/electroblob/wizardry/entity/construct/EntityMagicConstruct.java index f3165aa7..08a8caa8 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityMagicConstruct.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityMagicConstruct.java @@ -24,13 +24,10 @@ import javax.annotation.Nullable; import java.util.UUID; /** - * This class is for all inanimate magical constructs which are not projectiles. It was made from scratch to provide a - * unifying superclass for black hole, blizzard, tornado and a few others which all share some characteristics. The - * caster UUID, lifetime and damage multiplier are stored here, and lifetime is also synced here. - *

- * When extending this class, override both constructors. Generally speaking, subclasses of this class are areas of - * effect which deal damage or apply effects over time. - * + * This class is for all inanimate magical constructs which are not projectiles. Generally speaking, subclasses of this + * class are areas of effect which deal damage or apply effects over time, including black hole, blizzard, tornado and + * a few others. The caster UUID, lifetime and damage multiplier are stored here, and lifetime is also synced here. + * * @since Wizardry 1.0 */ public abstract class EntityMagicConstruct extends Entity implements IEntityOwnable, IEntityAdditionalSpawnData { @@ -40,10 +37,8 @@ public abstract class EntityMagicConstruct extends Entity implements IEntityOwna * {@link EntityMagicConstruct#getCaster()}. */ private UUID casterUUID; - /** - * The time in ticks this magical construct lasts for; defaults to 600 (30 seconds). If this is -1 the construct - * doesn't despawn. - */ + /** The time in ticks this magical construct lasts for; defaults to 600 (30 seconds). If this is -1 the construct + * doesn't despawn. */ public int lifetime = 600; /** The damage multiplier for this construct, determined by the wand with which it was cast. */ @@ -78,6 +73,7 @@ public abstract class EntityMagicConstruct extends Entity implements IEntityOwna @Override public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand){ + // Permanent constructs can now be dispelled by sneak-right-clicking if(lifetime == -1 && getCaster() == player && player.isSneaking() && player.getHeldItem(hand).getItem() instanceof ISpellCastingItem){ this.despawn(); return EnumActionResult.SUCCESS; @@ -98,7 +94,7 @@ public abstract class EntityMagicConstruct extends Entity implements IEntityOwna @Override protected void entityInit(){ - + // We could leave this unimplemented, but since the majority of subclasses don't use it, let's make it optional } @Override diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityRadiantTotem.java b/src/main/java/electroblob/wizardry/entity/construct/EntityRadiantTotem.java index 9a43cc4f..75b00cdd 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityRadiantTotem.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityRadiantTotem.java @@ -19,13 +19,23 @@ import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; -public class EntityRadiantTotem extends EntityMagicConstruct { +public class EntityRadiantTotem extends EntityScaledConstruct { private static final int PERIMETER_PARTICLE_DENSITY = 6; public EntityRadiantTotem(World world){ super(world); - this.setSize(1, 1); + this.setSize(1, 1); // This entity is different in that its area of effect is kind of 'outside' it + } + + @Override + protected boolean shouldScaleWidth(){ + return false; + } + + @Override + protected boolean shouldScaleHeight(){ + return false; } @Override @@ -37,7 +47,7 @@ public class EntityRadiantTotem extends EntityMagicConstruct { super.onUpdate(); - double radius = Spells.radiant_totem.getProperty(Spell.EFFECT_RADIUS).floatValue(); // TODO: Blast modifiers + double radius = Spells.radiant_totem.getProperty(Spell.EFFECT_RADIUS).floatValue() * sizeMultiplier; if(world.isRemote){ diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityScaledConstruct.java b/src/main/java/electroblob/wizardry/entity/construct/EntityScaledConstruct.java new file mode 100644 index 00000000..9e37ce7e --- /dev/null +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityScaledConstruct.java @@ -0,0 +1,68 @@ +package electroblob.wizardry.entity.construct; + +import io.netty.buffer.ByteBuf; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +/** + * Extension of {@link EntityMagicConstruct} that implements saving and loading of size (blast) multipliers. What + * the entity actually does with the multiplier value is up to subclasses to define; however, by default this class + * scales the entity bounding box according to the size multiplier (this can be controlled by overriding + * {@link EntityScaledConstruct#shouldScaleWidth()} and {@link EntityScaledConstruct#shouldScaleHeight()}). + * + * @author Electroblob + * @since Wizardry 4.3 + */ +public abstract class EntityScaledConstruct extends EntityMagicConstruct { + + /** The size multiplier for this construct, usually determined by the blast modifier the spell was cast with. */ + protected float sizeMultiplier = 1; + + public EntityScaledConstruct(World world){ + super(world); + } + + public float getSizeMultiplier(){ + return sizeMultiplier; + } + + public void setSizeMultiplier(float sizeMultiplier){ + this.sizeMultiplier = sizeMultiplier; + setSize(shouldScaleWidth() ? width * sizeMultiplier : width, shouldScaleHeight() ? height * sizeMultiplier : height); + } + + /** Returns true if the width of this entity's bounding box should be scaled by the size multiplier on creation. */ + protected boolean shouldScaleWidth(){ + return true; + } + + /** Returns true if the height of this entity's bounding box should be scaled by the size multiplier on creation. */ + protected boolean shouldScaleHeight(){ + return true; + } + + @Override + protected void readEntityFromNBT(NBTTagCompound nbt){ + super.readEntityFromNBT(nbt); + setSizeMultiplier(nbt.getFloat("sizeMultiplier")); + } + + @Override + protected void writeEntityToNBT(NBTTagCompound nbt){ + super.writeEntityToNBT(nbt); + nbt.setFloat("sizeMultiplier", sizeMultiplier); + + } + + @Override + public void readSpawnData(ByteBuf data){ + super.readSpawnData(data); + setSizeMultiplier(data.readFloat()); // Set the width correctly on the client side + } + + @Override + public void writeSpawnData(ByteBuf data){ + super.writeSpawnData(data); + data.writeFloat(sizeMultiplier); + } +} diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityStormcloud.java b/src/main/java/electroblob/wizardry/entity/construct/EntityStormcloud.java index ea1e851d..2f034c7f 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityStormcloud.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityStormcloud.java @@ -1,6 +1,5 @@ package electroblob.wizardry.entity.construct; -import electroblob.wizardry.Wizardry; import electroblob.wizardry.registry.Spells; import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.spell.Spell; @@ -8,47 +7,27 @@ import electroblob.wizardry.util.EntityUtils; import electroblob.wizardry.util.MagicDamage; import electroblob.wizardry.util.ParticleBuilder; import electroblob.wizardry.util.ParticleBuilder.Type; -import io.netty.buffer.ByteBuf; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.world.World; import java.util.List; -public class EntityStormcloud extends EntityMagicConstruct { - -// private static final DataParameter RADIUS = new DataParameter<>(21, DataSerializers.FLOAT); +public class EntityStormcloud extends EntityScaledConstruct { public EntityStormcloud(World world){ super(world); - this.height = 2.0f; - this.width = Spells.stormcloud.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2; + setSize(Spells.stormcloud.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 2); } -// @Override -// protected void entityInit(){ -// super.entityInit(); -// this.getDataManager().register(RADIUS, width); // TODO: This doesn't work, implement blast modifiers properly into SpellConstruct -// } - -// public void multiplyWidth(float multiplier){ -// this.setSize(width * multiplier, height); -// this.getDataManager().set(RADIUS, width); -// } + @Override + protected boolean shouldScaleHeight(){ + return false; + } public void onUpdate(){ super.onUpdate(); -// if(world.isRemote){ -// float radius = this.getDataManager().get(RADIUS); -// if(radius != width) this.setSize(radius, height); -// }else{ -// if(this.getDataManager().get(RADIUS) != width) this.getDataManager().set(RADIUS, width); -// } - -// if(this.ticksExisted % 35 == 0) this.playSound(WizardrySounds.ENTITY_STORMCLOUD_AMBIENT, 1, 1); - if(this.world.isRemote){ float areaFactor = (width * width) / 36; // Ensures cloud/raindrop density stays the same for different sizes @@ -83,16 +62,6 @@ public class EntityStormcloud extends EntityMagicConstruct { } } -// BlockPos pos = new BlockPos(this); -// -// for(int x = -(int)(this.width/2); x <= this.width/2 + 0.5; x++){ -// for(int z = -(int)(this.width/2); z <= this.width/2 + 0.5; z++){ -// -// int y = WizardryUtilities.getNearestFloor() -// -// } -// } - } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityTornado.java b/src/main/java/electroblob/wizardry/entity/construct/EntityTornado.java index f150e52c..581b9663 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityTornado.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityTornado.java @@ -7,8 +7,11 @@ import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.spell.Spell; import electroblob.wizardry.spell.Tornado; -import electroblob.wizardry.util.*; +import electroblob.wizardry.util.BlockUtils; +import electroblob.wizardry.util.EntityUtils; +import electroblob.wizardry.util.MagicDamage; import electroblob.wizardry.util.MagicDamage.DamageType; +import electroblob.wizardry.util.ParticleBuilder; import electroblob.wizardry.util.ParticleBuilder.Type; import io.netty.buffer.ByteBuf; import net.minecraft.block.material.Material; @@ -27,17 +30,21 @@ import net.minecraft.world.World; import java.util.List; -public class EntityTornado extends EntityMagicConstruct { +public class EntityTornado extends EntityScaledConstruct { private double velX, velZ; public EntityTornado(World world){ super(world); - this.height = 8.0f; - this.width = 5.0f; + setSize(Spells.tornado.getProperty(Spell.EFFECT_RADIUS).floatValue(), 8); this.isImmuneToFire = false; } - + + @Override + protected boolean shouldScaleHeight(){ + return false; + } + public void setHorizontalVelocity(double velX, double velZ){ this.velX = velX; this.velZ = velZ; @@ -48,7 +55,7 @@ public class EntityTornado extends EntityMagicConstruct { super.onUpdate(); - double radius = Spells.tornado.getProperty(Spell.EFFECT_RADIUS).doubleValue(); + double radius = width/2; if(this.ticksExisted % 120 == 1 && world.isRemote){ // Repeat is false so that the sound fades out when the tornado does rather than stopping suddenly diff --git a/src/main/java/electroblob/wizardry/registry/Spells.java b/src/main/java/electroblob/wizardry/registry/Spells.java index d4f27671..159c9bbe 100644 --- a/src/main/java/electroblob/wizardry/registry/Spells.java +++ b/src/main/java/electroblob/wizardry/registry/Spells.java @@ -275,17 +275,17 @@ public final class Spells { registry.register(new SpellProjectile<>("fireball", EntityMagicFireball::new).addProperties(Spell.DAMAGE, Spell.BURN_DURATION));//new Fireball()); registry.register(new FlameRay()); registry.register(new SpellProjectile<>("firebomb", EntityFirebomb::new).addProperties(Spell.DIRECT_DAMAGE, Spell.SPLASH_DAMAGE, Spell.BLAST_RADIUS, Spell.BURN_DURATION).soundValues(0.5f, 0.4f, 0.2f)); - registry.register(new SpellConstructRanged<>("fire_sigil", EntityFireSigil::new, true).floor(true).addProperties(Spell.DAMAGE, Spell.BURN_DURATION)); + registry.register(new SpellConstructRanged<>("fire_sigil", EntityFireSigil::new, true).floor(true).addProperties(Spell.EFFECT_RADIUS, Spell.DAMAGE, Spell.BURN_DURATION)); registry.register(new SpellProjectile<>("firebolt", EntityFirebolt::new).addProperties(Spell.DAMAGE, Spell.BURN_DURATION)); registry.register(new FrostRay()); registry.register(new SummonSnowGolem()); registry.register(new SpellArrow<>("ice_shard", EntityIceShard::new).addProperties(Spell.DAMAGE, Spell.EFFECT_DURATION, Spell.EFFECT_STRENGTH).soundValues(1, 1.6f, 0.4f)); registry.register(new IceStatue()); - registry.register(new SpellConstructRanged<>("frost_sigil", EntityFrostSigil::new, true).floor(true).addProperties(Spell.DAMAGE, Spell.EFFECT_DURATION, Spell.EFFECT_STRENGTH)); + registry.register(new SpellConstructRanged<>("frost_sigil", EntityFrostSigil::new, true).floor(true).addProperties(Spell.EFFECT_RADIUS, Spell.DAMAGE, Spell.EFFECT_DURATION, Spell.EFFECT_STRENGTH)); registry.register(new LightningRay()); registry.register(new SpellProjectile<>("spark_bomb", EntitySparkBomb::new).addProperties(Spell.DIRECT_DAMAGE, Spell.EFFECT_RADIUS, EntitySparkBomb.SECONDARY_MAX_TARGETS, Spell.SPLASH_DAMAGE).soundValues(0.5f, 0.4f, 0.2f)); registry.register(new SpellProjectile<>("homing_spark", EntitySpark::new).addProperties(Spell.DAMAGE, Spell.SEEKING_STRENGTH).soundValues(1.0f, 0.4f, 0.2f)); - registry.register(new SpellConstructRanged<>("lightning_sigil", EntityLightningSigil::new, true).floor(true).addProperties(Spell.DIRECT_DAMAGE, Spell.EFFECT_RADIUS, EntityLightningSigil.SECONDARY_MAX_TARGETS, Spell.SPLASH_DAMAGE)); + registry.register(new SpellConstructRanged<>("lightning_sigil", EntityLightningSigil::new, true).floor(true).addProperties(Spell.EFFECT_RADIUS, Spell.DIRECT_DAMAGE, Spell.EFFECT_RADIUS, EntityLightningSigil.SECONDARY_RANGE, EntityLightningSigil.SECONDARY_MAX_TARGETS, Spell.SPLASH_DAMAGE)); registry.register(new SpellArrow<>("lightning_arrow", EntityLightningArrow::new).addProperties(Spell.DAMAGE).soundValues(1, 1.45f, 0.3f)); registry.register(new LifeDrain()); registry.register(new SummonSkeleton()); @@ -309,7 +309,7 @@ public final class Spells { registry.register(new HealAlly()); registry.register(new SpellMinion<>("summon_blaze", EntityBlazeMinion::new).soundValues(1, 1.1f, 0.2f)); - registry.register(new SpellConstruct<>("ring_of_fire", SpellActions.POINT_DOWN, EntityFireRing::new, false).floor(true).addProperties(Spell.DAMAGE, Spell.BURN_DURATION)); + registry.register(new SpellConstruct<>("ring_of_fire", SpellActions.POINT_DOWN, EntityFireRing::new, false).floor(true).addProperties(Spell.EFFECT_RADIUS, Spell.DAMAGE, Spell.BURN_DURATION)); registry.register(new Detonate()); registry.register(new SpellBuff("fire_resistance", 1, 0.5f, 0, () -> MobEffects.FIRE_RESISTANCE).soundValues(0.7f, 1.2f, 0.4f)); registry.register(new SpellBuff("fireskin", 1, 0.5f, 0, () -> WizardryPotions.fireskin).addProperties(Spell.BURN_DURATION)); @@ -347,7 +347,7 @@ public final class Spells { registry.register(new PhaseStep()); registry.register(new VanishingBox()); registry.register(new GreaterHeal()); - registry.register(new SpellConstruct<>("healing_aura", SpellActions.POINT_DOWN, EntityHealAura::new, false).addProperties(Spell.DAMAGE, Spell.HEALTH)); + registry.register(new SpellConstruct<>("healing_aura", SpellActions.POINT_DOWN, EntityHealAura::new, false).addProperties(Spell.EFFECT_RADIUS, Spell.DAMAGE, Spell.HEALTH)); registry.register(new Forcefield()); registry.register(new SpellBuff("ironflesh", 0.4f, 0.5f, 0.6f, () -> MobEffects.RESISTANCE).soundValues(0.7f, 1.2f, 0.4f)); registry.register(new Transience()); @@ -366,7 +366,7 @@ public final class Spells { registry.register(new ForestsCurse()); registry.register(new Flight()); registry.register(new SpellMinion<>("silverfish_swarm", EntitySilverfishMinion::new).soundValues(1, 1.1f, 0.1f)); - registry.register(new SpellConstructRanged<>("black_hole", EntityBlackHole::new, false).soundValues(2, 0.7f, 0)); + registry.register(new SpellConstructRanged<>("black_hole", EntityBlackHole::new, false).addProperties(Spell.EFFECT_RADIUS).soundValues(2, 0.7f, 0)); registry.register(new Shockwave()); registry.register(new SummonIronGolem()); registry.register(new ArrowRain()); diff --git a/src/main/java/electroblob/wizardry/spell/ArrowRain.java b/src/main/java/electroblob/wizardry/spell/ArrowRain.java index aeb1ef78..733507d4 100644 --- a/src/main/java/electroblob/wizardry/spell/ArrowRain.java +++ b/src/main/java/electroblob/wizardry/spell/ArrowRain.java @@ -11,6 +11,7 @@ public class ArrowRain extends SpellConstructRanged { public ArrowRain(){ super("arrow_rain", EntityArrowRain::new, false); this.floor(true); + addProperties(EFFECT_RADIUS); } @Override diff --git a/src/main/java/electroblob/wizardry/spell/Hailstorm.java b/src/main/java/electroblob/wizardry/spell/Hailstorm.java index 3e67f964..51f9e81b 100644 --- a/src/main/java/electroblob/wizardry/spell/Hailstorm.java +++ b/src/main/java/electroblob/wizardry/spell/Hailstorm.java @@ -13,6 +13,7 @@ public class Hailstorm extends SpellConstructRanged { public Hailstorm(){ super("hailstorm", EntityHailstorm::new, false); this.floor(true); + addProperties(EFFECT_RADIUS); } @Override diff --git a/src/main/java/electroblob/wizardry/spell/SpellConstruct.java b/src/main/java/electroblob/wizardry/spell/SpellConstruct.java index f5cb08f7..71123fb8 100644 --- a/src/main/java/electroblob/wizardry/spell/SpellConstruct.java +++ b/src/main/java/electroblob/wizardry/spell/SpellConstruct.java @@ -2,6 +2,7 @@ package electroblob.wizardry.spell; import electroblob.wizardry.Wizardry; import electroblob.wizardry.entity.construct.EntityMagicConstruct; +import electroblob.wizardry.entity.construct.EntityScaledConstruct; import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.util.BlockUtils; import electroblob.wizardry.util.SpellModifiers; @@ -160,6 +161,7 @@ public class SpellConstruct extends Spell { construct.setCaster(caster); construct.lifetime = permanent ? -1 : (int)(getProperty(DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade)); construct.damageMultiplier = modifiers.get(SpellModifiers.POTENCY); + if(construct instanceof EntityScaledConstruct) ((EntityScaledConstruct)construct).setSizeMultiplier(modifiers.get(WizardryItems.blast_upgrade)); addConstructExtras(construct, side, caster, modifiers); // Prevents overlapping of multiple constructs of the same type. Since we have an instance here this is // very simple. The trade-off is that we have to create the entity before the spell fails, but unless diff --git a/src/main/resources/assets/ebwizardry/spells/arrow_rain.json b/src/main/resources/assets/ebwizardry/spells/arrow_rain.json index f3d3a3d9..903112d6 100644 --- a/src/main/resources/assets/ebwizardry/spells/arrow_rain.json +++ b/src/main/resources/assets/ebwizardry/spells/arrow_rain.json @@ -18,6 +18,7 @@ "cooldown": 300, "base_properties": { "range": 20, - "duration": 120 + "duration": 120, + "effect_radius": 2 } } \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/spells/black_hole.json b/src/main/resources/assets/ebwizardry/spells/black_hole.json index 22ddd6ca..eeb5f3d9 100644 --- a/src/main/resources/assets/ebwizardry/spells/black_hole.json +++ b/src/main/resources/assets/ebwizardry/spells/black_hole.json @@ -18,6 +18,7 @@ "cooldown": 400, "base_properties": { "duration": 400, - "range": 10 + "range": 10, + "effect_radius": 3 } } \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/spells/fire_sigil.json b/src/main/resources/assets/ebwizardry/spells/fire_sigil.json index 62816eca..a5b2d64e 100644 --- a/src/main/resources/assets/ebwizardry/spells/fire_sigil.json +++ b/src/main/resources/assets/ebwizardry/spells/fire_sigil.json @@ -18,6 +18,7 @@ "cooldown": 20, "base_properties": { "range": 10, + "effect_radius": 1, "damage": 6, "burn_duration": 10 } diff --git a/src/main/resources/assets/ebwizardry/spells/frost_sigil.json b/src/main/resources/assets/ebwizardry/spells/frost_sigil.json index 02770806..d80cd3fa 100644 --- a/src/main/resources/assets/ebwizardry/spells/frost_sigil.json +++ b/src/main/resources/assets/ebwizardry/spells/frost_sigil.json @@ -18,6 +18,7 @@ "cooldown": 20, "base_properties": { "range": 10, + "effect_radius": 1, "damage": 8, "effect_duration": 200, "effect_strength": 1 diff --git a/src/main/resources/assets/ebwizardry/spells/hailstorm.json b/src/main/resources/assets/ebwizardry/spells/hailstorm.json index 0d99a628..ea352cd1 100644 --- a/src/main/resources/assets/ebwizardry/spells/hailstorm.json +++ b/src/main/resources/assets/ebwizardry/spells/hailstorm.json @@ -18,6 +18,7 @@ "cooldown": 300, "base_properties": { "range": 20, - "duration": 120 + "duration": 120, + "effect_radius": 2 } } \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/spells/healing_aura.json b/src/main/resources/assets/ebwizardry/spells/healing_aura.json index 44e855bf..541f9418 100644 --- a/src/main/resources/assets/ebwizardry/spells/healing_aura.json +++ b/src/main/resources/assets/ebwizardry/spells/healing_aura.json @@ -18,6 +18,7 @@ "cooldown": 150, "base_properties": { "duration": 600, + "effect_radius": 2.5, "damage": 1, "health": 1 } diff --git a/src/main/resources/assets/ebwizardry/spells/lightning_sigil.json b/src/main/resources/assets/ebwizardry/spells/lightning_sigil.json index 77ce013f..66c44455 100644 --- a/src/main/resources/assets/ebwizardry/spells/lightning_sigil.json +++ b/src/main/resources/assets/ebwizardry/spells/lightning_sigil.json @@ -18,8 +18,9 @@ "cooldown": 20, "base_properties": { "range": 10, + "effect_radius": 1, "direct_damage": 6, - "effect_radius": 5, + "secondary_range": 1, "secondary_max_targets": 3, "splash_damage": 4 } diff --git a/src/main/resources/assets/ebwizardry/spells/ring_of_fire.json b/src/main/resources/assets/ebwizardry/spells/ring_of_fire.json index 4b31b96a..5c2d8671 100644 --- a/src/main/resources/assets/ebwizardry/spells/ring_of_fire.json +++ b/src/main/resources/assets/ebwizardry/spells/ring_of_fire.json @@ -18,6 +18,7 @@ "cooldown": 100, "base_properties": { "duration": 600, + "effect_radius": 2.5, "damage": 1, "burn_duration": 10 }