Search in sources :

Example 1 with ModifyVariable

use of org.spongepowered.asm.mixin.injection.ModifyVariable in project roadrunner by MaxNeedsSnacks.

the class ChunkHolderMixin method createShortHashSet.

/**
 * Using Hashsets instead of ArraySets for better worst-case performance
 * The default case of just a few items may be very slightly slower
 */
@ModifyVariable(method = "markForBlockUpdate", at = @At(ordinal = 0, value = "FIELD", target = "Lnet/minecraft/server/world/ChunkHolder;blockUpdatesBySection:[Lit/unimi/dsi/fastutil/shorts/ShortSet;", shift = At.Shift.BEFORE))
private byte createShortHashSet(byte b) {
    if (blockUpdatesBySection[b] == null) {
        this.pendingBlockUpdates = true;
        this.blockUpdatesBySection[b] = new ShortOpenHashSet();
    }
    return b;
}
Also used : ShortOpenHashSet(it.unimi.dsi.fastutil.shorts.ShortOpenHashSet) ModifyVariable(org.spongepowered.asm.mixin.injection.ModifyVariable)

Example 2 with ModifyVariable

use of org.spongepowered.asm.mixin.injection.ModifyVariable in project MasaGadget by plusls.

the class MixinRenderUtils method modifyInv.

@ModifyVariable(method = "renderInventoryOverlay", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/util/GuiUtils;getScaledWindowWidth()I", ordinal = 0, remap = false), ordinal = 0)
private static Inventory modifyInv(Inventory inv) {
    Inventory ret = inv;
    Entity traceEntity = TraceUtil.getTraceEntity();
    if (Configs.Tweakeroo.INVENTORY_PREVIEW_SUPPORT_SHULKER_BOX_ITEM_ENTITY.getBooleanValue() && ret == null && traceEntity instanceof ItemEntity) {
        ItemStack itemStack = ((ItemEntity) traceEntity).getStack();
        Item item = itemStack.getItem();
        NbtCompound invNbt = itemStack.getSubNbt("BlockEntityTag");
        DefaultedList<ItemStack> stacks = DefaultedList.ofSize(27, ItemStack.EMPTY);
        if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof ShulkerBoxBlock) {
            ret = new SimpleInventory(27);
            if (invNbt != null) {
                Inventories.readNbt(invNbt, stacks);
            }
            for (int i = 0; i < 27; ++i) {
                ret.setStack(i, stacks.get(i));
            }
        }
    }
    return ret;
}
Also used : Entity(net.minecraft.entity.Entity) ItemEntity(net.minecraft.entity.ItemEntity) Item(net.minecraft.item.Item) BlockItem(net.minecraft.item.BlockItem) ItemEntity(net.minecraft.entity.ItemEntity) NbtCompound(net.minecraft.nbt.NbtCompound) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) ItemStack(net.minecraft.item.ItemStack) BlockItem(net.minecraft.item.BlockItem) Inventory(net.minecraft.inventory.Inventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) ModifyVariable(org.spongepowered.asm.mixin.injection.ModifyVariable)

Example 3 with ModifyVariable

use of org.spongepowered.asm.mixin.injection.ModifyVariable in project Balm by ModdingForBlockheads.

the class LivingEntityMixin method modifyFallDamage.

@ModifyVariable(method = "causeFallDamage(FFLnet/minecraft/world/damagesource/DamageSource;)Z", at = @At("STORE"), ordinal = 0)
private int modifyFallDamage(int damage) {
    LivingFallEvent event = currentFallEvent.get();
    float effectiveDamage = damage;
    if (event != null && event.getFallDamageOverride() != null) {
        effectiveDamage = event.getFallDamageOverride();
    }
    return (int) effectiveDamage;
}
Also used : LivingFallEvent(net.blay09.mods.balm.api.event.LivingFallEvent) ModifyVariable(org.spongepowered.asm.mixin.injection.ModifyVariable)

Example 4 with ModifyVariable

use of org.spongepowered.asm.mixin.injection.ModifyVariable in project Balm by ModdingForBlockheads.

the class MinecraftMixin method modifyScreen.

@ModifyVariable(method = "setScreen(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;screen:Lnet/minecraft/client/gui/screens/Screen;", opcode = Opcodes.GETFIELD, shift = At.Shift.AFTER), argsOnly = true)
public Screen modifyScreen(Screen screen) {
    OpenScreenEvent event = new OpenScreenEvent(screen);
    Balm.getEvents().fireEvent(event);
    return event.getScreen();
}
Also used : OpenScreenEvent(net.blay09.mods.balm.api.event.client.OpenScreenEvent) ModifyVariable(org.spongepowered.asm.mixin.injection.ModifyVariable)

Example 5 with ModifyVariable

use of org.spongepowered.asm.mixin.injection.ModifyVariable in project Arclight by IzzelAliz.

the class RedstoneWireBlockMixin method arclight$blockRedstone.

@ModifyVariable(method = "updatePower", name = "l", index = 8, at = @At(value = "JUMP", ordinal = 0, opcode = Opcodes.IF_ICMPEQ))
public int arclight$blockRedstone(int l, World world, BlockPos pos, BlockState state) {
    int i = state.get(RedstoneWireBlock.POWER);
    if (i != l) {
        BlockRedstoneEvent event = new BlockRedstoneEvent(CraftBlock.at(world, pos), i, l);
        Bukkit.getPluginManager().callEvent(event);
        return event.getNewCurrent();
    }
    return l;
}
Also used : BlockRedstoneEvent(org.bukkit.event.block.BlockRedstoneEvent) ModifyVariable(org.spongepowered.asm.mixin.injection.ModifyVariable)

Aggregations

ModifyVariable (org.spongepowered.asm.mixin.injection.ModifyVariable)27 ScaledResolution (net.minecraft.client.gui.ScaledResolution)4 GuiContainer (net.minecraft.client.gui.inventory.GuiContainer)4 Mixin (org.spongepowered.asm.mixin.Mixin)4 At (org.spongepowered.asm.mixin.injection.At)4 Minecraft (net.minecraft.client.Minecraft)3 PoseStack (com.mojang.blaze3d.vertex.PoseStack)2 CameraClipEvent (cope.cosmos.client.events.render.other.CameraClipEvent)2 List (java.util.List)2 Groupable (net.coderbot.batchedentityrendering.impl.Groupable)2 TaggingRenderTypeWrapper (net.coderbot.batchedentityrendering.impl.wrappers.TaggingRenderTypeWrapper)2 BlockState (net.minecraft.block.BlockState)2 Button (net.minecraft.client.gui.components.Button)2 MultiBufferSource (net.minecraft.client.renderer.MultiBufferSource)2 ItemStack (net.minecraft.item.ItemStack)2 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)2 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Suggestion (com.mojang.brigadier.suggestion.Suggestion)1 Suggestions (com.mojang.brigadier.suggestion.Suggestions)1