Skip to content

Commit

Permalink
Beta 8 Complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandra-Myers committed Aug 9, 2023
1 parent 1091475 commit d7b751d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.alexandra.atlas.atlas_combat.mixin;

import net.alexandra.atlas.atlas_combat.extensions.AABBExtensions;
import net.minecraft.util.Mth;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Final;
Expand Down Expand Up @@ -35,36 +36,11 @@ public class AABBMixin implements AABBExtensions {
public double maxY;

@Override
public Vec3 getNearestPointTo(Vec3 paramVec3) {
if (paramVec3.x < this.minX && paramVec3.y < this.minY && paramVec3.z < this.minZ)
return new Vec3(this.minX, this.minY, this.minZ);
if (paramVec3.x < this.minX && paramVec3.y < this.minY && paramVec3.z > this.maxZ)
return new Vec3(this.minX, this.minY, this.maxZ);
if (paramVec3.x < this.minX && paramVec3.y > this.maxY && paramVec3.z < this.minZ)
return new Vec3(this.minX, this.maxY, this.minZ);
if (paramVec3.x < this.minX && paramVec3.y > this.maxY && paramVec3.z > this.maxZ)
return new Vec3(this.minX, this.maxY, this.maxZ);
if (paramVec3.x > this.maxX && paramVec3.y < this.minY && paramVec3.z < this.minZ)
return new Vec3(this.maxX, this.minY, this.minZ);
if (paramVec3.x > this.maxX && paramVec3.y < this.minY && paramVec3.z > this.maxZ)
return new Vec3(this.maxX, this.minY, this.maxZ);
if (paramVec3.x > this.maxX && paramVec3.y > this.maxY && paramVec3.z < this.minZ)
return new Vec3(this.maxX, this.maxY, this.minZ);
if (paramVec3.x > this.maxX && paramVec3.y > this.maxY && paramVec3.z > this.maxZ)
return new Vec3(this.maxX, this.maxY, this.maxZ);
public Vec3 getNearestPointTo(Vec3 vec3) {
double x = Mth.clamp(vec3.x, this.minX, this.maxX);
double y = Mth.clamp(vec3.y, this.minY, this.maxY);
double z = Mth.clamp(vec3.z, this.minZ, this.maxZ);

if (paramVec3.x < this.minX)
return new Vec3(this.minX, paramVec3.y, paramVec3.z);
if (paramVec3.y < this.minY)
return new Vec3(paramVec3.x, this.minY, paramVec3.z);
if (paramVec3.z < this.minZ)
return new Vec3(paramVec3.x, paramVec3.y, this.minZ);
if (paramVec3.x > this.maxX)
return new Vec3(this.maxX, paramVec3.y, paramVec3.z);
if (paramVec3.y > this.maxY)
return new Vec3(paramVec3.x, this.maxY, paramVec3.z);
if (paramVec3.z > this.maxZ)
return new Vec3(paramVec3.x, paramVec3.y, this.maxZ);
return paramVec3;
return new Vec3(x, y, z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ public int changeIFrames(int constant, @Local(ordinal = 0) final DamageSource so
enemy = entity2;
int invulnerableTime = 10;
if (entity2 instanceof Player player) {
invulnerableTime = (int) Math.min(player.getCurrentItemAttackStrengthDelay(), invulnerableTime);
int base = (int) Math.min(player.getCurrentItemAttackStrengthDelay(), invulnerableTime);
invulnerableTime = base >= 4 ? base - 1 : base;
}

if (source.is(DamageTypeTags.IS_PROJECTILE) && !AtlasCombat.CONFIG.projectilesHaveIFrames()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ public void injectPlayer(ServerboundInteractPacket packet, CallbackInfo ci) {
}

@Redirect(method = "handleInteract", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D"))
public double redirectCheck(AABB instance, Vec3 vec3) {
return ((AABBExtensions)instance).getNearestPointTo(vec3).distanceToSqr(vec3);
public double redirectCheck(AABB instance, Vec3 old) {
Vec3 vec3 = player.getEyePosition(0.0F);
return vec3.distanceToSqr(((AABBExtensions)instance).getNearestPointTo(vec3));
}
@ModifyExpressionValue(method = "handleInteract",
at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;MAX_INTERACTION_DISTANCE:D",opcode = Opcodes.GETSTATIC))
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/atlas_combat/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"text.config.atlas-combat-config.option.projectilesHaveIFrames": "Determines if projectile damage sources have I-Frames",
"text.config.atlas-combat-config.option.magicHasIFrames": "Determines if magic damage sources have I-Frames",
"text.config.atlas-combat-config.option.autoAttackAllowed": "Option for servers which will prevent using auto-attack on client",
"text.config.atlas-combat-config.option.bowMomentumDamage": "Bow damage is influenced by the arrow momentum",
"text.config.atlas-combat-config.option.configOnlyWeapons": "Adds Knives and Longswords with their own respective stats and abilities.",
"text.config.atlas-combat-config.option.piercer": "Adds enchantment Piercer, which allows for disabling of shields, as well as adding 10% armor piercing. Incompat with Cleaving.",
"text.config.atlas-combat-config.option.defender": "Adds enchantment Defender, which decreases shield disable time by 0.5s, and increases protection for shields and swords.",
Expand Down

0 comments on commit d7b751d

Please sign in to comment.