org.spongepowered.asm.mixin.injection.ModifyVariable Java Examples

The following examples show how to use org.spongepowered.asm.mixin.injection.ModifyVariable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MixinMinecraftClient.java    From Sandbox with GNU Lesser General Public License v3.0 6 votes vote down vote up
@ModifyVariable(method = "openScreen", at = @At("HEAD"), ordinal = 0)
public Screen openScreen(Screen screen) {
    if (screen instanceof TitleScreen || (screen == null && MinecraftClient.getInstance().world == null)) {
        screen = new SandboxTitleScreen();
    }
    return screen;
}
 
Example #2
Source File: MixinPlayerEntity.java    From patchwork-api with GNU Lesser General Public License v2.1 6 votes vote down vote up
@ModifyVariable(method = "addExperience", at = @At("HEAD"), ordinal = 0)
private int onAddExperience(int points) {
	@SuppressWarnings("ConstantConditions")
	PlayerEntity player = (PlayerEntity) (Object) this;

	PlayerXpEvent.XpChange event = new PlayerXpEvent.XpChange(player, points);
	MinecraftForge.EVENT_BUS.post(event);

	// The only effect of passing in zero is a call to addScore(0), which shouldn't have any effect.
	return event.isCanceled() ? 0 : event.getAmount();
}
 
Example #3
Source File: MixinEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@ModifyVariable(
    method = "Lnet/minecraft/client/renderer/EntityRenderer;orientCamera(F)V",
    index = 10,
    at = @At(
        value = "FIELD",
        target = "Lnet/minecraft/client/settings/GameSettings;debugCamEnable:Z",
        ordinal = 1
    ))
private double zoomOutIfPiloting(double oldZoom) {
    //TODO: Make this number scale with the Ship
    return ((IShipPilot) this.mc.player).isPilotingShip() ? 15.0d : oldZoom;
}
 
Example #4
Source File: MixinEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@ModifyVariable(
    method = "Lnet/minecraft/client/renderer/EntityRenderer;orientCamera(F)V",
    index = 8,
    at = @At(
        value = "JUMP",
        opcode = Opcodes.IFEQ,
        ordinal = 0,
        shift = At.Shift.BY,
        by = -2
    ))
private double offsetZIfMounted(double oldVal) {
    return (this.mountData != null
        && this.mountData.getMountedShip().getShipRenderer().offsetPos != null
        ? this.cachedPosition.Z : oldVal) + this.eyeVector.Z;
}
 
Example #5
Source File: MixinEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@ModifyVariable(
    method = "Lnet/minecraft/client/renderer/EntityRenderer;orientCamera(F)V",
    index = 6,
    at = @At(
        value = "JUMP",
        opcode = Opcodes.IFEQ,
        ordinal = 0,
        shift = At.Shift.BY,
        by = -2
    ))
private double offsetYIfMounted(double oldVal) {
    return (this.mountData != null
        && this.mountData.getMountedShip().getShipRenderer().offsetPos != null
        ? this.cachedPosition.Y : oldVal) + this.eyeVector.Y;
}
 
Example #6
Source File: MixinEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@ModifyVariable(
    method = "Lnet/minecraft/client/renderer/EntityRenderer;orientCamera(F)V",
    index = 4,
    at = @At(
        value = "JUMP",
        opcode = Opcodes.IFEQ,
        ordinal = 0,
        shift = At.Shift.BY,
        by = -2
    ))
private double offsetXIfMounted(double oldVal) {
    return (this.mountData != null
        && this.mountData.getMountedShip().getShipRenderer().offsetPos != null
        ? this.cachedPosition.X : oldVal) + this.eyeVector.X;
}
 
Example #7
Source File: MixinBlockFluidRenderer.java    From VanillaFix with MIT License 5 votes vote down vote up
/**
 * @reason Adds liquid textures to the set of visible textures in the compiled chunk. Note
 * that this is necessary only for liquid textures, since Forge liquids are rendered by the
 * normal block rendering code.
 */
@ModifyVariable(method = "renderFluid", at = @At(value = "CONSTANT", args = "floatValue=0.001", ordinal = 1), ordinal = 0)
private TextureAtlasSprite afterTextureDetermined(TextureAtlasSprite texture) {
    CompiledChunk compiledChunk = TemporaryStorage.currentCompiledChunk.get();
    if (compiledChunk != null) {
        ((IPatchedCompiledChunk) compiledChunk).getVisibleTextures().add(texture);
    } else {
        // Called from non-chunk render thread. Unfortunately, the best we can do
        // is assume it's only going to be used once:
        ((IPatchedTextureAtlasSprite) texture).markNeedsAnimationUpdate();
    }

    return texture;
}
 
Example #8
Source File: WorldRenderer_pausedShakeMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@ModifyVariable(method = "render", argsOnly = true, ordinal = 0 ,at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/client/particle/ParticleManager;renderParticles(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;Lnet/minecraft/client/render/LightmapTextureManager;Lnet/minecraft/client/render/Camera;F)V",
        shift = At.Shift.BEFORE
))
private float changeTickPhaseBack(float previous)
{
    return initial;
}
 
Example #9
Source File: WorldRenderer_pausedShakeMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@ModifyVariable(method = "render", argsOnly = true, ordinal = 0 ,at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/client/world/ClientWorld;getEntities()Ljava/lang/Iterable;"
))
private float changeTickPhase(float previous)
{
    initial = previous;
    if (!TickSpeed.process_entities)
        return ((MinecraftClientInferface)client).getPausedTickDelta();
    return previous;
}
 
Example #10
Source File: MixinFontRenderer.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@ModifyVariable(method = "getStringWidth", at = @At("HEAD"), ordinal = 0)
private String getStringWidth(final String string) {
    if (string == null || LiquidBounce.eventManager == null)
        return string;

    final TextEvent textEvent = new TextEvent(string);
    LiquidBounce.eventManager.callEvent(textEvent);
    return textEvent.getText();
}
 
Example #11
Source File: MixinFontRenderer.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@ModifyVariable(method = "renderString", at = @At("HEAD"), ordinal = 0)
private String renderString(final String string) {
    if (string == null || LiquidBounce.eventManager == null)
        return string;

    final TextEvent textEvent = new TextEvent(string);
    LiquidBounce.eventManager.callEvent(textEvent);
    return textEvent.getText();
}
 
Example #12
Source File: MixinFontRenderer.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@ModifyVariable(method = "getStringWidth", at = @At("HEAD"), ordinal = 0)
private String getStringWidth(final String string) {
    if (string == null || LiquidBounce.eventManager == null)
        return string;

    final TextEvent textEvent = new TextEvent(string);
    LiquidBounce.eventManager.callEvent(textEvent);
    return textEvent.getText();
}
 
Example #13
Source File: MixinFontRenderer.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@ModifyVariable(method = "renderString", at = @At("HEAD"), ordinal = 0)
private String renderString(final String string) {
    if (string == null || LiquidBounce.eventManager == null)
        return string;

    final TextEvent textEvent = new TextEvent(string);
    LiquidBounce.eventManager.callEvent(textEvent);
    return textEvent.getText();
}
 
Example #14
Source File: MixinMinecraftClient.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
@ModifyVariable(method = "openScreen", at = @At("HEAD"), ordinal = 0)
public Screen openScreen(Screen screen) {
    if (screen == null) {
        ScreenEvent.Close close = EventDispatcher.publish(new ScreenEvent.Close(WrappingUtil.convert(currentScreen)));
        if (close.isCancelled())
            return currentScreen;
        return null;
    } else {
        ScreenEvent.Open open = EventDispatcher.publish(new ScreenEvent.Open(WrappingUtil.convert(screen)));
        if (open.isCancelled())
            return currentScreen;
        return WrappingUtil.convert(open.getScreen());
    }
}
 
Example #15
Source File: MixinStateManager.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
@ModifyVariable(method = "add", at = @At("HEAD"), ordinal = 0)
        public Property<?>[] properties(Property<?>[] in) {
//            if (ArrayUtils.contains(in, Properties.WATERLOGGED)) {
//                in=ArrayUtils.add(ArrayUtils.removeElement(in, Properties.WATERLOGGED), SandboxProperties.PROPERTY_FLUIDLOGGABLE);
//            }
            return in;
        }
 
Example #16
Source File: MixinPlayerEntity.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@ModifyVariable(method = "addExperienceLevels", at = @At("HEAD"), ordinal = 0)
private int onAddExperienceLevels(int levels) {
	@SuppressWarnings("ConstantConditions")
	PlayerEntity player = (PlayerEntity) (Object) this;

	PlayerXpEvent.LevelChange event = new PlayerXpEvent.LevelChange(player, levels);
	MinecraftForge.EVENT_BUS.post(event);

	// There are no effects from passing in zero levels, so do that if we've been canceled
	return event.isCanceled() ? 0 : event.getLevels();
}
 
Example #17
Source File: MixinCommandSuggestor.java    From multiconnect with MIT License 5 votes vote down vote up
@ModifyVariable(method = "highlight", at = @At(value = "STORE", ordinal = 0))
private static Iterator<ParsedArgument<CommandSource, ?>> decorateHighlightIterator(Iterator<ParsedArgument<CommandSource, ?>> itr) {
    return Iterators.concat(
            Iterators.transform(itr,
                    arg -> arg != null && arg.getResult() instanceof Custom_1_12_Argument ?
                            decorateHighlightIterator(((Custom_1_12_Argument) arg.getResult()).<CommandSource>getSubArgs().iterator())
                            : Iterators.singletonIterator(arg))
    );
}
 
Example #18
Source File: MixinNoteBlock.java    From multiconnect with MIT License 5 votes vote down vote up
@ModifyVariable(method = "onSyncedBlockEvent", ordinal = 0, at = @At("HEAD"))
private BlockState onOnBlockAction(BlockState localState, BlockState state, World world, BlockPos pos, int type, int data) {
    if (ConnectionInfo.protocolVersion > Protocols.V1_12_2)
        return localState;
    Instrument instrument = type < 0 || type >= 10 ? Instrument.HARP : Instrument.values()[type];
    state = state.with(NoteBlock.INSTRUMENT, instrument).with(NoteBlock.NOTE, MathHelper.clamp(data, 0, 24));
    world.setBlockState(pos, state, 18);
    return state;
}
 
Example #19
Source File: MixinEncoderHandler.java    From multiconnect with MIT License 5 votes vote down vote up
@ModifyVariable(method = "encode", ordinal = 0, at = @At(value = "STORE", ordinal = 0))
private PacketByteBuf transformPacketByteBuf(PacketByteBuf buf) {
    if (side == NetworkSide.SERVERBOUND)
        buf = new TransformerByteBuf(buf, context.get());
    context.set(null);
    this.buf.set(buf);
    return buf;
}
 
Example #20
Source File: MixinDecoderHandler.java    From multiconnect with MIT License 5 votes vote down vote up
@ModifyVariable(method = "decode", ordinal = 0, at = @At(value = "STORE", ordinal = 0))
private PacketByteBuf transformPacketByteBuf(PacketByteBuf buf) {
    if (side == NetworkSide.CLIENTBOUND)
        buf = new TransformerByteBuf(buf, context.get());
    context.set(null);
    return buf;
}
 
Example #21
Source File: MixinMinecraftClient.java    From multiconnect with MIT License 5 votes vote down vote up
@ModifyVariable(method = "render", ordinal = 0, at = @At("HEAD"))
private boolean shouldTick(boolean oldShouldTick) {
    if (ConnectionInfo.reloadingResources && ConnectionInfo.protocol != ProtocolRegistry.latest()) {
        return false;
    }
    return oldShouldTick;
}
 
Example #22
Source File: MixinWorldClient.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@ModifyVariable(method = "doVoidFogParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;randomDisplayTick(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;Ljava/util/Random;)V", shift = At.Shift.AFTER), ordinal = 0)
private boolean handleBarriers(final boolean flag) {
    final TrueSight trueSight = (TrueSight) LiquidBounce.moduleManager.getModule(TrueSight.class);
    return flag || trueSight.getState() && trueSight.getBarriersValue().get();
}
 
Example #23
Source File: MixinClientChunkManager.java    From multiconnect with MIT License 4 votes vote down vote up
@ModifyVariable(method = "loadChunkFromPacket", ordinal = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/WorldChunk;getSectionArray()[Lnet/minecraft/world/chunk/ChunkSection;"))
private WorldChunk grabChunk(WorldChunk chunk) {
    this.chunk.set(chunk);
    return chunk;
}
 
Example #24
Source File: MixinArgumentTypes.java    From multiconnect with MIT License 4 votes vote down vote up
@ModifyVariable(method = "byId", ordinal = 0, at = @At("HEAD"))
private static Identifier modifyById(Identifier id) {
    return ConnectionInfo.protocolVersion <= Protocols.V1_13_2 && NBT.equals(id) ? NBT_COMPOUND_TAG : id;
}
 
Example #25
Source File: MixinWorldChunk.java    From multiconnect with MIT License 4 votes vote down vote up
@ModifyVariable(method = "setBlockState", ordinal = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getBlock()Lnet/minecraft/block/Block;", ordinal = 0))
private BlockState calcShouldReplaceBlockEntity(BlockState oldState, BlockPos pos, BlockState newState, boolean bl) {
    shouldReplaceBlockEntity = ConnectionInfo.protocol.shouldBlockChangeReplaceBlockEntity(oldState.getBlock(), newState.getBlock());
    return oldState;
}
 
Example #26
Source File: MixinMinecraft.java    From VanillaFix with MIT License 4 votes vote down vote up
/** @reason Implement using Ctrl + 0-9 to select profiler sections 10-19. */
@ModifyVariable(method = "updateDebugProfilerName", at = @At("HEAD"), ordinal = 0)
private int getKeyCountForProfilerNameUpdate(int keyCount) {
    return GuiScreen.isCtrlKeyDown() ? keyCount + 10 : keyCount;
}
 
Example #27
Source File: MixinGuiChat.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@ModifyVariable(method = "onAutocompleteResponse", at = @At("HEAD"))
private String[] remap(String[] in) {
    return NickHider.instance == null || !NickHider.instance.getNickHiderConfig().isMasterEnabled() ?
        in : NickHider.instance.tabComplete(in, inputField.getText());
}
 
Example #28
Source File: MixinFontRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@ModifyVariable(method = "getStringWidth", at = @At(value = "HEAD"))
private String modWidth(String in) {
    return NickHider.instance == null ? in : NickHider.instance.apply(in);
}
 
Example #29
Source File: MixinFontRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@ModifyVariable(method = "renderString", at = @At(value = "HEAD"))
private String mod(String in) {
    return NickHider.instance == null ? in : NickHider.instance.apply(in);
}
 
Example #30
Source File: MixinEntityPlayerSP.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @author Sk1er
 * @reason NickHider
 */
@ModifyVariable(method = "sendChatMessage", at = @At("HEAD"))
private String sendChat(String chat) {
    NickHider instance = NickHider.instance;
    return instance == null || !instance.getNickHiderConfig().isMasterEnabled() ? chat : instance.out(chat);
}