MixinAbstractInventoryScreen.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2020 shedaniel
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package me.shedaniel.nopotionoffset.mixin;
  17. import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen;
  18. import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
  19. import net.minecraft.container.Container;
  20. import net.minecraft.entity.player.PlayerInventory;
  21. import net.minecraft.text.Text;
  22. import org.spongepowered.asm.mixin.Mixin;
  23. import org.spongepowered.asm.mixin.injection.At;
  24. import org.spongepowered.asm.mixin.injection.Inject;
  25. import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
  26. @Mixin(AbstractInventoryScreen.class)
  27. public abstract class MixinAbstractInventoryScreen<T extends Container> extends AbstractContainerScreen<T> {
  28. public MixinAbstractInventoryScreen(T container, PlayerInventory playerInventory, Text name) {
  29. super(container, playerInventory, name);
  30. }
  31. @Inject(method = "applyStatusEffectOffset", at = @At("RETURN"))
  32. private void applyStatusEffectOffset(CallbackInfo info) {
  33. this.x = (this.width - this.containerWidth) / 2;
  34. }
  35. }