DBotThePony — Вчера, в 16:20
:umer: Вопрос только в том, а почему не переместить типичные патчи в mixin ---------- ну и починил /clear для экзокостюма
This commit is contained in:
parent
c9fa920a82
commit
a4888c1982
@ -0,0 +1,22 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
|
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.CallbackInfo;
|
||||||
|
import ru.dbotthepony.mc.otm.client.render.GlitchRenderer;
|
||||||
|
|
||||||
|
@Mixin(GameRenderer.class)
|
||||||
|
public class MixinGameRenderer {
|
||||||
|
@Inject(
|
||||||
|
method = "render(FJZ)V",
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lcom/mojang/blaze3d/pipeline/RenderTarget;bindWrite(Z)V"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private void render(float p_109094_, long p_109095_, boolean p_109096_, CallbackInfo ci) {
|
||||||
|
GlitchRenderer.render();
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,8 @@ 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.world.Container;
|
||||||
|
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;
|
||||||
@ -12,8 +14,12 @@ 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.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability;
|
import ru.dbotthepony.mc.otm.capability.MatteryCapability;
|
||||||
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@Mixin(Inventory.class)
|
@Mixin(Inventory.class)
|
||||||
public class MixinInventory {
|
public class MixinInventory {
|
||||||
@ -46,4 +52,36 @@ public class MixinInventory {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "dropAll()V",
|
||||||
|
at = @At("TAIL")
|
||||||
|
)
|
||||||
|
private void dropAll(CallbackInfo ci) {
|
||||||
|
MatteryPlayerCapability.inventoryDropAll((Inventory)(Object)this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "clearContent()V",
|
||||||
|
at = @At("TAIL")
|
||||||
|
)
|
||||||
|
private void clearContent(CallbackInfo ci) {
|
||||||
|
MatteryPlayerCapability.inventoryClearContent((Inventory)(Object)this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "clearOrCountMatchingItems(Ljava/util/function/Predicate;ILnet/minecraft/world/Container;)I",
|
||||||
|
at = @At("RETURN"),
|
||||||
|
cancellable = true
|
||||||
|
)
|
||||||
|
private void clearOrCountMatchingItems(Predicate<ItemStack> predicate, int count, Container container, CallbackInfoReturnable<Integer> cir) {
|
||||||
|
player.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(it -> {
|
||||||
|
if (!it.getHasExoPack()) return;
|
||||||
|
|
||||||
|
int i = cir.getReturnValue();
|
||||||
|
i += ContainerHelper.clearOrCountMatchingItems(it.getExoPackContainer(), predicate, count - i, count == 0);
|
||||||
|
|
||||||
|
cir.setReturnValue(i);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
19
src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java
Normal file
19
src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.mixin;
|
||||||
|
|
||||||
|
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.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability;
|
||||||
|
|
||||||
|
@Mixin(Player.class)
|
||||||
|
public class MixinPlayer {
|
||||||
|
@Inject(
|
||||||
|
method = "destroyVanishingCursedItems()V",
|
||||||
|
at = @At("TAIL")
|
||||||
|
)
|
||||||
|
private void destroyVanishingCursedItems(CallbackInfo ci) {
|
||||||
|
MatteryPlayerCapability.playerDestroyVanishingCursedItems((Player)(Object)this);
|
||||||
|
}
|
||||||
|
}
|
@ -621,30 +621,6 @@ function initializeCoreMod() {
|
|||||||
return node
|
return node
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'Inventory#dropAll': injectAtTail(
|
|
||||||
'net.minecraft.world.entity.player.Inventory.m_36071_()V',
|
|
||||||
[
|
|
||||||
new VarInsnNode(opcodesRemapped.aload, 0),
|
|
||||||
new MethodInsnNode(opcodesRemapped.invokestatic, 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', 'inventoryDropAll', '(Lnet/minecraft/world/entity/player/Inventory;)V', false)
|
|
||||||
]
|
|
||||||
),
|
|
||||||
|
|
||||||
'Inventory#clearContent': injectAtTail(
|
|
||||||
'net.minecraft.world.entity.player.Inventory.m_6211_()V',
|
|
||||||
[
|
|
||||||
new VarInsnNode(opcodesRemapped.aload, 0),
|
|
||||||
new MethodInsnNode(opcodesRemapped.invokestatic, 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', 'inventoryClearContent', '(Lnet/minecraft/world/entity/player/Inventory;)V', false)
|
|
||||||
]
|
|
||||||
),
|
|
||||||
|
|
||||||
'Player#destroyVanishingCursedItems': injectAtTail(
|
|
||||||
'net.minecraft.world.entity.player.Player.m_36345_()V',
|
|
||||||
[
|
|
||||||
new VarInsnNode(opcodesRemapped.aload, 0),
|
|
||||||
new MethodInsnNode(opcodesRemapped.invokestatic, 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', 'playerDestroyVanishingCursedItems', '(Lnet/minecraft/world/entity/player/Player;)V', false)
|
|
||||||
]
|
|
||||||
),
|
|
||||||
|
|
||||||
'blend func lock 1': {
|
'blend func lock 1': {
|
||||||
'target': {
|
'target': {
|
||||||
'type': 'METHOD',
|
'type': 'METHOD',
|
||||||
@ -773,49 +749,6 @@ function initializeCoreMod() {
|
|||||||
return node
|
return node
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'GameRenderer#render hook': {
|
|
||||||
'target': {
|
|
||||||
'type': 'METHOD',
|
|
||||||
'class': 'net.minecraft.client.renderer.GameRenderer',
|
|
||||||
'methodName': ASMAPI.mapMethod('m_109093_'), // render
|
|
||||||
'methodDesc': '(FJZ)V'
|
|
||||||
},
|
|
||||||
|
|
||||||
'transformer': function(node) {
|
|
||||||
// 288: invokevirtual #3558 // Method net/minecraft/client/renderer/PostChain.process:(F)V
|
|
||||||
// 291: aload_0
|
|
||||||
// 292: getfield #2773 // Field minecraft:Lnet/minecraft/client/Minecraft;
|
|
||||||
// 295: invokevirtual #2818 // Method net/minecraft/client/Minecraft.getMainRenderTarget:()Lcom/mojang/blaze3d/pipeline/RenderTarget;
|
|
||||||
// 298: iconst_1
|
|
||||||
// 299: invokevirtual #3561 // Method com/mojang/blaze3d/pipeline/RenderTarget.bindWrite:(Z)V
|
|
||||||
// <-- our target
|
|
||||||
// 302: aload_0
|
|
||||||
// 303: getfield #2773 // Field minecraft:Lnet/minecraft/client/Minecraft;
|
|
||||||
// 306: invokevirtual #2821 // Method net/minecraft/client/Minecraft.getWindow:()Lcom/mojang/blaze3d/platform/Window;
|
|
||||||
// 309: astore 7
|
|
||||||
|
|
||||||
var ourmethod = ASMAPI.mapMethod('m_83947_') // bindWrite
|
|
||||||
|
|
||||||
for (var i = 0; i < node.instructions.size(); i++) {
|
|
||||||
var instruction = node.instructions.get(i)
|
|
||||||
|
|
||||||
if (instruction.getOpcode() == opcodesRemapped.invokevirtual && instruction.name == ourmethod && instruction.desc == '(Z)V') {
|
|
||||||
node.instructions.insert(instruction, new MethodInsnNode(
|
|
||||||
opcodesRemapped.invokestatic,
|
|
||||||
'ru/dbotthepony/mc/otm/client/render/GlitchRenderer',
|
|
||||||
'render',
|
|
||||||
'()V',
|
|
||||||
false
|
|
||||||
))
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return node
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
'LevelRenderer DynamicBufferSource callback': {
|
'LevelRenderer DynamicBufferSource callback': {
|
||||||
'target': {
|
'target': {
|
||||||
'type': 'METHOD',
|
'type': 'METHOD',
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
"MixinLivingEntity",
|
"MixinLivingEntity",
|
||||||
"MixinAnvilBlock",
|
"MixinAnvilBlock",
|
||||||
"MixinInventory",
|
"MixinInventory",
|
||||||
"MixinAbstractHurtingProjectile"
|
"MixinAbstractHurtingProjectile",
|
||||||
|
"MixinPlayer"
|
||||||
|
],
|
||||||
|
"client": [
|
||||||
|
"MixinGameRenderer"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user