Toreterror changes
Remove cheep item fix cheep spawning nightmare sword tooltip apple cow sheared drop fix
This commit is contained in:
1 parent
dc2c4cf014
commit
84bf436434
40 files changed
+411
-209
No files matched your search
@@ -454,8 +454,8 @@ public final class AntarchySettings {
|
||||
private static double toreterrorHealth = 300.0D;
|
||||
private static double toreterrorJumpAttackDamage = 14.0D;
|
||||
private static double toreterrorJumpAttackKnockback = 2.5D;
|
||||
private static double toreterrorSpinDamage = 8.0D;
|
||||
private static double toreterrorSpinKnockback = 1.5D;
|
||||
private static double toreterrorSpinDamage = 6.0D;
|
||||
private static double toreterrorSpinKnockback = 0.9D;
|
||||
private static double toreterrorRangedWaterBombChance = 0.5D;
|
||||
private static double toreterrorProjectileDamageMultiplier = 0.5D;
|
||||
private static double waterBombDamage = 6.0D;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.craisinlord.antarchy.config;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class ConfigResetGuard {
|
||||
public static final int RESET_GENERATION = 1;
|
||||
private static final String MARKER_FILE_NAME = ".config_generation";
|
||||
|
||||
private ConfigResetGuard() {
|
||||
}
|
||||
|
||||
public static void wipeIfNeeded(Path configDir, Path... configFiles) {
|
||||
Path markerPath = configDir.resolve(MARKER_FILE_NAME);
|
||||
if (readGeneration(markerPath) >= RESET_GENERATION) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Path configFile : configFiles) {
|
||||
try {
|
||||
if (Files.deleteIfExists(configFile)) {
|
||||
Antarchy.LOGGER.info("Reset config file {} to defaults (config generation {})", configFile, RESET_GENERATION);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Antarchy.LOGGER.warn("Failed to delete config file {} during config reset", configFile, e);
|
||||
}
|
||||
}
|
||||
|
||||
writeGeneration(markerPath);
|
||||
}
|
||||
|
||||
private static int readGeneration(Path markerPath) {
|
||||
if (!Files.exists(markerPath)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
return Integer.parseInt(Files.readString(markerPath).trim());
|
||||
} catch (IOException | NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeGeneration(Path markerPath) {
|
||||
try {
|
||||
Files.createDirectories(markerPath.getParent());
|
||||
Files.writeString(markerPath, Integer.toString(RESET_GENERATION));
|
||||
} catch (IOException e) {
|
||||
Antarchy.LOGGER.warn("Failed to write config generation marker at {}", markerPath, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,10 @@ public final class AntarchySoundEvents {
|
||||
public static Supplier<SoundEvent> BOMBER_WALK = (Supplier<SoundEvent>) UNBOUND;
|
||||
public static Supplier<SoundEvent> BOMBER_KNOCK = (Supplier<SoundEvent>) UNBOUND;
|
||||
public static Supplier<SoundEvent> BOMBER_EXPLODE = (Supplier<SoundEvent>) UNBOUND;
|
||||
public static Supplier<SoundEvent> TORETERROR_IDLE = (Supplier<SoundEvent>) UNBOUND;
|
||||
public static Supplier<SoundEvent> TORETERROR_HURT = (Supplier<SoundEvent>) UNBOUND;
|
||||
public static Supplier<SoundEvent> TORETERROR_DEATH = (Supplier<SoundEvent>) UNBOUND;
|
||||
public static Supplier<SoundEvent> TORETERROR_BOMBER_FIRE = (Supplier<SoundEvent>) UNBOUND;
|
||||
public static Supplier<SoundEvent> STINKY_FLY = (Supplier<SoundEvent>) UNBOUND;
|
||||
public static Supplier<SoundEvent> CREEPING_HORROR_GROWL = (Supplier<SoundEvent>) UNBOUND;
|
||||
public static Supplier<SoundEvent> CREEPING_HORROR_HURT = (Supplier<SoundEvent>) UNBOUND;
|
||||
@@ -249,6 +253,10 @@ public final class AntarchySoundEvents {
|
||||
Supplier<SoundEvent> bomberWalk,
|
||||
Supplier<SoundEvent> bomberKnock,
|
||||
Supplier<SoundEvent> bomberExplode,
|
||||
Supplier<SoundEvent> toreterrorIdle,
|
||||
Supplier<SoundEvent> toreterrorHurt,
|
||||
Supplier<SoundEvent> toreterrorDeath,
|
||||
Supplier<SoundEvent> toreterrorBomberFire,
|
||||
Supplier<SoundEvent> stinkyFly,
|
||||
Supplier<SoundEvent> creepingHorrorGrowl,
|
||||
Supplier<SoundEvent> creepingHorrorHurt,
|
||||
@@ -372,6 +380,10 @@ public final class AntarchySoundEvents {
|
||||
BOMBER_WALK = bomberWalk;
|
||||
BOMBER_KNOCK = bomberKnock;
|
||||
BOMBER_EXPLODE = bomberExplode;
|
||||
TORETERROR_IDLE = toreterrorIdle;
|
||||
TORETERROR_HURT = toreterrorHurt;
|
||||
TORETERROR_DEATH = toreterrorDeath;
|
||||
TORETERROR_BOMBER_FIRE = toreterrorBomberFire;
|
||||
STINKY_FLY = stinkyFly;
|
||||
CREEPING_HORROR_GROWL = creepingHorrorGrowl;
|
||||
CREEPING_HORROR_HURT = creepingHorrorHurt;
|
||||
|
||||
@@ -155,7 +155,7 @@ public final class StinkyBehavior {
|
||||
}
|
||||
|
||||
private static void attractArthropod(Mob mob, LivingEntity source) {
|
||||
if (!isValidStinkySourceForMob(mob, source)) {
|
||||
if (!isValidStinkyAttackSourceForMob(mob, source)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public final class StinkyBehavior {
|
||||
}
|
||||
|
||||
private static void repelPassiveOrNeutralMob(Mob mob, LivingEntity source) {
|
||||
if (!(mob instanceof PathfinderMob pathfinderMob) || !isValidStinkySourceForMob(mob, source)) {
|
||||
if (!(mob instanceof PathfinderMob pathfinderMob) || !isValidStinkyRepelSourceForMob(mob, source)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,10 @@ public final class StinkyBehavior {
|
||||
return !(mob instanceof Enemy);
|
||||
}
|
||||
|
||||
private static boolean isValidStinkySourceForMob(Mob mob, LivingEntity source) {
|
||||
private static boolean isValidStinkyAttackSourceForMob(Mob mob, LivingEntity source) {
|
||||
if (!isValidStinkyRepelSourceForMob(mob, source)) {
|
||||
return false;
|
||||
}
|
||||
if (source == mob || !source.isAlive() || !source.hasEffect(AntarchyObjects.STINKY_EFFECT.get())) {
|
||||
return false;
|
||||
}
|
||||
@@ -205,4 +208,14 @@ public final class StinkyBehavior {
|
||||
return !mob.isAlliedTo(source);
|
||||
}
|
||||
|
||||
private static boolean isValidStinkyRepelSourceForMob(Mob mob, LivingEntity source) {
|
||||
if (source == mob || !source.isAlive() || !source.hasEffect(AntarchyObjects.STINKY_EFFECT.get())) {
|
||||
return false;
|
||||
}
|
||||
if (source instanceof Player player && player.isSpectator()) {
|
||||
return false;
|
||||
}
|
||||
return !mob.isAlliedTo(source);
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.craisinlord.antarchy.content.client;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.item.NightmareSwordItem;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public final class NightmareSwordTooltipHelper {
|
||||
private NightmareSwordTooltipHelper() {
|
||||
}
|
||||
|
||||
public static Component damageLine() {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
float damage = player != null
|
||||
? NightmareSwordItem.calculateDamage(player)
|
||||
: (float) AntarchySettings.nightmareSwordBaseDamage();
|
||||
return Component.translatable("tooltip.antarchy.nightmare_sword_damage", formatDamage(damage)).withStyle(ChatFormatting.RED);
|
||||
}
|
||||
|
||||
private static String formatDamage(float damage) {
|
||||
float rounded = Math.round(damage * 10.0F) / 10.0F;
|
||||
if (rounded == (int) rounded) {
|
||||
return String.valueOf((int) rounded);
|
||||
}
|
||||
return String.valueOf(rounded);
|
||||
}
|
||||
}
|
||||
@@ -353,6 +353,18 @@ public abstract class AppleCowEntity extends Cow implements GeoEntity, Shearable
|
||||
this.spawnAtLocation(new ItemStack(this.shearDropItem(), 2), this.getBbHeight() * 0.66F);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropCustomDeathLoot(ServerLevel level, net.minecraft.world.damagesource.DamageSource damageSource, boolean recentlyHit) {
|
||||
super.dropCustomDeathLoot(level, damageSource, recentlyHit);
|
||||
|
||||
if (this.isBaby() || this.isSheared()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int count = this instanceof AppleCowEntityVariants.EnchantedGoldenAppleCow ? 1 : 1 + this.random.nextInt(2);
|
||||
this.spawnAtLocation(new ItemStack(this.shearDropItem(), count));
|
||||
}
|
||||
|
||||
private net.minecraft.world.item.Item shearDropItem() {
|
||||
if (this instanceof AppleCowEntityVariants.EnchantedGoldenAppleCow) {
|
||||
return Items.ENCHANTED_GOLDEN_APPLE;
|
||||
|
||||
+34
-18
@@ -2,6 +2,7 @@ package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -78,7 +79,7 @@ public class ToreterrorEntity extends Monster implements GeoEntity {
|
||||
private static final int RAPID_FIRE_END_TICK = 60;
|
||||
private static final int SHOOT_BOMBER_TICK = 12;
|
||||
private static final int SHOOT_BOMBER_SECOND_TICK = 32;
|
||||
private static final int JUMP_TOTAL_TICKS = 55;
|
||||
private static final int JUMP_TOTAL_TICKS = 40;
|
||||
private static final int JUMP_LAUNCH_TICK = 10;
|
||||
private static final int JUMP_SHAKE_TICKS = 12;
|
||||
private static final int SPIN_START_TOTAL_TICKS = 5;
|
||||
@@ -93,8 +94,8 @@ public class ToreterrorEntity extends Monster implements GeoEntity {
|
||||
private static final double RANGED_MAX_RANGE_SQR = 625.0D;
|
||||
private static final double SPIN_TRIGGER_RANGE_SQR = 225.0D;
|
||||
private static final double SPIN_LEASH_RANGE_SQR = 225.0D;
|
||||
private static final double SPIN_RADIUS = 4.5D;
|
||||
private static final double SPIN_MOVE_SPEED = 0.833D;
|
||||
private static final double SPIN_RADIUS = 2.5D;
|
||||
private static final double SPIN_MOVE_SPEED = 0.65D;
|
||||
private static final double SPIN_ANIMATION_SPEED = 0.49D;
|
||||
private static final double JUMP_SHOCKWAVE_RADIUS = 6.0D;
|
||||
|
||||
@@ -145,7 +146,8 @@ public class ToreterrorEntity extends Monster implements GeoEntity {
|
||||
.add(Attributes.MOVEMENT_SPEED, 0.325D)
|
||||
.add(Attributes.FOLLOW_RANGE, 48.0D)
|
||||
.add(Attributes.KNOCKBACK_RESISTANCE, 0.85D)
|
||||
.add(Attributes.ARMOR, 10.0D);
|
||||
.add(Attributes.ARMOR, 16.0D)
|
||||
.add(Attributes.ARMOR_TOUGHNESS, 4.0D);
|
||||
}
|
||||
|
||||
public static boolean canSpawn(EntityType<ToreterrorEntity> entityType, ServerLevelAccessor level, MobSpawnType spawnReason, BlockPos pos, net.minecraft.util.RandomSource random) {
|
||||
@@ -284,7 +286,22 @@ public class ToreterrorEntity extends Monster implements GeoEntity {
|
||||
return this.entityData.get(JUMP_SHAKING);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected net.minecraft.sounds.SoundEvent getAmbientSound() {
|
||||
return AntarchySoundEvents.TORETERROR_IDLE.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected net.minecraft.sounds.SoundEvent getHurtSound(DamageSource damageSource) {
|
||||
return AntarchySoundEvents.TORETERROR_HURT.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected net.minecraft.sounds.SoundEvent getDeathSound() {
|
||||
return AntarchySoundEvents.TORETERROR_DEATH.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSeenByPlayer(ServerPlayer player) {
|
||||
super.startSeenByPlayer(player);
|
||||
this.bossEvent.addPlayer(player);
|
||||
@@ -423,7 +440,7 @@ public class ToreterrorEntity extends Monster implements GeoEntity {
|
||||
LivingEntity target = this.getTarget();
|
||||
if (target != null) {
|
||||
Vec3 toTarget = target.position().subtract(this.position()).normalize();
|
||||
this.setDeltaMovement(toTarget.x * 0.6D, 1.4D, toTarget.z * 0.6D);
|
||||
this.setDeltaMovement(toTarget.x * 0.6D, 1.15D, toTarget.z * 0.6D);
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
}
|
||||
@@ -431,20 +448,18 @@ public class ToreterrorEntity extends Monster implements GeoEntity {
|
||||
this.jumpAirborne = true;
|
||||
}
|
||||
if (this.jumpLaunched && this.jumpAirborne && !this.shockwaveApplied) {
|
||||
boolean forceLand = this.jumpAnimTicks <= 1;
|
||||
if (forceLand) {
|
||||
BlockPos pos = BlockPos.containing(this.getX(), this.getY(), this.getZ());
|
||||
while (pos.getY() > this.level().getMinBuildHeight() && this.level().isEmptyBlock(pos)) {
|
||||
pos = pos.below();
|
||||
}
|
||||
this.teleportTo(this.getX(), pos.getY() + 1.0, this.getZ());
|
||||
this.setDeltaMovement(Vec3.ZERO);
|
||||
}
|
||||
if (this.onGround() || forceLand) {
|
||||
if (this.onGround()) {
|
||||
this.shockwaveApplied = true;
|
||||
this.applyJumpShockwave();
|
||||
this.jumpShakeTicks = JUMP_SHAKE_TICKS;
|
||||
this.entityData.set(JUMP_SHAKING, true);
|
||||
} else if (this.jumpAnimTicks <= 10) {
|
||||
Vec3 vel = this.getDeltaMovement();
|
||||
this.setDeltaMovement(vel.x * 0.5D, Math.min(vel.y, -1.5D), vel.z * 0.5D);
|
||||
this.hasImpulse = true;
|
||||
if (this.jumpAnimTicks <= 2) {
|
||||
this.jumpAnimTicks = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.jumpAnimTicks--;
|
||||
@@ -517,7 +532,7 @@ public class ToreterrorEntity extends Monster implements GeoEntity {
|
||||
this.spinEndTicks--;
|
||||
if (this.spinEndTicks <= 0) {
|
||||
this.stopSpinSequence();
|
||||
this.spinCooldown = 260 + this.random.nextInt(80);
|
||||
this.spinCooldown = 340 + this.random.nextInt(80);
|
||||
this.spinHitCooldowns.clear();
|
||||
}
|
||||
}
|
||||
@@ -532,7 +547,7 @@ public class ToreterrorEntity extends Monster implements GeoEntity {
|
||||
return;
|
||||
}
|
||||
Vec3 forward = this.spinDirection.lengthSqr() > 1.0E-4D ? this.spinDirection.normalize() : towardTarget;
|
||||
Vec3 combined = forward.scale(0.95D).add(towardTarget.scale(0.05D));
|
||||
Vec3 combined = forward.scale(0.99D).add(towardTarget.scale(0.01D));
|
||||
this.spinDirection = combined.lengthSqr() > 1.0E-4D ? combined.normalize() : towardTarget;
|
||||
}
|
||||
|
||||
@@ -703,6 +718,7 @@ public class ToreterrorEntity extends Monster implements GeoEntity {
|
||||
if (!(this.level() instanceof ServerLevel serverLevel)) return;
|
||||
LivingEntity target = this.getTarget();
|
||||
if (target == null) return;
|
||||
this.playSound(AntarchySoundEvents.TORETERROR_BOMBER_FIRE.get(), 1.1F, 0.9F + this.random.nextFloat() * 0.15F);
|
||||
int count = 3;
|
||||
for (int i = 0; i < count; i++) {
|
||||
BomberEntity bomber = AntarchyObjects.BOMBER.get().create(this.level());
|
||||
|
||||
+73
-2
@@ -1,18 +1,24 @@
|
||||
package com.craisinlord.antarchy.content.entity.ant;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.PlayerRespawnLogic;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.OwnableEntity;
|
||||
import net.minecraft.world.entity.TamableAnimal;
|
||||
import net.minecraft.world.entity.animal.horse.AbstractHorse;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.vehicle.DismountHelper;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -20,13 +26,78 @@ import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.minecraft.world.level.portal.DimensionTransition;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class AntTeleportHelper {
|
||||
private static final double COMPANION_FOLLOW_RADIUS = 16.0D;
|
||||
|
||||
private AntTeleportHelper() {
|
||||
}
|
||||
|
||||
public static void teleportPlayerWithCompanions(ServerPlayer player, ServerLevel destination, Vec3 destinationPos) {
|
||||
Mob vehicle = player.getVehicle() instanceof Mob mob ? mob : null;
|
||||
List<Mob> companions = collectCompanions(player);
|
||||
player.teleportTo(destination, destinationPos.x, destinationPos.y, destinationPos.z, player.getYRot(), player.getXRot());
|
||||
Mob movedVehicle = null;
|
||||
for (Mob companion : companions) {
|
||||
Mob moved = moveCompanion(companion, destination, destinationPos);
|
||||
if (companion == vehicle) {
|
||||
movedVehicle = moved;
|
||||
}
|
||||
}
|
||||
|
||||
if (movedVehicle != null) {
|
||||
player.startRiding(movedVehicle, true);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Mob> collectCompanions(ServerPlayer player) {
|
||||
List<Mob> companions = new ArrayList<>();
|
||||
if (player.getVehicle() instanceof Mob vehicle) {
|
||||
companions.add(vehicle);
|
||||
}
|
||||
|
||||
for (Mob mob : player.serverLevel().getEntitiesOfClass(Mob.class, player.getBoundingBox().inflate(COMPANION_FOLLOW_RADIUS), mob -> isFollowingPet(mob, player))) {
|
||||
if (!companions.contains(mob)) {
|
||||
companions.add(mob);
|
||||
}
|
||||
}
|
||||
|
||||
return companions;
|
||||
}
|
||||
|
||||
private static boolean isFollowingPet(Mob mob, ServerPlayer player) {
|
||||
if (!mob.isAlive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mob instanceof TamableAnimal tamable) {
|
||||
return tamable.isTame() && player.getUUID().equals(tamable.getOwnerUUID()) && !tamable.isOrderedToSit();
|
||||
}
|
||||
|
||||
if (mob instanceof AbstractHorse horse) {
|
||||
return horse.isTamed() && player.getUUID().equals(horse.getOwnerUUID());
|
||||
}
|
||||
|
||||
return mob instanceof OwnableEntity ownable && player.getUUID().equals(ownable.getOwnerUUID());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Mob moveCompanion(Mob companion, ServerLevel destination, Vec3 destinationPos) {
|
||||
companion.stopRiding();
|
||||
companion.ejectPassengers();
|
||||
companion.getNavigation().stop();
|
||||
if (companion.level() == destination) {
|
||||
companion.teleportTo(destinationPos.x, destinationPos.y, destinationPos.z);
|
||||
return companion;
|
||||
}
|
||||
|
||||
Entity moved = companion.changeDimension(new DimensionTransition(destination, destinationPos, Vec3.ZERO, companion.getYRot(), companion.getXRot(), DimensionTransition.DO_NOTHING));
|
||||
return moved instanceof Mob mob ? mob : null;
|
||||
}
|
||||
|
||||
static InteractionResult handleInteraction(BaseAntEntity ant, Player player, ItemStack itemStack) {
|
||||
if (ant.requiresActivationReagent() && !ant.isTeleportActivatedState()) {
|
||||
if (!(player instanceof ServerPlayer serverPlayer)) {
|
||||
@@ -62,7 +133,7 @@ public final class AntTeleportHelper {
|
||||
}
|
||||
|
||||
Vec3 destinationPos = getDestinationPosition(serverPlayer, destination);
|
||||
serverPlayer.teleportTo(destination, destinationPos.x, destinationPos.y, destinationPos.z, serverPlayer.getYRot(), serverPlayer.getXRot());
|
||||
teleportPlayerWithCompanions(serverPlayer, destination, destinationPos);
|
||||
serverPlayer.playSound(SoundEvents.ENDERMAN_TELEPORT, 1.0F, 1.0F);
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.craisinlord.antarchy.content.item;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.client.NightmareSwordTooltipHelper;
|
||||
import java.util.List;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.SwordItem;
|
||||
@@ -21,6 +23,18 @@ public class NightmareSwordItem extends SwordItem {
|
||||
this.attackSpeed = attackSpeed;
|
||||
}
|
||||
|
||||
public static float calculateDamage(LivingEntity attacker) {
|
||||
float baseDamage = (float) AntarchySettings.nightmareSwordBaseDamage();
|
||||
float maxHealth = attacker.getMaxHealth();
|
||||
if (maxHealth <= 0.0F) {
|
||||
return baseDamage;
|
||||
}
|
||||
|
||||
float missingFraction = (maxHealth - attacker.getHealth()) / maxHealth;
|
||||
float scalingFactor = (float) AntarchySettings.nightmareSwordScalingFactor();
|
||||
return baseDamage + missingFraction * scalingFactor * baseDamage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemAttributeModifiers getDefaultAttributeModifiers() {
|
||||
return SwordItem.createAttributes(
|
||||
@@ -38,6 +52,7 @@ public class NightmareSwordItem extends SwordItem {
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
|
||||
tooltipComponents.add(Component.translatable("tooltip.antarchy.nightmare_sword").withStyle(ChatFormatting.DARK_RED));
|
||||
tooltipComponents.add(NightmareSwordTooltipHelper.damageLine());
|
||||
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.craisinlord.antarchy.mixins;
|
||||
|
||||
import com.craisinlord.antarchy.content.item.NightmareSwordItem;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public abstract class NightmareSwordDamageMixin {
|
||||
@ModifyVariable(method = "hurt", at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
private float antarchy$applyNightmareSwordDamage(float amount, DamageSource source) {
|
||||
LivingEntity self = (LivingEntity) (Object) this;
|
||||
if (self.level().isClientSide) {
|
||||
return amount;
|
||||
}
|
||||
|
||||
if (!(source.getEntity() instanceof Player attacker)) {
|
||||
return amount;
|
||||
}
|
||||
|
||||
if (!(attacker.getMainHandItem().getItem() instanceof NightmareSwordItem)) {
|
||||
return amount;
|
||||
}
|
||||
|
||||
return NightmareSwordItem.calculateDamage(attacker);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user