From f5cd740497a09ec17f2d1197ae5facdd1c72cb93 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Sat, 10 Oct 2020 18:30:54 +0100 Subject: [PATCH] Add amulet of esundor, plus fixes for frost barrier --- .../renderer/entity/RenderIceBarrier.java | 5 ---- .../entity/construct/EntityIceBarrier.java | 24 +++++++++--------- .../wizardry/item/ItemArtefact.java | 14 ++++++++++ .../wizardry/registry/WizardryItems.java | 2 ++ .../assets/ebwizardry/lang/en_gb.lang | 2 ++ .../assets/ebwizardry/lang/en_us.lang | 2 ++ .../models/item/amulet_frost_warding.json | 6 +++++ .../textures/items/amulet_frost_warding.png | Bin 0 -> 1968 bytes 8 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 src/main/resources/assets/ebwizardry/models/item/amulet_frost_warding.json create mode 100644 src/main/resources/assets/ebwizardry/textures/items/amulet_frost_warding.png 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 0000000000000000000000000000000000000000..c370f09e95e186f12a572ae3ec8f3fd53c2d15fe GIT binary patch literal 1968 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s-i>g8*N`ey06$*;-(=u~X z6-p`#QWa7wGSe6sDsHU}kDT;IgXhn4kz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