Implement blast modifier support for all applicable constructs, plus misc construct-related cleanup and fixes

This commit is contained in:
Electroblob77
2020-06-28 16:56:18 +01:00
parent 97c21b5057
commit 3a68ba8927
36 changed files with 296 additions and 201 deletions
@@ -829,18 +829,18 @@ public class ClientProxy extends CommonProxy {
// Runes on ground // Runes on ground
RenderingRegistry.registerEntityRenderingHandler(EntityHealAura.class, 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, 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, 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, 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, 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(EntityDecay.class, RenderDecay::new);
RenderingRegistry.registerEntityRenderingHandler(EntityCombustionRune.class, 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 // TESRs
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityArcaneWorkbench.class, new RenderArcaneWorkbench()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityArcaneWorkbench.class, new RenderArcaneWorkbench());
@@ -18,6 +18,7 @@ import java.util.Collections;
public class RenderBlackHole extends Render<EntityBlackHole> { public class RenderBlackHole extends Render<EntityBlackHole> {
// 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, private static final ResourceLocation RAY_TEXTURE = new ResourceLocation(Wizardry.MODID,
"textures/entity/black_hole/ray.png"); "textures/entity/black_hole/ray.png");
private static final ResourceLocation CENTRE_TEXTURE = new ResourceLocation(Wizardry.MODID, private static final ResourceLocation CENTRE_TEXTURE = new ResourceLocation(Wizardry.MODID,
@@ -65,20 +66,20 @@ public class RenderBlackHole extends Render<EntityBlackHole> {
for(int j = 0; j < 30; j++){ for(int j = 0; j < 30; j++){
float scale = 3.0f; float radius = 3.0f * entity.getSizeMultiplier();
int a = entity.randomiser[j]; int a = entity.randomiser[j];
int b = entity.randomiser2[j]; int b = entity.randomiser2[j];
int sliceAngle = 20 + a; 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 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 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 absoluteX = x1 * MathHelper.cos(31 * b);
double absoluteY = z1 * MathHelper.sin(31 * a) + x1 * MathHelper.cos(31 * a) * MathHelper.sin(31 * b); double absoluteY = z1 * MathHelper.sin(31 * a) + x1 * MathHelper.cos(31 * a) * MathHelper.sin(31 * b);
@@ -19,12 +19,10 @@ import org.lwjgl.opengl.GL11;
public class RenderFireRing extends Render<EntityFireRing> { public class RenderFireRing extends Render<EntityFireRing> {
private final ResourceLocation texture; private final ResourceLocation texture;
private float scale;
public RenderFireRing(RenderManager renderManager, ResourceLocation texture, float scale){ public RenderFireRing(RenderManager renderManager, ResourceLocation texture){
super(renderManager); super(renderManager);
this.texture = texture; this.texture = texture;
this.scale = scale;
} }
@Override @Override
@@ -48,7 +46,7 @@ public class RenderFireRing extends Render<EntityFireRing> {
GlStateManager.rotate(-90, 1, 0, 0); GlStateManager.rotate(-90, 1, 0, 0);
float s = DrawingUtils.smoothScaleFactor(entity.lifetime, entity.ticksExisted, partialTicks, 10, 10); 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(); Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer(); BufferBuilder buffer = tessellator.getBuffer();
@@ -66,20 +64,21 @@ public class RenderFireRing extends Render<EntityFireRing> {
GlStateManager.popMatrix(); GlStateManager.popMatrix();
// Fire // Fire
// TODO: Bleeeuuurugh this is disgusting must fix :0
if(s >= 1){ if(s >= 1){
GlStateManager.disableLighting(); GlStateManager.disableLighting();
TextureAtlasSprite icon = Minecraft.getMinecraft().getBlockRendererDispatcher() TextureAtlasSprite icon = Minecraft.getMinecraft().getBlockRendererDispatcher()
.getModelForState(Blocks.FIRE.getDefaultState()).getParticleTexture(); .getModelForState(Blocks.FIRE.getDefaultState()).getParticleTexture();
int sides = 16; float s1 = entity.width/5;
int sides = (int)(16 * s1);
float height = 1.0f; float height = 1.0f;
for(int k = 0; k < sides; k++){ for(int k = 0; k < sides; k++){
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y + 0.05f, (float)z); GlStateManager.translate((float)x, (float)y + 0.05f, (float)z);
float f1 = 1.0f; // GlStateManager.scale(s1, s1, s1);
GlStateManager.scale(f1, f1, f1);
float f2 = 0.5F; float f2 = 0.5F;
float f3 = 0.0F; float f3 = 0.0F;
float f4 = 0.2f; float f4 = 0.2f;
@@ -89,7 +88,7 @@ public class RenderFireRing extends Render<EntityFireRing> {
int i = 0; int i = 0;
GlStateManager.rotate((360f / (float)sides) * k, 0, 1, 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); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
@@ -126,8 +125,7 @@ public class RenderFireRing extends Render<EntityFireRing> {
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y + 0.05f, (float)z); GlStateManager.translate((float)x, (float)y + 0.05f, (float)z);
float f1 = 1.0f; // GlStateManager.scale(s1, s1, s1);
GlStateManager.scale(f1, f1, f1);
float f2 = 0.5F; float f2 = 0.5F;
float f3 = 0.0F; float f3 = 0.0F;
float f4 = 0.2f; float f4 = 0.2f;
@@ -137,7 +135,7 @@ public class RenderFireRing extends Render<EntityFireRing> {
int i = 0; int i = 0;
GlStateManager.rotate((360f / (float)sides) * k, 0, 1, 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); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
@@ -107,9 +107,9 @@ public class RenderRadiantTotem extends Render<EntityRadiantTotem> {
float age = entity.ticksExisted + partialTicks; float age = entity.ticksExisted + partialTicks;
float rotationSpeed = 2; float rotationSpeed = 2;
// GlStateManager.rotate(age * rotationSpeed/2, 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(60.0F, 0.7071F, 0.0F, 0.7071F);
// GlStateManager.rotate(age * rotationSpeed, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(age * rotationSpeed, 0.0F, 1.0F, 0.0F);
GlStateManager.scale(0.5, 0.5, 0.5); GlStateManager.scale(0.5, 0.5, 0.5);
@@ -1,7 +1,6 @@
package electroblob.wizardry.client.renderer.entity; package electroblob.wizardry.client.renderer.entity;
import electroblob.wizardry.client.DrawingUtils; import electroblob.wizardry.client.DrawingUtils;
import electroblob.wizardry.entity.construct.EntityHealAura;
import electroblob.wizardry.entity.construct.EntityMagicConstruct; import electroblob.wizardry.entity.construct.EntityMagicConstruct;
import electroblob.wizardry.util.AllyDesignationSystem; import electroblob.wizardry.util.AllyDesignationSystem;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@@ -19,13 +18,13 @@ import org.lwjgl.opengl.GL11;
public class RenderSigil extends Render<EntityMagicConstruct> { public class RenderSigil extends Render<EntityMagicConstruct> {
private final ResourceLocation texture; private final ResourceLocation texture;
private float scale; private float rotationSpeed;
private boolean invisibleToEnemies; 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); super(renderManager);
this.texture = texture; this.texture = texture;
this.scale = scale; this.rotationSpeed = rotationSpeed;
this.invisibleToEnemies = invisibleToEnemies; this.invisibleToEnemies = invisibleToEnemies;
} }
@@ -35,8 +34,8 @@ public class RenderSigil extends Render<EntityMagicConstruct> {
// Makes the sigil invisible to enemies of the player that created it // Makes the sigil invisible to enemies of the player that created it
if(this.invisibleToEnemies){ if(this.invisibleToEnemies){
// Unfortunately we can't access the caster's allies if they're not online, it only works the other way round // 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 if(entity.getCaster() != Minecraft.getMinecraft().player && entity.getCaster() instanceof EntityPlayer
.isPlayerAlly((EntityPlayer)entity.getCaster(), Minecraft.getMinecraft().player)){ && !AllyDesignationSystem.isPlayerAlly((EntityPlayer)entity.getCaster(), Minecraft.getMinecraft().player)){
return; return;
} }
} }
@@ -59,10 +58,10 @@ public class RenderSigil extends Render<EntityMagicConstruct> {
GlStateManager.rotate(-90, 1, 0, 0); GlStateManager.rotate(-90, 1, 0, 0);
// Healing aura rotates slowly // 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); float s = entity.width * DrawingUtils.smoothScaleFactor(entity.lifetime, entity.ticksExisted, partialTicks, 10, 10);
GlStateManager.scale(scale * s, scale * s, scale * s); GlStateManager.scale(s, s, s);
Tessellator tessellator = Tessellator.getInstance(); Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer(); BufferBuilder buffer = tessellator.getBuffer();
@@ -1,17 +1,23 @@
package electroblob.wizardry.entity.construct; package electroblob.wizardry.entity.construct;
import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.spell.Spell;
import net.minecraft.entity.projectile.EntityTippedArrow; import net.minecraft.entity.projectile.EntityTippedArrow;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
public class EntityArrowRain extends EntityMagicConstruct { public class EntityArrowRain extends EntityScaledConstruct {
public EntityArrowRain(World world){ public EntityArrowRain(World world){
super(world); super(world);
this.height = 3.0f; setSize(Spells.arrow_rain.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 5);
this.width = 5.0f; }
@Override
protected boolean shouldScaleHeight(){
return false;
} }
public void onUpdate(){ public void onUpdate(){
@@ -19,14 +25,21 @@ public class EntityArrowRain extends EntityMagicConstruct {
super.onUpdate(); super.onUpdate();
if(!this.world.isRemote){ 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.motionX = MathHelper.cos((float)Math.toRadians(this.rotationYaw + 90));
arrow.motionY = -0.6; arrow.motionY = -0.6;
arrow.motionZ = MathHelper.sin((float)Math.toRadians(this.rotationYaw + 90)); arrow.motionZ = MathHelper.sin((float)Math.toRadians(this.rotationYaw + 90));
arrow.shootingEntity = this.getCaster(); arrow.shootingEntity = this.getCaster();
arrow.setDamage(7.0d * damageMultiplier); arrow.setDamage(7.0d * damageMultiplier);
arrow.setPotionEffect(new ItemStack(Items.ARROW)); arrow.setPotionEffect(new ItemStack(Items.ARROW));
this.world.spawnEntity(arrow); this.world.spawnEntity(arrow);
} }
} }
@@ -3,8 +3,10 @@ package electroblob.wizardry.entity.construct;
import electroblob.wizardry.Wizardry; import electroblob.wizardry.Wizardry;
import electroblob.wizardry.entity.EntityLevitatingBlock; import electroblob.wizardry.entity.EntityLevitatingBlock;
import electroblob.wizardry.item.ItemArtefact; import electroblob.wizardry.item.ItemArtefact;
import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.BlockUtils; import electroblob.wizardry.util.BlockUtils;
import electroblob.wizardry.util.EntityUtils; import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.MagicDamage; import electroblob.wizardry.util.MagicDamage;
@@ -27,7 +29,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List; import java.util.List;
public class EntityBlackHole extends EntityMagicConstruct { public class EntityBlackHole extends EntityScaledConstruct {
private static final double SUCTION_STRENGTH = 0.075; 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. */ /** 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){ public EntityBlackHole(World world){
super(world); super(world);
this.width = 6.0f; float r = Spells.black_hole.getProperty(Spell.EFFECT_RADIUS).floatValue();
this.height = 3.0f; setSize(r * 2, r);
randomiser = new int[30]; randomiser = new int[30];
for(int i = 0; i < randomiser.length; i++){ for(int i = 0; i < randomiser.length; i++){
randomiser[i] = this.rand.nextInt(10); randomiser[i] = this.rand.nextInt(10);
@@ -91,7 +93,7 @@ public class EntityBlackHole extends EntityMagicConstruct {
if(!this.world.isRemote){ 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) boolean suckInBlocks = getCaster() instanceof EntityPlayer && EntityUtils.canDamageBlocks(getCaster(), world)
&& ItemArtefact.isArtefactActive((EntityPlayer)getCaster(), WizardryItems.charm_black_hole); && ItemArtefact.isArtefactActive((EntityPlayer)getCaster(), WizardryItems.charm_black_hole);
@@ -16,12 +16,18 @@ import net.minecraft.world.World;
import java.util.List; import java.util.List;
public class EntityBlizzard extends EntityMagicConstruct { public class EntityBlizzard extends EntityScaledConstruct {
public EntityBlizzard(World world){ public EntityBlizzard(World world){
super(world); super(world);
this.height = 1.0f; // TODO: Set the size properly and do whatever forcefield does to allow block and entity interaction inside it
this.width = 1.0f; // (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(){ 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 // 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) // 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){ if(!this.world.isRemote){
@@ -64,13 +70,13 @@ public class EntityBlizzard extends EntityMagicConstruct {
for(int i=0; i<6; i++){ for(int i=0; i<6; i++){
double speed = (rand.nextBoolean() ? 1 : -1) * (0.1 + 0.05 * rand.nextDouble()); 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); .time(100).scale(2).spin(rand.nextDouble() * (radius - 0.5) + 0.5, speed).shaded(true).spawn(world);
} }
for(int i=0; i<3; i++){ for(int i=0; i<3; i++){
double speed = (rand.nextBoolean() ? 1 : -1) * (0.05 + 0.02 * rand.nextDouble()); 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); .clr(0xffffff).shaded(true).spin(rand.nextDouble() * (radius - 1) + 0.5, speed).spawn(world);
} }
} }
@@ -10,12 +10,21 @@ import net.minecraft.world.World;
import java.util.List; import java.util.List;
public class EntityCombustionRune extends EntityMagicConstruct { public class EntityCombustionRune extends EntityScaledConstruct {
public EntityCombustionRune(World world){ public EntityCombustionRune(World world){
super(world); super(world);
this.height = 0.2f; setSize(2, 0.2f);
this.width = 2.0f; }
@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 @Override
@@ -31,7 +40,7 @@ public class EntityCombustionRune extends EntityMagicConstruct {
if(this.isValidTarget(target)){ 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, world.newExplosion(this.getCaster(), this.posX, this.posY, this.posZ, strength, true,
getCaster() != null && EntityUtils.canDamageBlocks(getCaster(), world)); getCaster() != null && EntityUtils.canDamageBlocks(getCaster(), world));
@@ -48,9 +57,6 @@ public class EntityCombustionRune extends EntityMagicConstruct {
} }
} }
@Override
protected void entityInit(){}
@Override @Override
public boolean canRenderOnFire(){ public boolean canRenderOnFire(){
return false; return false;
@@ -17,7 +17,7 @@ import java.util.List;
public class EntityDecay extends EntityMagicConstruct { public class EntityDecay extends EntityMagicConstruct {
public int textureIndex = 0; public int textureIndex;
public EntityDecay(World world){ public EntityDecay(World world){
super(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 readEntityFromNBT(NBTTagCompound nbttagcompound){}
@Override protected void writeEntityToNBT(NBTTagCompound nbttagcompound){} @Override protected void writeEntityToNBT(NBTTagCompound nbttagcompound){}
@@ -18,12 +18,11 @@ import net.minecraft.world.World;
import java.util.List; 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){ public EntityEarthquake(World world){
super(world); super(world);
this.height = 1.0f; setSize(1, 1); // This one probably should be small
this.width = 1.0f;
} }
public void onUpdate(){ public void onUpdate(){
@@ -12,14 +12,16 @@ import net.minecraft.world.World;
import java.util.List; import java.util.List;
public class EntityFireRing extends EntityMagicConstruct { public class EntityFireRing extends EntityScaledConstruct {
// TODO: Implement blast modifiers
public EntityFireRing(World world){ public EntityFireRing(World world){
super(world); super(world);
this.height = 1.0f; setSize(Spells.ring_of_fire.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 1);
this.width = 5.0f; }
@Override
protected boolean shouldScaleHeight(){
return false;
} }
public void onUpdate(){ public void onUpdate(){
@@ -32,8 +34,7 @@ public class EntityFireRing extends EntityMagicConstruct {
if(!this.world.isRemote){ if(!this.world.isRemote){
List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(2.5d, this.posX, this.posY, List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(width/2, this.posX, this.posY, this.posZ, this.world);
this.posZ, this.world);
for(EntityLivingBase target : targets){ for(EntityLivingBase target : targets){
@@ -14,12 +14,17 @@ import net.minecraft.world.World;
import java.util.List; 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){ public EntityFireSigil(World world){
super(world); super(world);
this.height = 0.2f; setSize(Spells.fire_sigil.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 0.2f);
this.width = 2.0f; }
@Override
protected boolean shouldScaleHeight(){
return false;
} }
@Override @Override
@@ -59,16 +64,13 @@ public class EntityFireSigil extends EntityMagicConstruct {
} }
} }
}else if(this.rand.nextInt(15) == 0){ }else if(this.rand.nextInt(15) == 0){
double radius = 0.5 + rand.nextDouble() * 0.3; double radius = (0.5 + rand.nextDouble() * 0.3) * width/2;
float angle = rand.nextFloat() * (float)Math.PI * 2;; float angle = rand.nextFloat() * (float)Math.PI * 2;
world.spawnParticle(EnumParticleTypes.FLAME, this.posX + radius * MathHelper.cos(angle), this.posY + 0.1, world.spawnParticle(EnumParticleTypes.FLAME, this.posX + radius * MathHelper.cos(angle), this.posY + 0.1,
this.posZ + radius * MathHelper.sin(angle), 0, 0, 0); this.posZ + radius * MathHelper.sin(angle), 0, 0, 0);
} }
} }
@Override
protected void entityInit(){}
@Override @Override
public boolean canRenderOnFire(){ public boolean canRenderOnFire(){
return false; return false;
@@ -6,16 +6,19 @@ import electroblob.wizardry.entity.projectile.EntityMagicArrow;
import electroblob.wizardry.item.ItemArtefact; import electroblob.wizardry.item.ItemArtefact;
import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.registry.WizardrySounds; 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 electroblob.wizardry.util.ParticleBuilder.Type;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.SPacketEntityVelocity; import net.minecraft.network.play.server.SPacketEntityVelocity;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@@ -32,6 +35,7 @@ import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
// TODO: Possibly convert this to EntityScaledConstruct
@Mod.EventBusSubscriber @Mod.EventBusSubscriber
public class EntityForcefield extends EntityMagicConstruct implements ICustomHitbox { public class EntityForcefield extends EntityMagicConstruct implements ICustomHitbox {
@@ -63,16 +67,6 @@ public class EntityForcefield extends EntityMagicConstruct implements ICustomHit
return radius; return radius;
} }
@Override
public boolean canBeCollidedWith(){
return false;//!this.isDead;
}
@Override
public AxisAlignedBB getCollisionBox(Entity entity){
return null;//entity.getEntityBoundingBox();
}
@Nullable @Nullable
@Override @Override
public AxisAlignedBB getCollisionBoundingBox(){ public AxisAlignedBB getCollisionBoundingBox(){
@@ -244,31 +238,28 @@ public class EntityForcefield extends EntityMagicConstruct implements ICustomHit
return closestPoint.subtract(line.normalize().scale(MathHelper.sqrt(rsquared - dsquared))); 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 @Override
public void writeSpawnData(ByteBuf data){ public void writeSpawnData(ByteBuf data){
super.writeSpawnData(data); super.writeSpawnData(data);
data.writeFloat(getRadius()); data.writeFloat(getRadius());
if(getCaster() != null) data.writeInt(getCaster().getEntityId());
} }
@Override @Override
public void readSpawnData(ByteBuf data){ public void readSpawnData(ByteBuf data){
super.readSpawnData(data); super.readSpawnData(data);
setRadius(data.readFloat()); 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()); @Override
protected void readEntityFromNBT(NBTTagCompound nbt){
if(entity instanceof EntityLivingBase){ super.readEntityFromNBT(nbt);
setCaster((EntityLivingBase)entity); radius = nbt.getFloat("radius");
}else{
Wizardry.logger.warn("Forcefield caster with ID in spawn data not found");
}
} }
@Override @Override
@@ -17,12 +17,16 @@ import net.minecraft.world.World;
import java.util.List; import java.util.List;
public class EntityFrostSigil extends EntityMagicConstruct { public class EntityFrostSigil extends EntityScaledConstruct {
public EntityFrostSigil(World world){ public EntityFrostSigil(World world){
super(world); super(world);
this.height = 0.2f; setSize(Spells.frost_sigil.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 0.2f);
this.width = 2.0f; }
@Override
protected boolean shouldScaleHeight(){
return false;
} }
@Override @Override
@@ -32,7 +36,7 @@ public class EntityFrostSigil extends EntityMagicConstruct {
if(!this.world.isRemote){ if(!this.world.isRemote){
List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(1.0d, this.posX, this.posY, List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(width/2, this.posX, this.posY,
this.posZ, this.world); this.posZ, this.world);
for(EntityLivingBase target : targets){ for(EntityLivingBase target : targets){
@@ -56,8 +60,8 @@ public class EntityFrostSigil extends EntityMagicConstruct {
} }
} }
}else if(this.rand.nextInt(15) == 0){ }else if(this.rand.nextInt(15) == 0){
double radius = 0.5 + rand.nextDouble() * 0.3; double radius = (0.5 + rand.nextDouble() * 0.3) * width/2;
float angle = rand.nextFloat() * (float)Math.PI * 2;; float angle = rand.nextFloat() * (float)Math.PI * 2;
ParticleBuilder.create(Type.SNOW) ParticleBuilder.create(Type.SNOW)
.pos(this.posX + radius * MathHelper.cos(angle), this.posY + 0.1, this.posZ + radius * MathHelper.sin(angle)) .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 .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 @Override
public boolean canRenderOnFire(){ public boolean canRenderOnFire(){
return false; return false;
@@ -1,15 +1,21 @@
package electroblob.wizardry.entity.construct; package electroblob.wizardry.entity.construct;
import electroblob.wizardry.entity.projectile.EntityIceShard; 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.util.math.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
public class EntityHailstorm extends EntityMagicConstruct { public class EntityHailstorm extends EntityScaledConstruct {
public EntityHailstorm(World world){ public EntityHailstorm(World world){
super(world); super(world);
this.height = 3.0f; setSize(Spells.hailstorm.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 5);
this.width = 5.0f; }
@Override
protected boolean shouldScaleHeight(){
return false;
} }
public void onUpdate(){ public void onUpdate(){
@@ -17,15 +23,21 @@ public class EntityHailstorm extends EntityMagicConstruct {
super.onUpdate(); super.onUpdate();
if(!this.world.isRemote){ 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); EntityIceShard iceshard = new EntityIceShard(world);
iceshard.setPosition(this.posX + rand.nextDouble() * 6 - 3, this.posY + rand.nextDouble() * 4 - 2, iceshard.setPosition(x, y, z);
this.posZ + rand.nextDouble() * 6 - 3);
iceshard.motionX = MathHelper.cos((float)Math.toRadians(this.rotationYaw + 90)); iceshard.motionX = MathHelper.cos((float)Math.toRadians(this.rotationYaw + 90));
iceshard.motionY = -0.6; iceshard.motionY = -0.6;
iceshard.motionZ = MathHelper.sin((float)Math.toRadians(this.rotationYaw + 90)); iceshard.motionZ = MathHelper.sin((float)Math.toRadians(this.rotationYaw + 90));
iceshard.setCaster(this.getCaster()); iceshard.setCaster(this.getCaster());
iceshard.damageMultiplier = this.damageMultiplier; iceshard.damageMultiplier = this.damageMultiplier;
this.world.spawnEntity(iceshard); this.world.spawnEntity(iceshard);
} }
} }
@@ -15,14 +15,11 @@ import net.minecraft.world.World;
import java.util.List; import java.util.List;
public class EntityHealAura extends EntityMagicConstruct { public class EntityHealAura extends EntityScaledConstruct {
// TODO: Implement blast modifiers
public EntityHealAura(World world){ public EntityHealAura(World world){
super(world); super(world);
this.height = 1.0f; setSize(Spells.healing_aura.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 1);
this.width = 5.0f;
} }
@Override @Override
@@ -36,7 +33,7 @@ public class EntityHealAura extends EntityMagicConstruct {
if(!this.world.isRemote){ if(!this.world.isRemote){
List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(2.5, posX, posY, posZ, world); List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(width/2, posX, posY, posZ, world);
for(EntityLivingBase target : targets){ for(EntityLivingBase target : targets){
@@ -69,8 +66,8 @@ public class EntityHealAura extends EntityMagicConstruct {
}else{ }else{
for(int i=1; i<3; i++){ for(int i=1; i<3; i++){
float brightness = 0.5f + (rand.nextFloat() * 0.5f); float brightness = 0.5f + (rand.nextFloat() * 0.5f);
double radius = rand.nextDouble() * 2.0; double radius = rand.nextDouble() * (width/2);
float angle = rand.nextFloat() * (float)Math.PI * 2;; float angle = rand.nextFloat() * (float)Math.PI * 2;
ParticleBuilder.create(Type.SPARKLE) ParticleBuilder.create(Type.SPARKLE)
.pos(this.posX + radius * MathHelper.cos(angle), this.posY, this.posZ + radius * MathHelper.sin(angle)) .pos(this.posX + radius * MathHelper.cos(angle), this.posY, this.posZ + radius * MathHelper.sin(angle))
.vel(0, 0.05, 0) .vel(0, 0.05, 0)
@@ -63,7 +63,8 @@ public class EntityIceSpike extends EntityMagicConstruct {
for(Object entity : this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox())){ for(Object entity : this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox())){
if(entity instanceof EntityLivingBase && this.isValidTarget((EntityLivingBase)entity)){ if(entity instanceof EntityLivingBase && this.isValidTarget((EntityLivingBase)entity)){
DamageSource source = this.getCaster() == null ? DamageSource.MAGIC : MagicDamage.causeDirectMagicDamage(this.getCaster(), DamageType.FROST); 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)) if(((EntityLivingBase)entity).attackEntityFrom(source, Spells.ice_spikes.getProperty(Spell.DAMAGE).floatValue() * this.damageMultiplier))
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(WizardryPotions.frost, ((EntityLivingBase)entity).addPotionEffect(new PotionEffect(WizardryPotions.frost,
Spells.ice_spikes.getProperty(Spell.EFFECT_DURATION).intValue(), Spells.ice_spikes.getProperty(Spell.EFFECT_DURATION).intValue(),
@@ -15,14 +15,19 @@ import net.minecraft.world.World;
import java.util.List; 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 static final String SECONDARY_MAX_TARGETS = "secondary_max_targets";
public EntityLightningSigil(World world){ public EntityLightningSigil(World world){
super(world); super(world);
this.height = 0.2f; setSize(Spells.frost_sigil.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 0.2f);
this.width = 2.0f; }
@Override
protected boolean shouldScaleHeight(){
return false;
} }
@Override @Override
@@ -34,7 +39,7 @@ public class EntityLightningSigil extends EntityMagicConstruct {
this.setDead(); this.setDead();
} }
List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(1.0d, this.posX, this.posY, List<EntityLivingBase> targets = EntityUtils.getLivingWithinRadius(width/2, this.posX, this.posY,
this.posZ, this.world); this.posZ, this.world);
for(EntityLivingBase target : targets){ for(EntityLivingBase target : targets){
@@ -58,7 +63,7 @@ public class EntityLightningSigil extends EntityMagicConstruct {
this.playSound(WizardrySounds.ENTITY_LIGHTNING_SIGIL_TRIGGER, 1.0f, 1.0f); this.playSound(WizardrySounds.ENTITY_LIGHTNING_SIGIL_TRIGGER, 1.0f, 1.0f);
// Secondary chaining effect // Secondary chaining effect
double seekerRange = Spells.lightning_sigil.getProperty(Spell.EFFECT_RADIUS).doubleValue(); double seekerRange = Spells.lightning_sigil.getProperty(SECONDARY_RANGE).doubleValue();
List<EntityLivingBase> secondaryTargets = EntityUtils.getLivingWithinRadius(seekerRange, List<EntityLivingBase> secondaryTargets = EntityUtils.getLivingWithinRadius(seekerRange,
target.posX, target.posY + target.height / 2, target.posZ, world); 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){ if(this.world.isRemote && this.rand.nextInt(15) == 0){
double radius = 0.5 + rand.nextDouble() * 0.3; double radius = (0.5 + rand.nextDouble() * 0.3) * width/2;
float angle = rand.nextFloat() * (float)Math.PI * 2;; float angle = rand.nextFloat() * (float)Math.PI * 2;
ParticleBuilder.create(Type.SPARK) ParticleBuilder.create(Type.SPARK)
.pos(this.posX + radius * MathHelper.cos(angle), this.posY + 0.1, this.posZ + radius * MathHelper.sin(angle)) .pos(this.posX + radius * MathHelper.cos(angle), this.posY + 0.1, this.posZ + radius * MathHelper.sin(angle))
.spawn(world); .spawn(world);
@@ -24,13 +24,10 @@ import javax.annotation.Nullable;
import java.util.UUID; import java.util.UUID;
/** /**
* This class is for all inanimate magical constructs which are not projectiles. It was made from scratch to provide a * This class is for all inanimate magical constructs which are not projectiles. Generally speaking, subclasses of this
* unifying superclass for black hole, blizzard, tornado and a few others which all share some characteristics. The * class are areas of effect which deal damage or apply effects over time, including black hole, blizzard, tornado and
* caster UUID, lifetime and damage multiplier are stored here, and lifetime is also synced here. * a few others. The caster UUID, lifetime and damage multiplier are stored here, and lifetime is also synced here.
* <p></p> *
* 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.
*
* @since Wizardry 1.0 * @since Wizardry 1.0
*/ */
public abstract class EntityMagicConstruct extends Entity implements IEntityOwnable, IEntityAdditionalSpawnData { public abstract class EntityMagicConstruct extends Entity implements IEntityOwnable, IEntityAdditionalSpawnData {
@@ -40,10 +37,8 @@ public abstract class EntityMagicConstruct extends Entity implements IEntityOwna
* {@link EntityMagicConstruct#getCaster()}. */ * {@link EntityMagicConstruct#getCaster()}. */
private UUID casterUUID; private UUID casterUUID;
/** /** The time in ticks this magical construct lasts for; defaults to 600 (30 seconds). If this is -1 the construct
* The time in ticks this magical construct lasts for; defaults to 600 (30 seconds). If this is -1 the construct * doesn't despawn. */
* doesn't despawn.
*/
public int lifetime = 600; public int lifetime = 600;
/** The damage multiplier for this construct, determined by the wand with which it was cast. */ /** 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 @Override
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand){ 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){ if(lifetime == -1 && getCaster() == player && player.isSneaking() && player.getHeldItem(hand).getItem() instanceof ISpellCastingItem){
this.despawn(); this.despawn();
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
@@ -98,7 +94,7 @@ public abstract class EntityMagicConstruct extends Entity implements IEntityOwna
@Override @Override
protected void entityInit(){ protected void entityInit(){
// We could leave this unimplemented, but since the majority of subclasses don't use it, let's make it optional
} }
@Override @Override
@@ -19,13 +19,23 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class EntityRadiantTotem extends EntityMagicConstruct { public class EntityRadiantTotem extends EntityScaledConstruct {
private static final int PERIMETER_PARTICLE_DENSITY = 6; private static final int PERIMETER_PARTICLE_DENSITY = 6;
public EntityRadiantTotem(World world){ public EntityRadiantTotem(World world){
super(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 @Override
@@ -37,7 +47,7 @@ public class EntityRadiantTotem extends EntityMagicConstruct {
super.onUpdate(); 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){ if(world.isRemote){
@@ -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);
}
}
@@ -1,6 +1,5 @@
package electroblob.wizardry.entity.construct; package electroblob.wizardry.entity.construct;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.registry.Spells; import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.spell.Spell; import electroblob.wizardry.spell.Spell;
@@ -8,47 +7,27 @@ import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.MagicDamage; import electroblob.wizardry.util.MagicDamage;
import electroblob.wizardry.util.ParticleBuilder; import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type; 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.EntityLivingBase;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.List; import java.util.List;
public class EntityStormcloud extends EntityMagicConstruct { public class EntityStormcloud extends EntityScaledConstruct {
// private static final DataParameter<Float> RADIUS = new DataParameter<>(21, DataSerializers.FLOAT);
public EntityStormcloud(World world){ public EntityStormcloud(World world){
super(world); super(world);
this.height = 2.0f; setSize(Spells.stormcloud.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2, 2);
this.width = Spells.stormcloud.getProperty(Spell.EFFECT_RADIUS).floatValue() * 2;
} }
// @Override @Override
// protected void entityInit(){ protected boolean shouldScaleHeight(){
// super.entityInit(); return false;
// 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);
// }
public void onUpdate(){ public void onUpdate(){
super.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){ if(this.world.isRemote){
float areaFactor = (width * width) / 36; // Ensures cloud/raindrop density stays the same for different sizes 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()
//
// }
// }
} }
} }
@@ -7,8 +7,11 @@ import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.spell.Spell; import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.spell.Tornado; 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.MagicDamage.DamageType;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type; import electroblob.wizardry.util.ParticleBuilder.Type;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@@ -27,17 +30,21 @@ import net.minecraft.world.World;
import java.util.List; import java.util.List;
public class EntityTornado extends EntityMagicConstruct { public class EntityTornado extends EntityScaledConstruct {
private double velX, velZ; private double velX, velZ;
public EntityTornado(World world){ public EntityTornado(World world){
super(world); super(world);
this.height = 8.0f; setSize(Spells.tornado.getProperty(Spell.EFFECT_RADIUS).floatValue(), 8);
this.width = 5.0f;
this.isImmuneToFire = false; this.isImmuneToFire = false;
} }
@Override
protected boolean shouldScaleHeight(){
return false;
}
public void setHorizontalVelocity(double velX, double velZ){ public void setHorizontalVelocity(double velX, double velZ){
this.velX = velX; this.velX = velX;
this.velZ = velZ; this.velZ = velZ;
@@ -48,7 +55,7 @@ public class EntityTornado extends EntityMagicConstruct {
super.onUpdate(); super.onUpdate();
double radius = Spells.tornado.getProperty(Spell.EFFECT_RADIUS).doubleValue(); double radius = width/2;
if(this.ticksExisted % 120 == 1 && world.isRemote){ if(this.ticksExisted % 120 == 1 && world.isRemote){
// Repeat is false so that the sound fades out when the tornado does rather than stopping suddenly // Repeat is false so that the sound fades out when the tornado does rather than stopping suddenly
@@ -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 SpellProjectile<>("fireball", EntityMagicFireball::new).addProperties(Spell.DAMAGE, Spell.BURN_DURATION));//new Fireball());
registry.register(new FlameRay()); 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 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 SpellProjectile<>("firebolt", EntityFirebolt::new).addProperties(Spell.DAMAGE, Spell.BURN_DURATION));
registry.register(new FrostRay()); registry.register(new FrostRay());
registry.register(new SummonSnowGolem()); 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 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 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 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<>("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 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 SpellArrow<>("lightning_arrow", EntityLightningArrow::new).addProperties(Spell.DAMAGE).soundValues(1, 1.45f, 0.3f));
registry.register(new LifeDrain()); registry.register(new LifeDrain());
registry.register(new SummonSkeleton()); registry.register(new SummonSkeleton());
@@ -309,7 +309,7 @@ public final class Spells {
registry.register(new HealAlly()); registry.register(new HealAlly());
registry.register(new SpellMinion<>("summon_blaze", EntityBlazeMinion::new).soundValues(1, 1.1f, 0.2f)); 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 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("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)); 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 PhaseStep());
registry.register(new VanishingBox()); registry.register(new VanishingBox());
registry.register(new GreaterHeal()); 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 Forcefield());
registry.register(new SpellBuff("ironflesh", 0.4f, 0.5f, 0.6f, () -> MobEffects.RESISTANCE).soundValues(0.7f, 1.2f, 0.4f)); registry.register(new SpellBuff("ironflesh", 0.4f, 0.5f, 0.6f, () -> MobEffects.RESISTANCE).soundValues(0.7f, 1.2f, 0.4f));
registry.register(new Transience()); registry.register(new Transience());
@@ -366,7 +366,7 @@ public final class Spells {
registry.register(new ForestsCurse()); registry.register(new ForestsCurse());
registry.register(new Flight()); registry.register(new Flight());
registry.register(new SpellMinion<>("silverfish_swarm", EntitySilverfishMinion::new).soundValues(1, 1.1f, 0.1f)); 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 Shockwave());
registry.register(new SummonIronGolem()); registry.register(new SummonIronGolem());
registry.register(new ArrowRain()); registry.register(new ArrowRain());
@@ -11,6 +11,7 @@ public class ArrowRain extends SpellConstructRanged<EntityArrowRain> {
public ArrowRain(){ public ArrowRain(){
super("arrow_rain", EntityArrowRain::new, false); super("arrow_rain", EntityArrowRain::new, false);
this.floor(true); this.floor(true);
addProperties(EFFECT_RADIUS);
} }
@Override @Override
@@ -13,6 +13,7 @@ public class Hailstorm extends SpellConstructRanged<EntityHailstorm> {
public Hailstorm(){ public Hailstorm(){
super("hailstorm", EntityHailstorm::new, false); super("hailstorm", EntityHailstorm::new, false);
this.floor(true); this.floor(true);
addProperties(EFFECT_RADIUS);
} }
@Override @Override
@@ -2,6 +2,7 @@ package electroblob.wizardry.spell;
import electroblob.wizardry.Wizardry; import electroblob.wizardry.Wizardry;
import electroblob.wizardry.entity.construct.EntityMagicConstruct; import electroblob.wizardry.entity.construct.EntityMagicConstruct;
import electroblob.wizardry.entity.construct.EntityScaledConstruct;
import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.util.BlockUtils; import electroblob.wizardry.util.BlockUtils;
import electroblob.wizardry.util.SpellModifiers; import electroblob.wizardry.util.SpellModifiers;
@@ -160,6 +161,7 @@ public class SpellConstruct<T extends EntityMagicConstruct> extends Spell {
construct.setCaster(caster); construct.setCaster(caster);
construct.lifetime = permanent ? -1 : (int)(getProperty(DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade)); construct.lifetime = permanent ? -1 : (int)(getProperty(DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade));
construct.damageMultiplier = modifiers.get(SpellModifiers.POTENCY); construct.damageMultiplier = modifiers.get(SpellModifiers.POTENCY);
if(construct instanceof EntityScaledConstruct) ((EntityScaledConstruct)construct).setSizeMultiplier(modifiers.get(WizardryItems.blast_upgrade));
addConstructExtras(construct, side, caster, modifiers); addConstructExtras(construct, side, caster, modifiers);
// Prevents overlapping of multiple constructs of the same type. Since we have an instance here this is // 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 // very simple. The trade-off is that we have to create the entity before the spell fails, but unless
@@ -18,6 +18,7 @@
"cooldown": 300, "cooldown": 300,
"base_properties": { "base_properties": {
"range": 20, "range": 20,
"duration": 120 "duration": 120,
"effect_radius": 2
} }
} }
@@ -18,6 +18,7 @@
"cooldown": 400, "cooldown": 400,
"base_properties": { "base_properties": {
"duration": 400, "duration": 400,
"range": 10 "range": 10,
"effect_radius": 3
} }
} }
@@ -18,6 +18,7 @@
"cooldown": 20, "cooldown": 20,
"base_properties": { "base_properties": {
"range": 10, "range": 10,
"effect_radius": 1,
"damage": 6, "damage": 6,
"burn_duration": 10 "burn_duration": 10
} }
@@ -18,6 +18,7 @@
"cooldown": 20, "cooldown": 20,
"base_properties": { "base_properties": {
"range": 10, "range": 10,
"effect_radius": 1,
"damage": 8, "damage": 8,
"effect_duration": 200, "effect_duration": 200,
"effect_strength": 1 "effect_strength": 1
@@ -18,6 +18,7 @@
"cooldown": 300, "cooldown": 300,
"base_properties": { "base_properties": {
"range": 20, "range": 20,
"duration": 120 "duration": 120,
"effect_radius": 2
} }
} }
@@ -18,6 +18,7 @@
"cooldown": 150, "cooldown": 150,
"base_properties": { "base_properties": {
"duration": 600, "duration": 600,
"effect_radius": 2.5,
"damage": 1, "damage": 1,
"health": 1 "health": 1
} }
@@ -18,8 +18,9 @@
"cooldown": 20, "cooldown": 20,
"base_properties": { "base_properties": {
"range": 10, "range": 10,
"effect_radius": 1,
"direct_damage": 6, "direct_damage": 6,
"effect_radius": 5, "secondary_range": 1,
"secondary_max_targets": 3, "secondary_max_targets": 3,
"splash_damage": 4 "splash_damage": 4
} }
@@ -18,6 +18,7 @@
"cooldown": 100, "cooldown": 100,
"base_properties": { "base_properties": {
"duration": 600, "duration": 600,
"effect_radius": 2.5,
"damage": 1, "damage": 1,
"burn_duration": 10 "burn_duration": 10
} }