diff --git a/src/main/java/electroblob/wizardry/client/renderer/entity/RenderIceBarrier.java b/src/main/java/electroblob/wizardry/client/renderer/entity/RenderIceBarrier.java index 5ee0edac..2d1edcb1 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/entity/RenderIceBarrier.java +++ b/src/main/java/electroblob/wizardry/client/renderer/entity/RenderIceBarrier.java @@ -25,16 +25,11 @@ public class RenderIceBarrier extends Render { GlStateManager.translate(x, y + entity.height/2, z); GlStateManager.rotate(180, 0F, 0F, 1F); GlStateManager.rotate(yaw, 0, 1, 0); - //GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, 0, 0, 1); GlStateManager.translate(0, -entity.height/2 - 0.3, 0); - // Pass in -1 for the lifetime as the boulder crumbles when the time expires -// float s = DrawingUtils.smoothScaleFactor(-1, entity.ticksExisted, partialTicks, 10, 10); float s = entity.getSizeMultiplier(); GlStateManager.scale(s, s, s); -// GlStateManager.translate(0, 0.875, 0); // No idea why it starts 7/8 of a block too low, but it does - this.bindTexture(TEXTURE); model.render(entity, 0, 0, 0, 0, 0, 0.0625f); diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityIceBarrier.java b/src/main/java/electroblob/wizardry/entity/construct/EntityIceBarrier.java index 239336fb..39183c54 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityIceBarrier.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityIceBarrier.java @@ -49,8 +49,8 @@ public class EntityIceBarrier extends EntityScaledConstruct implements ICustomHi // Bit of a cheat but it's easier than trying to sync FrostBarrier#addConstructExtras if(world.isRemote && firstUpdate){ + setSizeMultiplier(sizeMultiplier); // Do this first or it'll overwrite the bounding box setRotation(rotationYaw, rotationPitch); - setSizeMultiplier(sizeMultiplier); } this.prevPosX = posX; @@ -78,20 +78,22 @@ public class EntityIceBarrier extends EntityScaledConstruct implements ICustomHi Vec3d look = this.getLookVec(); - for(Entity entity : world.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox().grow(2))){ + if(!world.isRemote){ - if(entity instanceof EntityMagicConstruct) continue; + for(Entity entity : world.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox().grow(2))){ - if(!entity.getEntityBoundingBox().intersects(this.getEntityBoundingBox())) continue; + if(entity instanceof EntityMagicConstruct) continue; - double perpendicularDist = getSignedPerpendicularDistance(entity.getPositionVector()); + if(!entity.getEntityBoundingBox().intersects(this.getEntityBoundingBox())) continue; - if(Math.abs(perpendicularDist) < entity.width/2 + THICKNESS/2){ + // For some reason the player position seems to be off by 1 block in x and z, no idea how so for now + // I've just fudged it by adding 1 to x and z + double perpendicularDist = getSignedPerpendicularDistance(entity.getPositionVector().add(1, 0, 1)); - double velocity = 0.25 * Math.signum(perpendicularDist); - entity.addVelocity(velocity * look.x, 0, velocity * look.z); + if(Math.abs(perpendicularDist) < entity.width/2 + THICKNESS/2){ - if(!world.isRemote){ + double velocity = 0.25 * Math.signum(perpendicularDist); + entity.addVelocity(velocity * look.x, 0, velocity * look.z); // Player motion is handled on that player's client so needs packets if(entity instanceof EntityPlayerMP){ ((EntityPlayerMP)entity).connection.sendPacket(new SPacketEntityVelocity(entity)); @@ -159,9 +161,7 @@ public class EntityIceBarrier extends EntityScaledConstruct implements ICustomHi private double getSignedPerpendicularDistance(Vec3d point){ Vec3d look = this.getLookVec(); Vec3d delta = new Vec3d(point.x - this.posX, 0, point.z - this.posZ); - double dist = delta.length(); - float angle = (float)(delta.dotProduct(look) / dist); - return dist * MathHelper.sin(angle); + return delta.dotProduct(look); } } diff --git a/src/main/java/electroblob/wizardry/item/ItemArtefact.java b/src/main/java/electroblob/wizardry/item/ItemArtefact.java index afc47d74..a286dd91 100644 --- a/src/main/java/electroblob/wizardry/item/ItemArtefact.java +++ b/src/main/java/electroblob/wizardry/item/ItemArtefact.java @@ -5,6 +5,7 @@ import electroblob.wizardry.Wizardry; import electroblob.wizardry.constants.Element; import electroblob.wizardry.data.WizardData; import electroblob.wizardry.entity.construct.EntityFireRing; +import electroblob.wizardry.entity.construct.EntityIceBarrier; import electroblob.wizardry.entity.living.ISummonedCreature; import electroblob.wizardry.entity.projectile.EntityDart; import electroblob.wizardry.entity.projectile.EntityForceOrb; @@ -364,6 +365,19 @@ public class ItemArtefact extends Item { } }); + }else if(artefact == WizardryItems.amulet_frost_warding){ + + if(!world.isRemote && player.ticksExisted % 40 == 0){ + + List barriers = world.getEntitiesWithinAABB(EntityIceBarrier.class, player.getEntityBoundingBox().grow(1.5)); + + // Check whether any barriers near the player are facing away from them, meaning the player is behind them + if(!barriers.isEmpty() && barriers.stream().anyMatch(b -> b.getLookVec().dotProduct(b.getPositionVector().subtract(player.getPositionVector())) > 0)){ + player.addPotionEffect(new PotionEffect(WizardryPotions.ward, 50, 1)); + } + + } + }else if(artefact == WizardryItems.charm_feeding){ // Every 5 seconds, feed the player if they are hungry enough if(player.ticksExisted % 100 == 0){ diff --git a/src/main/java/electroblob/wizardry/registry/WizardryItems.java b/src/main/java/electroblob/wizardry/registry/WizardryItems.java index 2980fde1..827c69e9 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryItems.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryItems.java @@ -253,6 +253,7 @@ public final class WizardryItems { public static final Item amulet_fire_cloaking = placeholder(); public static final Item amulet_ice_immunity = placeholder(); public static final Item amulet_ice_protection = placeholder(); + public static final Item amulet_frost_warding = placeholder(); public static final Item amulet_potential = placeholder(); public static final Item amulet_channeling = placeholder(); public static final Item amulet_lich = placeholder(); @@ -622,6 +623,7 @@ public final class WizardryItems { registerItem(registry, "amulet_fire_cloaking", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.AMULET)); registerItem(registry, "amulet_ice_immunity", new ItemArtefact(EnumRarity.EPIC, ItemArtefact.Type.AMULET)); registerItem(registry, "amulet_ice_protection", new ItemArtefact(EnumRarity.UNCOMMON, ItemArtefact.Type.AMULET)); + registerItem(registry, "amulet_frost_warding", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.AMULET)); registerItem(registry, "amulet_potential", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.AMULET)); registerItem(registry, "amulet_channeling", new ItemArtefact(EnumRarity.UNCOMMON, ItemArtefact.Type.AMULET)); registerItem(registry, "amulet_lich", new ItemArtefact(EnumRarity.UNCOMMON, ItemArtefact.Type.AMULET)); diff --git a/src/main/resources/assets/ebwizardry/lang/en_gb.lang b/src/main/resources/assets/ebwizardry/lang/en_gb.lang index ccf6a7d9..9d09419e 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_gb.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_gb.lang @@ -346,6 +346,8 @@ item.ebwizardry\:amulet_ice_immunity.name=Permafrost Amulet item.ebwizardry\:amulet_ice_immunity.desc=Grants total immunity to frostbite effects item.ebwizardry\:amulet_ice_protection.name=Frostbound Amulet item.ebwizardry\:amulet_ice_protection.desc=Reduces frost damage by 30%% +item.ebwizardry\:amulet_frost_warding.name=Amulet of Esundor +item.ebwizardry\:amulet_frost_warding.desc=Grants a warding effect when standing behind a wall of frost item.ebwizardry\:amulet_potential.name=Amulet of Potential item.ebwizardry\:amulet_potential.desc=Grants a 15%% chance to shoot lightning at creatures that melee attack you item.ebwizardry\:amulet_channeling.name=Amulet of Channeling diff --git a/src/main/resources/assets/ebwizardry/lang/en_us.lang b/src/main/resources/assets/ebwizardry/lang/en_us.lang index 18b344dd..62439a62 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_us.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_us.lang @@ -346,6 +346,8 @@ item.ebwizardry\:amulet_ice_immunity.name=Permafrost Amulet item.ebwizardry\:amulet_ice_immunity.desc=Grants total immunity to frostbite effects item.ebwizardry\:amulet_ice_protection.name=Frostbound Amulet item.ebwizardry\:amulet_ice_protection.desc=Reduces frost damage by 30%% +item.ebwizardry\:amulet_frost_warding.name=Amulet of Esundor +item.ebwizardry\:amulet_frost_warding.desc=Grants a warding effect when standing behind a wall of frost item.ebwizardry\:amulet_potential.name=Amulet of Potential item.ebwizardry\:amulet_potential.desc=Grants a 15%% chance to shoot lightning at creatures that melee attack you item.ebwizardry\:amulet_channeling.name=Amulet of Channeling diff --git a/src/main/resources/assets/ebwizardry/models/item/amulet_frost_warding.json b/src/main/resources/assets/ebwizardry/models/item/amulet_frost_warding.json new file mode 100644 index 00000000..c6d9cc2e --- /dev/null +++ b/src/main/resources/assets/ebwizardry/models/item/amulet_frost_warding.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "ebwizardry:items/amulet_frost_warding" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/textures/items/amulet_frost_warding.png b/src/main/resources/assets/ebwizardry/textures/items/amulet_frost_warding.png new file mode 100644 index 00000000..c370f09e Binary files /dev/null and b/src/main/resources/assets/ebwizardry/textures/items/amulet_frost_warding.png differ