Skip to content

Commit

Permalink
(2) I don't even know at this point
Browse files Browse the repository at this point in the history
  • Loading branch information
Electro593 committed Jan 31, 2025
1 parent a3fd8b0 commit 5fd5306
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Optional<Fluid> fluid() {
return Optional.ofNullable(this.fluid);
}
public Optional<TagKey<Fluid>> tag() {
return Optional.of(TagKey.of(RegistryKeys.FLUID, this.tag));
return Registries.FLUID.streamTags().filter(tagKey -> tagKey.id().equals(this.tag)).findFirst();
}
public boolean isTag() {
return this.tag != null;
Expand Down
50 changes: 0 additions & 50 deletions src/main/java/de/dafuqs/spectrum/mixin/MiningToolItemMixin.java

This file was deleted.

47 changes: 44 additions & 3 deletions src/main/java/de/dafuqs/spectrum/mixin/PlayerEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import de.dafuqs.spectrum.api.entity.*;
import de.dafuqs.spectrum.api.item.*;
import de.dafuqs.spectrum.cca.*;
import de.dafuqs.spectrum.components.*;
import de.dafuqs.spectrum.entity.entity.*;
import de.dafuqs.spectrum.helpers.*;
import de.dafuqs.spectrum.helpers.enchantments.*;
Expand All @@ -17,6 +18,9 @@
import de.dafuqs.spectrum.progression.*;
import de.dafuqs.spectrum.registries.*;
import de.dafuqs.spectrum.status_effects.*;
import net.minecraft.block.*;
import net.minecraft.component.*;
import net.minecraft.component.type.*;
import net.minecraft.enchantment.*;
import net.minecraft.entity.*;
import net.minecraft.entity.attribute.*;
Expand All @@ -25,6 +29,7 @@
import net.minecraft.entity.player.*;
import net.minecraft.item.*;
import net.minecraft.particle.*;
import net.minecraft.registry.*;
import net.minecraft.registry.entry.*;
import net.minecraft.registry.tag.*;
import net.minecraft.server.network.*;
Expand Down Expand Up @@ -57,9 +62,44 @@ protected PlayerEntityMixin(EntityType<? extends LivingEntity> entityType, World
@Shadow
protected abstract boolean canChangeIntoPose(EntityPose pose);

@Shadow
@Final
private PlayerInventory inventory;
@Unique
public SpectrumFishingBobberEntity fishingBobber;

@WrapOperation(method = "getBlockBreakingSpeed(Lnet/minecraft/block/BlockState;)F", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;getBlockBreakingSpeed(Lnet/minecraft/block/BlockState;)F"))
private float yourHandlerMethod(PlayerInventory inventory, BlockState state, Operation<Float> original) {
ItemStack stack = inventory.main.get(inventory.selectedSlot);
DynamicRegistryManager drm = getRegistryManager();
ToolComponent tool = stack.get(DataComponentTypes.TOOL);
float speed = original.call(inventory, state);

// RAZING GAMING
int razingLevel = SpectrumEnchantmentHelper.getLevel(drm, SpectrumEnchantments.RAZING, stack);
if (razingLevel > 0 && tool != null && tool.getSpeed(state) > tool.defaultMiningSpeed()) {
float hardness = state.getBlock().getHardness();
speed = (float) Math.max(1 + hardness, Math.pow(2, 1 + razingLevel / 8F));
}

// INERTIA GAMING
// inertia mining speed calculation logic is capped at 5 levels.
// Higher and the formula would do weird stuff
int inertiaLevel = SpectrumEnchantmentHelper.getLevel(drm, SpectrumEnchantments.INERTIA, stack);
inertiaLevel = Math.min(4, inertiaLevel);
if (inertiaLevel > 0) {
var inertia = stack.getOrDefault(SpectrumDataComponentTypes.INERTIA, InertiaComponent.DEFAULT);
if (state.isOf(inertia.lastMined())) {
var additionalSpeedPercent = 2.0 * Math.log(inertia.count()) / Math.log((6 - inertiaLevel) * (6 - inertiaLevel) + 1);
speed *= 0.5F + (float) additionalSpeedPercent;
} else {
speed /= 4;
}
}

return speed;
}

@Inject(method = "updateSwimming()V", at = @At("HEAD"), cancellable = true)
public void spectrum$updateSwimming(CallbackInfo ci) {
if (SpectrumTrinketItem.hasEquipped(this, SpectrumItems.RING_OF_DENSER_STEPS)) {
Expand Down Expand Up @@ -145,7 +185,7 @@ protected PlayerEntityMixin(EntityType<? extends LivingEntity> entityType, World
return value;
}

@Inject(method = "attack(Lnet/minecraft/entity/Entity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/enchantment/EnchantmentHelper;getFireAspect(Lnet/minecraft/entity/LivingEntity;)I"))
@Inject(method = "attack(Lnet/minecraft/entity/Entity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getVelocity()Lnet/minecraft/util/math/Vec3d;"))
private void spectrum$perfectCounter(Entity target, CallbackInfo ci, @Local(ordinal = 0) LocalFloatRef damage) {
var player = (PlayerEntity) (Object) this;
if (MiscPlayerDataComponent.get(player).consumePerfectCounter()) {
Expand Down Expand Up @@ -257,7 +297,7 @@ public int addExperience(int experience) {
}

@ModifyVariable(method = "getBlockBreakingSpeed",
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z"),
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;hasStatusEffect(Lnet/minecraft/registry/entry/RegistryEntry;)Z"),
to = @At("TAIL")
),
at = @At(value = "LOAD"),
Expand All @@ -276,7 +316,8 @@ public float applyInexorableAntiSlowdowns(float original) {
var player = (PlayerEntity) (Object) this;
var f = original;

if (player.isSubmergedIn(FluidTags.WATER) && !EnchantmentHelper.hasAquaAffinity(player))
boolean hasAquaAffinity = SpectrumEnchantmentHelper.getEquipmentLevel(player.getWorld().getRegistryManager(), Enchantments.AQUA_AFFINITY, player) > 0;
if (player.isSubmergedIn(FluidTags.WATER) && !hasAquaAffinity)
f *= 5;

if (!player.isOnGround())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import de.dafuqs.spectrum.cca.*;
import de.dafuqs.spectrum.registries.*;
import net.minecraft.entity.*;
import net.minecraft.entity.attribute.*;
import net.minecraft.entity.effect.*;
import net.minecraft.entity.player.*;
import net.minecraft.registry.entry.*;
Expand All @@ -17,7 +16,7 @@ public SleepStatusEffect(StatusEffectCategory category, int color, boolean scale
super(category, color);
this.scales = scales;
}
// oh my god
// TODO: can the tag check be implemented into the entities base attribute modifier somehow?
public static float getSleepResistance(@Nullable StatusEffectInstance sleepEffect, LivingEntity entity) {
Expand Down Expand Up @@ -97,10 +96,11 @@ else if (entity.hasStatusEffect(SpectrumStatusEffects.SOMNOLENCE)) {
}

// Sleep effects don't scale except for uh, calming ufck
@Override
public double adjustModifierAmount(int amplifier, EntityAttributeModifier modifier) {
if (scales)
return super.adjustModifierAmount(amplifier, modifier);
return modifier.getValue();
}
//TODO verify that you can't more than one level of eternal or fatal slumber
// @Override
// public double adjustModifierAmount(int amplifier, EntityAttributeModifier modifier) {
// if (scales)
// return super.adjustModifierAmount(amplifier, modifier);
// return modifier.getValue();
// }
}
1 change: 0 additions & 1 deletion src/main/resources/spectrum.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"MapStateMixin",
"MapStatePlayerUpdateTrackerMixin",
"MC252934Mixin",
"MiningToolItemMixin",
"MobEntityMixin",
"NoteBlockMixin",
"PiglinBrainMixin",
Expand Down

0 comments on commit 5fd5306

Please sign in to comment.