Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to 1.20.1 #102

Open
wants to merge 4 commits into
base: 1.19.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'fabric-loom' version '1.2.7'
id 'maven-publish'
}

Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.1
loader_version=0.14.19

# Mod Properties
mod_version = 0.9.0-beta-1.19.4
mod_version = 0.9.0-beta-1.20
maven_group = com.kqp
archives_base_name = inventorytabs

# Dependencies
fabric_version=0.77.0+1.19.4
clothconfig_version=10.0.96
modmenu_version=6.1.0-rc.4
fabric_version=0.81.2+1.20
clothconfig_version=11.0.97
modmenu_version=6.2.2
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.CartographyTableScreen;
import net.minecraft.client.util.math.MatrixStack;

@Environment(EnvType.CLIENT)
@Mixin(CartographyTableScreen.class)
public class CartographyTableScreenTabAdder {
@Inject(method = "drawBackground", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/client/gui/screen/ingame/CartographyTableScreen;renderBackground(Lnet/minecraft/client/util/math/MatrixStack;)V"))
protected void drawBackgroundTabs(MatrixStack matrices, float delta, int mouseX, int mouseY,
CallbackInfo callbackInfo) {
@Inject(method = "drawBackground", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/client/gui/screen/ingame/CartographyTableScreen;renderBackground(Lnet/minecraft/client/gui/DrawContext;)V"))
protected void drawBackgroundTabs(DrawContext context, float delta, int mouseX, int mouseY, CallbackInfo ci) {
MinecraftClient client = MinecraftClient.getInstance();
TabManager tabManager = ((TabManagerContainer) client).getTabManager();

tabManager.tabRenderer.renderBackground(matrices);
tabManager.tabRenderer.renderBackground(context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@
public class ControlsListWidget$KeyBindingEntryMixin_SoftConflict {
@Shadow @Final private KeyBinding binding;

@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/ButtonWidget;setMessage(Lnet/minecraft/text/Text;)V"))
public Text setMessage(Text text) {
TextColor c = text.getStyle().getColor();
if(c != null && c.getRgb() == Objects.requireNonNull(Formatting.RED.getColorValue())) {
if(this.binding == InventoryTabsClient.NEXT_TAB_KEY_BIND) {
text = text.copy().formatted(Formatting.GOLD);
}
@ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/MutableText;formatted(Lnet/minecraft/util/Formatting;)Lnet/minecraft/text/MutableText;"))
public Formatting setBracketsColor(Formatting color) {
if (this.binding == InventoryTabsClient.NEXT_TAB_KEY_BIND && color.equals(Formatting.RED)) {
return Formatting.GOLD;
}
return text;

return color;
}

@ModifyArg(index = 4, method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;fill(IIIII)V"))
public int setIndicatorColor(int color) {
if (this.binding == InventoryTabsClient.NEXT_TAB_KEY_BIND) {
return Formatting.GOLD.getColorValue() | 0xFF000000;
}

return color;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.LoomScreen;
import net.minecraft.client.util.math.MatrixStack;

@Environment(EnvType.CLIENT)
@Mixin(LoomScreen.class)
public class LoomScreenTabAdder {
@Inject(method = "drawBackground", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/client/gui/screen/ingame/LoomScreen;renderBackground(Lnet/minecraft/client/util/math/MatrixStack;)V"))
protected void drawBackgroundTabs(MatrixStack matrices, float delta, int mouseX, int mouseY,
CallbackInfo callbackInfo) {
@Inject(method = "drawBackground", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/client/gui/screen/ingame/LoomScreen;renderBackground(Lnet/minecraft/client/gui/DrawContext;)V"))
protected void drawBackgroundTabs(DrawContext context, float delta, int mouseX, int mouseY, CallbackInfo ci) {
MinecraftClient client = MinecraftClient.getInstance();
TabManager tabManager = ((TabManagerContainer) client).getTabManager();

tabManager.tabRenderer.renderBackground(matrices);
tabManager.tabRenderer.renderBackground(context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.StonecutterScreen;
import net.minecraft.client.util.math.MatrixStack;

@Environment(EnvType.CLIENT)
@Mixin(StonecutterScreen.class)
public class StonecutterScreenTabAdder {
@Inject(method = "drawBackground", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/client/gui/screen/ingame/StonecutterScreen;renderBackground(Lnet/minecraft/client/util/math/MatrixStack;)V"))
protected void drawBackgroundTabs(MatrixStack matrices, float delta, int mouseX, int mouseY,
CallbackInfo callbackInfo) {
@Inject(method = "drawBackground", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/client/gui/screen/ingame/StonecutterScreen;renderBackground(Lnet/minecraft/client/gui/DrawContext;)V"))
protected void drawBackgroundTabs(DrawContext context, float delta, int mouseX, int mouseY, CallbackInfo ci) {
MinecraftClient client = MinecraftClient.getInstance();
TabManager tabManager = ((TabManagerContainer) client).getTabManager();

tabManager.tabRenderer.renderBackground(matrices);
tabManager.tabRenderer.renderBackground(context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import net.fabricmc.loader.api.FabricLoader;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.*;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -74,7 +75,7 @@ private void initTabRenderer(CallbackInfo callbackInfo) {
matchingBlockPositions.add(blockPos);

// For double chests
World world = client.player.world;
World world = client.player.getWorld();
if (world.getBlockState(blockPos).getBlock() instanceof ChestBlock) {
if (ChestUtil.isDouble(world, blockPos)) {
matchingBlockPositions.add(ChestUtil.getOtherChestBlockPos(world, blockPos));
Expand All @@ -101,27 +102,25 @@ private void initTabRenderer(CallbackInfo callbackInfo) {
}

@Inject(method = "render", at = @At("HEAD"))
protected void drawBackgroundTabs(MatrixStack matrices, int mouseX, int mouseY, float delta,
CallbackInfo callbackInfo) {
protected void drawBackgroundTabs(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (InventoryTabsClient.screenSupported(this)) {
if (!screenDoesDumbBlock()) {
MinecraftClient client = MinecraftClient.getInstance();
TabManager tabManager = ((TabManagerContainer) client).getTabManager();

tabManager.tabRenderer.renderBackground(matrices);
tabManager.tabRenderer.renderBackground(context);
}
}
}

@Inject(method = "render", at = @At("TAIL"))
protected void drawForegroundTabs(MatrixStack matrices, int mouseX, int mouseY, float delta,
CallbackInfo callbackInfo) {
protected void drawForegroundTabs(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (InventoryTabsClient.screenSupported(this)) {
MinecraftClient client = MinecraftClient.getInstance();
TabManager tabManager = ((TabManagerContainer) client).getTabManager();

tabManager.tabRenderer.renderForeground(matrices, mouseX, mouseY);
tabManager.tabRenderer.renderHoverTooltips(matrices, mouseX, mouseY);
tabManager.tabRenderer.renderForeground(context, mouseX, mouseY);
tabManager.tabRenderer.renderHoverTooltips(context, mouseX, mouseY);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
@Environment(EnvType.CLIENT)
@Mixin(Screen.class)
public interface ScreenAccessor {
@Accessor
ItemRenderer getItemRenderer();

@Accessor
TextRenderer getTextRenderer();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public abstract class BlockTabProvider implements TabProvider {

@Override
public void addAvailableTabs(ClientPlayerEntity player, List<Tab> tabs) {
World world = player.world;
World world = player.getWorld();

// TODO: make this better and check line of sight
for (int x = -SEARCH_DISTANCE; x <= SEARCH_DISTANCE; x++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void addAvailableTabs(ClientPlayerEntity player, List<Tab> tabs) {
List<ChestTab> chestTabs = tabs.stream().filter(tab -> tab instanceof ChestTab).map(tab -> (ChestTab) tab)
.filter(tab -> chestBlocks.contains(tab.blockId)).toList();

World world = player.world;
World world = player.getWorld();

// Add any chests that are blocked
chestTabs.stream().filter(tab -> ChestBlock.isChestBlocked(world, tab.blockPos)).forEach(tabsToRemove::add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void addAvailableTabs(ClientPlayerEntity player, List<Tab> tabs) {
List<ChestTab> chestTabs = tabs.stream().filter(tab -> tab instanceof ChestTab).map(tab -> (ChestTab) tab)
.filter(tab -> tab.blockId == Registries.BLOCK.getId(Blocks.ENDER_CHEST)).toList();

World world = player.world;
World world = player.getWorld();

// Add any chests that are blocked
chestTabs.stream().filter(tab -> ChestBlock.isChestBlocked(world, tab.blockPos)).forEach(tabsToRemove::add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public abstract class EntityTabProvider implements TabProvider {
public static final int SEARCH_DISTANCE = 5;
@Override
public void addAvailableTabs(ClientPlayerEntity player, List<Tab> tabs) {
World world = player.world;
World world = player.getWorld();
List<Entity> entityList = world.getNonSpectatingEntities(Entity.class, new Box(player.getBlockPos().getX()-SEARCH_DISTANCE, player.getBlockPos().getY()-SEARCH_DISTANCE, player.getBlockPos().getZ()-SEARCH_DISTANCE, player.getBlockPos().getX()+SEARCH_DISTANCE, player.getBlockPos().getY()+SEARCH_DISTANCE, player.getBlockPos().getZ()+SEARCH_DISTANCE));

for (Entity entity : entityList) {
Expand Down Expand Up @@ -60,4 +60,4 @@ public void addAvailableTabs(ClientPlayerEntity player, List<Tab> tabs) {
* @return
*/
public abstract Tab createTab(Entity entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public void addAvailableTabs(ClientPlayerEntity player, List<Tab> tabs) {
List<SimpleBlockTab> lecternTabs = tabs.stream().filter(tab -> tab instanceof SimpleBlockTab).map(tab -> (SimpleBlockTab) tab)
.filter(tab -> tab.blockId == Registries.BLOCK.getId(Blocks.LECTERN)).toList();
lecternTabs.stream().filter(tab -> {
BlockEntity blockEntity = player.world.getBlockEntity(tab.blockPos);
BlockEntity blockEntity = player.getWorld().getBlockEntity(tab.blockPos);

if (blockEntity instanceof LecternBlockEntity) {
BlockState blockState = player.world.getBlockState(tab.blockPos);
BlockState blockState = player.getWorld().getBlockState(tab.blockPos);

return !blockState.get(HAS_BOOK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public void addAvailableTabs(ClientPlayerEntity player, List<Tab> tabs) {

// Add any chests that are blocked
shulkerTabs.stream().filter(tab -> {
BlockEntity blockEntity = player.world.getBlockEntity(tab.blockPos);
BlockEntity blockEntity = player.getWorld().getBlockEntity(tab.blockPos);

if (blockEntity instanceof ShulkerBoxBlockEntity) {
BlockState blockState = player.world.getBlockState(tab.blockPos);
BlockState blockState = player.getWorld().getBlockState(tab.blockPos);

return !ShulkerBoxBlockInvoker.invokeCanOpen(blockState, player.world, tab.blockPos,
return !ShulkerBoxBlockInvoker.invokeCanOpen(blockState, player.getWorld(), tab.blockPos,
(ShulkerBoxBlockEntity) blockEntity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void addAvailableTabs(ClientPlayerEntity player, List<Tab> tabs) {
Set<SimpleEntityTab> tabsToRemove = new HashSet<>();
List<SimpleEntityTab> entityTabs = tabs.stream().filter(tab -> tab instanceof SimpleEntityTab).map(tab -> (SimpleEntityTab) tab)
.filter(tab -> entities.contains(tab.entityId)).toList();
World world = player.world;
World world = player.getWorld();
}

@Override
Expand All @@ -39,4 +39,4 @@ public void addEntity(Identifier entityId) {
public Tab createTab(Entity entity) {
return new SimpleEntityTab(entity);
}
}
}
Loading