Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;

import java.util.List;
import java.util.Objects;
Expand All @@ -36,11 +37,14 @@ public abstract class CreativeInventoryScreenMixin<T extends AbstractContainerMe
@Shadow
@Final
private List<CreativeTabsScreenPage> pages;
@Shadow
private CreativeTabsScreenPage currentPage;
@Shadow(aliases = "currentPage")
private CreativeTabsScreenPage currentSelectedPage;
@Shadow
private static CreativeModeTab selectedTab;

@Unique // Kept for mod internal usage
private static int currentPage;

@Shadow
abstract void setCurrentPage(CreativeTabsScreenPage currentPage);

Expand All @@ -63,24 +67,24 @@ public boolean switchToPage(int page) {
@Override
public boolean switchToNextPage() {
if (hasAdditionalPages()) {
this.setCurrentPage(this.pages.get(this.pages.indexOf(this.currentPage) + 1));
this.setCurrentPage(this.pages.get(this.pages.indexOf(this.currentSelectedPage) + 1));
return true;
}
return false;
}

@Override
public boolean switchToPreviousPage() {
if (this.pages.indexOf(this.currentPage) > 0) {
this.setCurrentPage(this.pages.get(this.pages.indexOf(this.currentPage) - 1));
if (this.pages.indexOf(this.currentSelectedPage) > 0) {
this.setCurrentPage(this.pages.get(this.pages.indexOf(this.currentSelectedPage) - 1));
return true;
}
return false;
}

@Override
public int getCurrentPage() {
return this.pages.indexOf(this.currentPage);
return this.pages.indexOf(this.currentSelectedPage);
}

@Override
Expand All @@ -102,7 +106,7 @@ public int getPage(CreativeModeTab itemGroup) {

@Override
public boolean hasAdditionalPages() {
return this.pages.indexOf(this.currentPage) < this.pages.size() - 1;
return this.pages.indexOf(this.currentSelectedPage) < this.pages.size() - 1;
}

@Override
Expand All @@ -118,7 +122,7 @@ public boolean setSelectedItemGroup(CreativeModeTab itemGroup) {
return false;
}

if (pages.indexOf(currentPage) != getPage(itemGroup)) {
if (pages.indexOf(currentSelectedPage) != getPage(itemGroup)) {
if (!switchToPage(getPage(itemGroup))) {
return false;
}
Expand All @@ -127,4 +131,14 @@ public boolean setSelectedItemGroup(CreativeModeTab itemGroup) {
selectTab(itemGroup);
return true;
}

@Unique
@Deprecated // Kept for mod internals
private boolean isGroupVisible(CreativeModeTab tab) {
return tab.shouldDisplay() && getCurrentPage() == getPage(tab);
}

@Unique
@Deprecated // Kept for mod internals
private void updateSelection() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.impl.registry.sync;

import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;

import java.util.HashMap;
import java.util.Map;

@Deprecated // Only for fighting internal usage by mods
public class RegistryMapSerializer {
public static final int VERSION = 1;

public static Map<ResourceLocation, Object2IntMap<ResourceLocation>> fromNbt(CompoundTag nbt) {
return new HashMap<>();
}

public static CompoundTag toNbt(Map<ResourceLocation, Object2IntMap<ResourceLocation>> map) {
return new CompoundTag();
}
}
2 changes: 1 addition & 1 deletion ffapi.gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
loom.platform=neoforge
fabric.loom.dontRemap=true

implementationVersion=2.0.2
implementationVersion=2.0.3

versionMc=1.21
versionForge=21.0.57-beta
Expand Down

0 comments on commit 262bc2d

Please sign in to comment.