Update mixins

This commit is contained in:
DBotThePony 2024-08-26 20:14:46 +07:00
parent cb276da292
commit e3990d7fb5
Signed by: DBot
GPG Key ID: DCC23B5715498507
18 changed files with 157 additions and 134 deletions

View File

@ -16,7 +16,8 @@ import ru.dbotthepony.mc.otm.core.MultiblockKt;
public abstract class BlockEntityMixin { public abstract class BlockEntityMixin {
@Inject( @Inject(
at = @At("TAIL"), at = @At("TAIL"),
method = "setRemoved()V" method = "setRemoved()V",
remap = false
) )
public void setRemovedListener(CallbackInfo ci) { public void setRemovedListener(CallbackInfo ci) {
MultiblockKt.onBlockEntityInvalidated((BlockEntity) (Object) this); MultiblockKt.onBlockEntityInvalidated((BlockEntity) (Object) this);

View File

@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu;
@Mixin(DispenserBlockEntity.class) @Mixin(DispenserBlockEntity.class)
public abstract class DispenserBlockEntityMixin { public abstract class DispenserBlockEntityMixin {
@Overwrite @Overwrite(remap = false)
public AbstractContainerMenu createMenu(int p_59312_, Inventory p_59313_) { public AbstractContainerMenu createMenu(int p_59312_, Inventory p_59313_) {
return MatteryChestMenu.c3x3(p_59312_, p_59313_, (DispenserBlockEntity) (Object) this); return MatteryChestMenu.c3x3(p_59312_, p_59313_, (DispenserBlockEntity) (Object) this);
} }

View File

@ -1,24 +0,0 @@
package ru.dbotthepony.mc.otm.mixin;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem;
@Mixin(EnchantmentHelper.class)
public class EnchantmentHelperMixin {
@Inject(
method = "getSweepingDamageRatio(Lnet/minecraft/world/entity/LivingEntity;)F",
at = @At("HEAD"),
cancellable = true)
private static void getSweepingDamageRatio(LivingEntity p_44822_, CallbackInfoReturnable<Float> info) {
var result = EnergySwordItem.getSweepingDamageRatioHook(p_44822_);
if (result != null) {
info.setReturnValue(result);
}
}
}

View File

@ -8,42 +8,44 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.dbotthepony.mc.otm.capability.IMatteryPlayer;
import ru.dbotthepony.mc.otm.capability.MatteryCapability; import ru.dbotthepony.mc.otm.capability.MatteryCapability;
@Mixin(FoodData.class) @Mixin(FoodData.class)
public class FoodDataMixin { public class FoodDataMixin {
@Shadow @Shadow(remap = false)
private int lastFoodLevel; private int lastFoodLevel;
@Shadow @Shadow(remap = false)
private int tickTimer; private int tickTimer;
@Shadow @Shadow(remap = false)
private int foodLevel; private int foodLevel;
@Shadow @Shadow(remap = false)
private float exhaustionLevel; private float exhaustionLevel;
@Inject( @Inject(
method = "tick(Lnet/minecraft/world/entity/player/Player;)V", method = "tick(Lnet/minecraft/world/entity/player/Player;)V",
at = @At("HEAD"), at = @At("HEAD"),
remap = false,
cancellable = true cancellable = true
) )
private void tick(Player player, CallbackInfo info) { private void tick(Player player, CallbackInfo info) {
player.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(it -> { var it = ((IMatteryPlayer) player).getOtmPlayer();
if (it.isAndroid()) {
info.cancel();
// полностью подменяем логику если андроид if (it.isAndroid()) {
lastFoodLevel = foodLevel; info.cancel();
if (player.level().getDifficulty() == Difficulty.PEACEFUL) { // полностью подменяем логику если андроид
exhaustionLevel = 0f; lastFoodLevel = foodLevel;
} else {
tickTimer = 0;
}
// не обновляем уровень истощения ибо он обнуляется логикой внутри MatteryPlayerCapability if (player.level().getDifficulty() == Difficulty.PEACEFUL) {
// а так же не регенерируем exhaustionLevel = 0f;
// ну и не получаем урон от "голодания" } else {
tickTimer = 0;
} }
});
// не обновляем уровень истощения ибо он обнуляется логикой внутри MatteryPlayerCapability
// а так же не регенерируем
// ну и не получаем урон от "голодания"
}
} }
} }

View File

@ -12,13 +12,13 @@ import static ru.dbotthepony.mc.otm.client.render.RenderHelperKt.pushScissorRect
// mostly because it is not a stack at all. // mostly because it is not a stack at all.
@Mixin(GuiGraphics.class) @Mixin(GuiGraphics.class)
public abstract class GuiGraphicsMixin { public abstract class GuiGraphicsMixin {
@Overwrite @Overwrite(remap = false)
public void enableScissor(int x0, int y0, int x1, int y1) { public void enableScissor(int x0, int y0, int x1, int y1) {
double scale = Minecraft.getInstance().getWindow().getGuiScale(); double scale = Minecraft.getInstance().getWindow().getGuiScale();
pushScissorRect((int) (scale * x0), (int) (scale * y0), (int) (scale * (x1 - x0)), (int) (scale * (y1 - y0))); pushScissorRect((int) (scale * x0), (int) (scale * y0), (int) (scale * (x1 - x0)), (int) (scale * (y1 - y0)));
} }
@Overwrite @Overwrite(remap = false)
public void disableScissor() { public void disableScissor() {
popScissorRect(); popScissorRect();
} }

View File

@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu;
@Mixin(HopperBlockEntity.class) @Mixin(HopperBlockEntity.class)
public abstract class HopperBlockEntityMixin { public abstract class HopperBlockEntityMixin {
@Overwrite @Overwrite(remap = false)
public AbstractContainerMenu createMenu(int p_59312_, Inventory p_59313_) { public AbstractContainerMenu createMenu(int p_59312_, Inventory p_59313_) {
return MatteryChestMenu.hopper(p_59312_, p_59313_, (HopperBlockEntity) (Object) this); return MatteryChestMenu.hopper(p_59312_, p_59313_, (HopperBlockEntity) (Object) this);
} }

View File

@ -10,12 +10,12 @@ import ru.dbotthepony.mc.otm.triggers.MatteryInventoryChangeTrigger;
@Mixin(InventoryChangeTrigger.class) @Mixin(InventoryChangeTrigger.class)
public abstract class InventoryChangeTriggerMixin { public abstract class InventoryChangeTriggerMixin {
@Overwrite @Overwrite(remap = false)
public void trigger(ServerPlayer p_43150_, Inventory p_43151_, ItemStack p_43152_) { public void trigger(ServerPlayer p_43150_, Inventory p_43151_, ItemStack p_43152_) {
MatteryInventoryChangeTrigger.INSTANCE.trigger(p_43150_, p_43151_, p_43152_); MatteryInventoryChangeTrigger.INSTANCE.trigger(p_43150_, p_43151_, p_43152_);
} }
@Overwrite @Overwrite(remap = false)
private void trigger(ServerPlayer p_43154_, Inventory p_43155_, ItemStack p_43156_, int p_43157_, int p_43158_, int p_43159_) { private void trigger(ServerPlayer p_43154_, Inventory p_43155_, ItemStack p_43156_, int p_43157_, int p_43158_, int p_43159_) {
MatteryInventoryChangeTrigger.INSTANCE.trigger(p_43154_, p_43155_, p_43156_, p_43157_, p_43158_, p_43159_); MatteryInventoryChangeTrigger.INSTANCE.trigger(p_43154_, p_43155_, p_43156_, p_43157_, p_43158_, p_43159_);
} }

View File

@ -8,29 +8,26 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.dbotthepony.mc.otm.capability.IMatteryPlayer;
import ru.dbotthepony.mc.otm.capability.MatteryCapability; import ru.dbotthepony.mc.otm.capability.MatteryCapability;
import ru.dbotthepony.mc.otm.registry.MSoundEvents; import ru.dbotthepony.mc.otm.registry.MSoundEvents;
@Mixin(AbstractHurtingProjectile.class) @Mixin(AbstractHurtingProjectile.class)
public class MixinAbstractHurtingProjectile { public class MixinAbstractHurtingProjectile {
@Inject( @Inject(
method = "hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z", method = "onDeflection(Lnet/minecraft/world/entity/Entity;Z)V",
at = @At( remap = false,
value = "INVOKE", at = @At("TAIL")
target = "Lnet/minecraft/world/entity/projectile/AbstractHurtingProjectile;markHurt()V",
ordinal = 0
)
) )
public void onProjectileHit(DamageSource pSource, float pAmount, CallbackInfoReturnable<Boolean> cir) { public void onDeflection(Entity entity, boolean byAttack, CallbackInfoReturnable<Boolean> cir) {
Entity entity = pSource.getEntity(); if (entity instanceof IMatteryPlayer player) {
if (entity == null) return; var cap = player.getOtmPlayer();
entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(cap -> {
AbstractHurtingProjectile proj = (AbstractHurtingProjectile)(Object)this; AbstractHurtingProjectile proj = (AbstractHurtingProjectile)(Object)this;
if (cap.isAndroid() && proj.getOwner() != entity) { if (cap.isAndroid() && proj.getOwner() != entity) {
entity.level().playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level().random.nextFloat() * 0.1f); entity.level().playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level().random.nextFloat() * 0.1f);
} }
}); }
} }
} }

View File

@ -14,6 +14,7 @@ public class MixinAnvilBlock {
@Inject( @Inject(
method = "damage(Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/level/block/state/BlockState;", method = "damage(Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/level/block/state/BlockState;",
at = @At("HEAD"), at = @At("HEAD"),
remap = false,
cancellable = true) cancellable = true)
private static void damage(BlockState pState, CallbackInfoReturnable<BlockState> info) { private static void damage(BlockState pState, CallbackInfoReturnable<BlockState> info) {
var list = MBlocks.INSTANCE.getTRITANIUM_ANVIL(); var list = MBlocks.INSTANCE.getTRITANIUM_ANVIL();

View File

@ -13,8 +13,10 @@ import ru.dbotthepony.mc.otm.client.render.RenderHelperKt;
public class MixinGameRenderer { public class MixinGameRenderer {
@Inject( @Inject(
method = "render(FJZ)V", method = "render(FJZ)V",
remap = false,
at = @At( at = @At(
value = "INVOKE", value = "INVOKE",
remap = false,
target = "Lcom/mojang/blaze3d/pipeline/RenderTarget;bindWrite(Z)V" target = "Lcom/mojang/blaze3d/pipeline/RenderTarget;bindWrite(Z)V"
) )
) )
@ -24,6 +26,7 @@ public class MixinGameRenderer {
@Inject( @Inject(
method = "reloadShaders(Lnet/minecraft/server/packs/resources/ResourceProvider;)V", method = "reloadShaders(Lnet/minecraft/server/packs/resources/ResourceProvider;)V",
remap = false,
at = @At("HEAD") at = @At("HEAD")
) )
private void reloadShaders(ResourceProvider p_250719_, CallbackInfo ci) { private void reloadShaders(ResourceProvider p_250719_, CallbackInfo ci) {

View File

@ -3,13 +3,13 @@ package ru.dbotthepony.mc.otm.mixin;
import net.minecraft.CrashReport; import net.minecraft.CrashReport;
import net.minecraft.CrashReportCategory; import net.minecraft.CrashReportCategory;
import net.minecraft.ReportedException; import net.minecraft.ReportedException;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.Container; import net.minecraft.world.Container;
import net.minecraft.world.ContainerHelper; import net.minecraft.world.ContainerHelper;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.registries.ForgeRegistries;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@ -17,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.dbotthepony.mc.otm.capability.MatteryCapability; import ru.dbotthepony.mc.otm.capability.IMatteryPlayer;
import ru.dbotthepony.mc.otm.capability.MatteryPlayer; import ru.dbotthepony.mc.otm.capability.MatteryPlayer;
import java.util.function.Predicate; import java.util.function.Predicate;
@ -25,12 +25,13 @@ import java.util.function.Predicate;
@Mixin(Inventory.class) @Mixin(Inventory.class)
public class MixinInventory { public class MixinInventory {
@Final @Final
@Shadow @Shadow(remap = false)
public Player player; public Player player;
@Inject( @Inject(
method = "add(ILnet/minecraft/world/item/ItemStack;)Z", method = "add(ILnet/minecraft/world/item/ItemStack;)Z",
at = @At("HEAD"), at = @At("HEAD"),
remap = false,
cancellable = true cancellable = true
) )
private void add(int pSlot, ItemStack pStack, CallbackInfoReturnable<Boolean> hook) { private void add(int pSlot, ItemStack pStack, CallbackInfoReturnable<Boolean> hook) {
@ -39,25 +40,24 @@ public class MixinInventory {
} }
if (pSlot == -1) { if (pSlot == -1) {
this.player.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(it -> { try {
try { hook.setReturnValue(((IMatteryPlayer) this.player).getOtmPlayer().inventoryAddImpl(pStack));
hook.setReturnValue(it.inventoryAddImpl(pStack)); } catch (Throwable throwable) {
} catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Adding item to inventory (Overdrive That Matters detour)");
CrashReport crashreport = CrashReport.forThrowable(throwable, "Adding item to inventory (Overdrive That Matters detour)"); CrashReportCategory crashreportcategory = crashreport.addCategory("Item being added");
CrashReportCategory crashreportcategory = crashreport.addCategory("Item being added"); crashreportcategory.setDetail("Registry Name", () -> String.valueOf(BuiltInRegistries.ITEM.getKey(pStack.getItem())));
crashreportcategory.setDetail("Registry Name", () -> String.valueOf(ForgeRegistries.ITEMS.getKey(pStack.getItem()))); crashreportcategory.setDetail("Item Class", () -> pStack.getItem().getClass().getName());
crashreportcategory.setDetail("Item Class", () -> pStack.getItem().getClass().getName()); crashreportcategory.setDetail("Item ID", Item.getId(pStack.getItem()));
crashreportcategory.setDetail("Item ID", Item.getId(pStack.getItem())); crashreportcategory.setDetail("Item data", pStack.getDamageValue());
crashreportcategory.setDetail("Item data", pStack.getDamageValue()); crashreportcategory.setDetail("Item name", () -> pStack.getHoverName().getString());
crashreportcategory.setDetail("Item name", () -> pStack.getHoverName().getString()); throw new ReportedException(crashreport);
throw new ReportedException(crashreport); }
}
});
} }
} }
@Inject( @Inject(
method = "dropAll()V", method = "dropAll()V",
remap = false,
at = @At("TAIL") at = @At("TAIL")
) )
private void dropAll(CallbackInfo ci) { private void dropAll(CallbackInfo ci) {
@ -66,6 +66,7 @@ public class MixinInventory {
@Inject( @Inject(
method = "clearContent()V", method = "clearContent()V",
remap = false,
at = @At("TAIL") at = @At("TAIL")
) )
private void clearContent(CallbackInfo ci) { private void clearContent(CallbackInfo ci) {
@ -74,17 +75,17 @@ public class MixinInventory {
@Inject( @Inject(
method = "clearOrCountMatchingItems(Ljava/util/function/Predicate;ILnet/minecraft/world/Container;)I", method = "clearOrCountMatchingItems(Ljava/util/function/Predicate;ILnet/minecraft/world/Container;)I",
remap = false,
at = @At("RETURN"), at = @At("RETURN"),
cancellable = true cancellable = true
) )
private void clearOrCountMatchingItems(Predicate<ItemStack> predicate, int count, Container container, CallbackInfoReturnable<Integer> cir) { private void clearOrCountMatchingItems(Predicate<ItemStack> predicate, int count, Container container, CallbackInfoReturnable<Integer> cir) {
player.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(it -> { var it = ((IMatteryPlayer) this.player).getOtmPlayer();
if (!it.getHasExopack()) return; if (!it.getHasExopack()) return;
int i = cir.getReturnValue(); int i = cir.getReturnValue();
i += ContainerHelper.clearOrCountMatchingItems(it.getExopackContainer(), predicate, count - i, count == 0); i += ContainerHelper.clearOrCountMatchingItems(it.getExopackContainer(), predicate, count - i, count == 0);
cir.setReturnValue(i); cir.setReturnValue(i);
});
} }
} }

View File

@ -1,14 +1,16 @@
package ru.dbotthepony.mc.otm.mixin; package ru.dbotthepony.mc.otm.mixin;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraftforge.event.ForgeEventFactory; import net.neoforged.neoforge.event.EventHooks;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.dbotthepony.mc.otm.capability.MatteryCapability; import ru.dbotthepony.mc.otm.capability.IMatteryPlayer;
import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.config.ServerConfig;
import ru.dbotthepony.mc.otm.core.util.ExperienceUtilsKt; import ru.dbotthepony.mc.otm.core.util.ExperienceUtilsKt;
import ru.dbotthepony.mc.otm.registry.MItems; import ru.dbotthepony.mc.otm.registry.MItems;
@ -16,53 +18,54 @@ import ru.dbotthepony.mc.otm.registry.MItems;
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
@Mixin(LivingEntity.class) @Mixin(LivingEntity.class)
public class MixinLivingEntity { public class MixinLivingEntity {
@Shadow @Shadow(remap = false)
@Nullable
protected Player lastHurtByPlayer; protected Player lastHurtByPlayer;
@Inject( @Inject(
method = "dropExperience()V", method = "dropExperience(Lnet/minecraft/world/entity/Entity;)V",
remap = false,
at = @At("HEAD"), at = @At("HEAD"),
cancellable = true) cancellable = true)
public void dropExperience(CallbackInfo hook) { public void dropExperience(@Nullable Entity killer, CallbackInfo hook) {
if (((Object) this) instanceof Player player && ServerConfig.INSTANCE.getDROP_EXPERIENCE_CAPSULES()) { if (((Object) this) instanceof Player player && ServerConfig.INSTANCE.getDROP_EXPERIENCE_CAPSULES()) {
player.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(it -> { hook.cancel();
hook.cancel();
long totalExperience = ExperienceUtilsKt.getTotalXpRequiredForLevel(player.experienceLevel); var android = ((IMatteryPlayer) player).getOtmPlayer();
totalExperience += (long) (player.experienceProgress * player.getXpNeededForNextLevel()); long totalExperience = ExperienceUtilsKt.getTotalXpRequiredForLevel(player.experienceLevel);
totalExperience += (long) (player.experienceProgress * player.getXpNeededForNextLevel());
double min = ServerConfig.INSTANCE.getMIN_EXPERIENCE_DROPPED(); double min = ServerConfig.INSTANCE.getMIN_EXPERIENCE_DROPPED();
double max = ServerConfig.INSTANCE.getMAX_EXPERIENCE_DROPPED(); double max = ServerConfig.INSTANCE.getMAX_EXPERIENCE_DROPPED();
if (min == max) { if (min == max) {
totalExperience *= min; totalExperience *= min;
} else {
if (min > max) {
min = 0.4;
max = 0.8;
}
totalExperience *= min + player.getRandom().nextDouble() * (max - min);
}
if (totalExperience >= Integer.MAX_VALUE) {
int hooked = EventHooks.getExperienceDrop(player, lastHurtByPlayer, Integer.MAX_VALUE);
if (hooked != Integer.MAX_VALUE) {
totalExperience = hooked;
}
} else {
totalExperience = EventHooks.getExperienceDrop(player, lastHurtByPlayer, (int) totalExperience);
}
if (totalExperience > 0L) {
if (android.isAndroid()) {
player.drop(MItems.INSTANCE.getESSENCE_DRIVE().make(totalExperience), true, false);
} else { } else {
if (min > max) { player.drop(MItems.INSTANCE.getESSENCE_CAPSULE().make(totalExperience), true, false);
min = 0.4;
max = 0.8;
}
totalExperience *= min + player.getRandom().nextDouble() * (max - min);
} }
}
if (totalExperience >= Integer.MAX_VALUE) {
int hooked = ForgeEventFactory.getExperienceDrop(player, lastHurtByPlayer, Integer.MAX_VALUE);
if (hooked != Integer.MAX_VALUE) {
totalExperience = hooked;
}
} else {
totalExperience = ForgeEventFactory.getExperienceDrop(player, lastHurtByPlayer, (int) totalExperience);
}
if (totalExperience > 0L) {
if (it.isAndroid()) {
player.drop(MItems.INSTANCE.getESSENCE_DRIVE().make(totalExperience), true, false);
} else {
player.drop(MItems.INSTANCE.getESSENCE_CAPSULE().make(totalExperience), true, false);
}
}
});
} }
} }
} }

View File

@ -12,8 +12,10 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayer;
public class MixinMinecraft { public class MixinMinecraft {
@Redirect( @Redirect(
method = "pickBlock()V", method = "pickBlock()V",
remap = false,
at = @At( at = @At(
value = "INVOKE", value = "INVOKE",
remap = false,
target = "Lnet/minecraft/world/entity/player/Inventory;findSlotMatchingItem(Lnet/minecraft/world/item/ItemStack;)I" target = "Lnet/minecraft/world/entity/player/Inventory;findSlotMatchingItem(Lnet/minecraft/world/item/ItemStack;)I"
) )
) )

View File

@ -27,6 +27,7 @@ public class MixinPlayer implements IMatteryPlayer {
@Inject( @Inject(
method = "getProjectile(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/item/ItemStack;", method = "getProjectile(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/item/ItemStack;",
remap = false,
at = @At( at = @At(
value = "INVOKE", value = "INVOKE",
target = "net.minecraftforge.common.ForgeHooks.getProjectile(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/item/ItemStack;", target = "net.minecraftforge.common.ForgeHooks.getProjectile(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/item/ItemStack;",
@ -45,6 +46,7 @@ public class MixinPlayer implements IMatteryPlayer {
@Inject( @Inject(
method = "destroyVanishingCursedItems()V", method = "destroyVanishingCursedItems()V",
remap = false,
at = @At("TAIL") at = @At("TAIL")
) )
private void destroyVanishingCursedItems(CallbackInfo ci) { private void destroyVanishingCursedItems(CallbackInfo ci) {
@ -55,6 +57,7 @@ public class MixinPlayer implements IMatteryPlayer {
@Inject( @Inject(
method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;FLcom/mojang/authlib/GameProfile;)V", method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;FLcom/mojang/authlib/GameProfile;)V",
remap = false,
at = @At("TAIL") at = @At("TAIL")
) )
private void constructOtmPlayer(Level p_250508_, BlockPos p_250289_, float p_251702_, GameProfile p_252153_, CallbackInfo ci) { private void constructOtmPlayer(Level p_250508_, BlockPos p_250289_, float p_251702_, GameProfile p_252153_, CallbackInfo ci) {
@ -69,6 +72,7 @@ public class MixinPlayer implements IMatteryPlayer {
@Inject( @Inject(
method = "addAdditionalSaveData(Lnet/minecraft/nbt/CompoundTag;)V", method = "addAdditionalSaveData(Lnet/minecraft/nbt/CompoundTag;)V",
remap = false,
at = @At("TAIL") at = @At("TAIL")
) )
private void addAdditionalSaveData(CompoundTag data, CallbackInfo ci) { private void addAdditionalSaveData(CompoundTag data, CallbackInfo ci) {
@ -77,6 +81,7 @@ public class MixinPlayer implements IMatteryPlayer {
@Inject( @Inject(
method = "readAdditionalSaveData(Lnet/minecraft/nbt/CompoundTag;)V", method = "readAdditionalSaveData(Lnet/minecraft/nbt/CompoundTag;)V",
remap = false,
at = @At("TAIL") at = @At("TAIL")
) )
private void readAdditionalSaveData(CompoundTag data, CallbackInfo ci) { private void readAdditionalSaveData(CompoundTag data, CallbackInfo ci) {

View File

@ -19,6 +19,7 @@ public abstract class SimpleCriterionTriggerMixin implements CriterionTrigger<Cr
@Inject( @Inject(
method = "removePlayerListener(Lnet/minecraft/server/PlayerAdvancements;Lnet/minecraft/advancements/CriterionTrigger$Listener;)V", method = "removePlayerListener(Lnet/minecraft/server/PlayerAdvancements;Lnet/minecraft/advancements/CriterionTrigger$Listener;)V",
at = @At("HEAD"), at = @At("HEAD"),
remap = false,
cancellable = true cancellable = true
) )
public void removePlayerListener(PlayerAdvancements p_66254_, CriterionTrigger.Listener p_66255_, CallbackInfo info) { public void removePlayerListener(PlayerAdvancements p_66254_, CriterionTrigger.Listener p_66255_, CallbackInfo info) {
@ -31,6 +32,7 @@ public abstract class SimpleCriterionTriggerMixin implements CriterionTrigger<Cr
@Inject( @Inject(
method = "addPlayerListener(Lnet/minecraft/server/PlayerAdvancements;Lnet/minecraft/advancements/CriterionTrigger$Listener;)V", method = "addPlayerListener(Lnet/minecraft/server/PlayerAdvancements;Lnet/minecraft/advancements/CriterionTrigger$Listener;)V",
at = @At("HEAD"), at = @At("HEAD"),
remap = false,
cancellable = true cancellable = true
) )
public void addPlayerListener(PlayerAdvancements p_66254_, CriterionTrigger.Listener p_66255_, CallbackInfo info) { public void addPlayerListener(PlayerAdvancements p_66254_, CriterionTrigger.Listener p_66255_, CallbackInfo info) {
@ -43,6 +45,7 @@ public abstract class SimpleCriterionTriggerMixin implements CriterionTrigger<Cr
@Inject( @Inject(
method = "removePlayerListeners(Lnet/minecraft/server/PlayerAdvancements;)V", method = "removePlayerListeners(Lnet/minecraft/server/PlayerAdvancements;)V",
at = @At("HEAD"), at = @At("HEAD"),
remap = false,
cancellable = true cancellable = true
) )
public void removePlayerListeners(PlayerAdvancements p_66254_, CallbackInfo info) { public void removePlayerListeners(PlayerAdvancements p_66254_, CallbackInfo info) {

View File

@ -1,8 +1,12 @@
package ru.dbotthepony.mc.otm.mixin; package ru.dbotthepony.mc.otm.mixin;
import net.minecraft.client.User;
import net.minecraft.client.resources.SplashManager; import net.minecraft.client.resources.SplashManager;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.neoforged.fml.ModList;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@ -10,14 +14,19 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List; import java.util.List;
import java.util.Locale;
@Mixin(SplashManager.class) @Mixin(SplashManager.class)
public abstract class SplashManagerMixin { public abstract class SplashManagerMixin {
@Shadow @Shadow(remap = false)
public List<String> splashes; private List<String> splashes;
@Shadow(remap = false)
@Nullable
private User user;
@Inject( @Inject(
at = @At("TAIL"), at = @At("TAIL"),
remap = false,
method = "apply(Ljava/util/List;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V" method = "apply(Ljava/util/List;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V"
) )
public void otmSplashes(List<String> splashes, ResourceManager p_118879_, ProfilerFiller p_118880_, CallbackInfo ci) { public void otmSplashes(List<String> splashes, ResourceManager p_118879_, ProfilerFiller p_118880_, CallbackInfo ci) {
@ -29,12 +38,41 @@ public abstract class SplashManagerMixin {
this.splashes.add("As it was 13 nanoseconds ago!"); this.splashes.add("As it was 13 nanoseconds ago!");
this.splashes.add("Smart AI is smart enough to fail Turing test!"); this.splashes.add("Smart AI is smart enough to fail Turing test!");
this.splashes.add("Neural computing!"); this.splashes.add("Neural computing!");
this.splashes.add("Swimming through quantum field!"); this.splashes.add("Swimming through quantum fields!");
this.splashes.add("For biological and digital alike!"); this.splashes.add("For biological and digital alike!");
this.splashes.add("Digital is the next form of Biological!"); this.splashes.add("Digital is the next form of Biological!");
this.splashes.add("Also try Starbound!"); this.splashes.add("Also try Starbound!");
this.splashes.add("Also try No Man's Sky!"); this.splashes.add("Also try No Man's Sky!");
this.splashes.add("Also try Factorio!"); this.splashes.add("Also try Factorio!");
if (ModList.get().isLoaded("jei")) {
this.splashes.add("E in JEI stands for Extraterrestrial!");
}
this.splashes.add("Smarter than Smart Cities!");
if (BuiltInRegistries.ITEM.keySet().stream().noneMatch((it) -> it.getPath().contains("tin_")))
this.splashes.add("Induction stove compatible!");
if (BuiltInRegistries.ITEM.keySet().stream().noneMatch((it) -> it.getPath().contains("lead_")))
this.splashes.add("Lead free!");
if (BuiltInRegistries.ITEM.keySet().stream().noneMatch((it) -> it.getPath().contains("electrum_")))
this.splashes.add("Somehow does not come with electrum!");
if (BuiltInRegistries.ITEM.keySet().stream().noneMatch((it) -> it.getPath().contains("silver_")))
this.splashes.add("Non-complementary to gold!");
if (this.user != null) {
var username = this.user.getName();
this.splashes.add("Say no more, " + username + "!");
this.splashes.add(username + ", and here comes the quarks!");
if (ModList.get().isLoaded("ad_astra")) {
this.splashes.add("Such a weird choice for Space Faring mod, " + username + "...");
}
}
} }
} }

View File

@ -48,6 +48,7 @@ class EnergySwordItem : MatteryItem(Properties().stacksTo(1).rarity(Rarity.RARE)
builder.add(Attributes.ATTACK_DAMAGE, AttributeModifier(BASE_ATTACK_DAMAGE_ID, 11.0, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) builder.add(Attributes.ATTACK_DAMAGE, AttributeModifier(BASE_ATTACK_DAMAGE_ID, 11.0, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND)
builder.add(Attributes.ATTACK_SPEED, AttributeModifier(BASE_ATTACK_SPEED_ID, -2.4, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) builder.add(Attributes.ATTACK_SPEED, AttributeModifier(BASE_ATTACK_SPEED_ID, -2.4, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND)
builder.add(Attributes.SWEEPING_DAMAGE_RATIO, AttributeModifier(ResourceLocation(OverdriveThatMatters.MOD_ID, "energy_sword_sweeping_edge"), 1.0, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND)
chargedAttributes = builder.build() chargedAttributes = builder.build()
builder = ItemAttributeModifiers.builder() builder = ItemAttributeModifiers.builder()
@ -214,14 +215,5 @@ class EnergySwordItem : MatteryItem(Properties().stacksTo(1).rarity(Rarity.RARE)
builder.pop() builder.pop()
} }
@JvmStatic
fun getSweepingDamageRatioHook(ply: LivingEntity): Float? {
if (ply.mainHandItem.item is EnergySwordItem && ply.mainHandItem.matteryEnergy?.extractEnergyExact(ENERGY_PER_SWING, true) == true) {
return 1f
}
return null
}
} }
} }

View File

@ -7,7 +7,6 @@
"refmap": "overdrive_that_matters.refmap.json", "refmap": "overdrive_that_matters.refmap.json",
"mixins": [ "mixins": [
"BlockEntityMixin", "BlockEntityMixin",
"EnchantmentHelperMixin",
"FoodDataMixin", "FoodDataMixin",
"MixinLivingEntity", "MixinLivingEntity",
"MixinAnvilBlock", "MixinAnvilBlock",