Skip to content

Commit

Permalink
Switch to mojmap and fix any issues within #15
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragon-Seeker committed Apr 17, 2024
1 parent 5f9b4d4 commit 60022ba
Show file tree
Hide file tree
Showing 34 changed files with 606 additions and 978 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ bin/
run/
/old-buildstuff/
/old-src/
remappedSrc/
15 changes: 10 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
}

architectury {
Expand All @@ -14,12 +14,17 @@ subprojects {
silentMojangMappingsLicense()
}

repositories {
maven { url "https://maven.parchmentmc.org" }
}

dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
// The following line declares the mojmap mappings, you may use other mappings as well
//mappings loom.officialMojangMappings()
// The following line declares the yarn mappings you may select this one as well.
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"

mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-1.20.4:2024.04.14@zip")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.ConfigHolder;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionResult;

public class CondensedCreative {

Expand All @@ -28,7 +28,7 @@ public static void onInitializeClient(boolean debugEnv) {
MAIN_CONFIG.registerSaveListener((configHolder, condensedCreativeConfig) -> {
CondensedEntryRegistry.refreshEntrypoints();

return ActionResult.SUCCESS;
return InteractionResult.SUCCESS;
});

for(CondensedCreativeInitializer initializer : LoaderSpecificUtils.getEntryPoints()){
Expand All @@ -48,8 +48,8 @@ public static boolean isDeveloperMode(){
return DEBUG_ENV || DEBUG;
}

public static Identifier createID(String path){
return new Identifier(MODID, path);
public static ResourceLocation createID(String path){
return new ResourceLocation(MODID, path);
}

//---------------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@
import io.wispforest.condensed_creative.entry.impl.CondensedItemEntry;
import io.wispforest.condensed_creative.util.CondensedInventory;
import me.shedaniel.math.Color;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.screen.slot.Slot;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.Slot;

public class SlotRenderUtils {

private static final Identifier PLUS_ICON = CondensedCreative.createID("textures/gui/plus_logo.png");
private static final Identifier MINUS_ICON = CondensedCreative.createID("textures/gui/minus_logo.png");
private static final ResourceLocation PLUS_ICON = CondensedCreative.createID("textures/gui/plus_logo.png");
private static final ResourceLocation MINUS_ICON = CondensedCreative.createID("textures/gui/minus_logo.png");

public static void renderExtraIfEntry(HandledScreen screen, DrawContext context, Slot slot){
if(!(screen instanceof CreativeInventoryScreen && slot.inventory instanceof CondensedInventory inv)) return;
public static void renderExtraIfEntry(AbstractContainerScreen screen, GuiGraphics context, Slot slot){
if(!(screen instanceof CreativeModeInventoryScreen && slot.container instanceof CondensedInventory inv)) return;

Entry entryStack = inv.getEntryStack(slot.getIndex());
Entry entryStack = inv.getEntryStack(slot.getContainerSlot());

if(!(entryStack instanceof CondensedItemEntry entry)) return;

Expand Down Expand Up @@ -67,49 +65,45 @@ public static void renderExtraIfEntry(HandledScreen screen, DrawContext context,
}

if(!entry.isChild) {
Identifier id = !CondensedItemEntry.CHILD_VISIBILITY.get(entry.condensedID) ? PLUS_ICON : MINUS_ICON;
ResourceLocation id = !CondensedItemEntry.CHILD_VISIBILITY.get(entry.condensedID) ? PLUS_ICON : MINUS_ICON;

context.drawTexture(id, minX, minY, 160, 0, 0, 16, 16, 16, 16);
context.blit(id, minX, minY, 160, 0, 0, 16, 16, 16, 16);
}
}

@Unique
public static boolean isSlotAbovePartOfCondensedEntry(Slot slot, Identifier condensedID){
int topSlotIndex = slot.getIndex() - 9;
private static boolean isSlotAbovePartOfCondensedEntry(Slot slot, ResourceLocation condensedID){
int topSlotIndex = slot.getContainerSlot() - 9;

return topSlotIndex >= 0 &&
((CondensedInventory) slot.inventory).getEntryStack(topSlotIndex) instanceof CondensedItemEntry condensedItemEntry &&
((CondensedInventory) slot.container).getEntryStack(topSlotIndex) instanceof CondensedItemEntry condensedItemEntry &&
condensedID == condensedItemEntry.condensedID;
}

@Unique
public static boolean isSlotBelowPartOfCondensedEntry(Slot slot, Identifier condensedID){
int bottomSlotIndex = slot.getIndex() + 9;
private static boolean isSlotBelowPartOfCondensedEntry(Slot slot, ResourceLocation condensedID){
int bottomSlotIndex = slot.getContainerSlot() + 9;

return bottomSlotIndex < slot.inventory.size() &&
((CondensedInventory) slot.inventory).getEntryStack(bottomSlotIndex) instanceof CondensedItemEntry condensedItemEntry &&
return bottomSlotIndex < slot.container.getContainerSize() &&
((CondensedInventory) slot.container).getEntryStack(bottomSlotIndex) instanceof CondensedItemEntry condensedItemEntry &&
condensedID == condensedItemEntry.condensedID;
}

@Unique
public static boolean isSlotLeftPartOfCondensedEntry(Slot slot, Identifier condensedID){
if(((slot.id) % 9 == 0)) return false;
private static boolean isSlotLeftPartOfCondensedEntry(Slot slot, ResourceLocation condensedID){
if(((slot.index) % 9 == 0)) return false;

int leftSlotIndex = slot.getIndex() - 1;
int leftSlotIndex = slot.getContainerSlot() - 1;

return leftSlotIndex < slot.inventory.size() &&
((CondensedInventory) slot.inventory).getEntryStack(leftSlotIndex) instanceof CondensedItemEntry condensedItemEntry &&
return leftSlotIndex < slot.container.getContainerSize() &&
((CondensedInventory) slot.container).getEntryStack(leftSlotIndex) instanceof CondensedItemEntry condensedItemEntry &&
condensedID == condensedItemEntry.condensedID;
}

@Unique
public static boolean isSlotRightPartOfCondensedEntry(Slot slot, Identifier condensedID){
if(((slot.id) % 9 == 8)) return false;
private static boolean isSlotRightPartOfCondensedEntry(Slot slot, ResourceLocation condensedID){
if(((slot.index) % 9 == 8)) return false;

int rightSlotIndex = slot.getIndex() + 1;
int rightSlotIndex = slot.getContainerSlot() + 1;

return rightSlotIndex < slot.inventory.size() &&
((CondensedInventory) slot.inventory).getEntryStack(rightSlotIndex) instanceof CondensedItemEntry condensedItemEntry &&
return rightSlotIndex < slot.container.getContainerSize() &&
((CondensedInventory) slot.container).getEntryStack(rightSlotIndex) instanceof CondensedItemEntry condensedItemEntry &&
condensedID == condensedItemEntry.condensedID;
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package io.wispforest.condensed_creative.compat;

import net.minecraft.item.ItemGroup;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;

/**
* A Handler for ItemGroups that may have various tabs within the given ItemGroup
*/
public abstract class ItemGroupVariantHandler<I extends ItemGroup> {
public abstract class ItemGroupVariantHandler<I extends CreativeModeTab> {

private static final Map<Identifier, ItemGroupVariantHandler<?>> VARIANT_HANDLERS = new HashMap<>();
private static final Map<ResourceLocation, ItemGroupVariantHandler<?>> VARIANT_HANDLERS = new HashMap<>();

private final Class<I> clazz;
private final Identifier id;
private final ResourceLocation id;

protected ItemGroupVariantHandler(Class<I> clazz, Identifier id){
protected ItemGroupVariantHandler(Class<I> clazz, ResourceLocation id){
this.clazz = clazz;
this.id = id;
}
Expand All @@ -29,7 +29,7 @@ protected ItemGroupVariantHandler(Class<I> clazz, Identifier id){
* Attempts to register a given {@link ItemGroupVariantHandler} to the main registry
* with check to see if an existing handler for the same ItemGroup clazz exists
*/
public static <I extends ItemGroup> void registerOptional(ItemGroupVariantHandler<I> handler){
public static <I extends CreativeModeTab> void registerOptional(ItemGroupVariantHandler<I> handler){
for (ItemGroupVariantHandler<?> value : VARIANT_HANDLERS.values()) {
if(value.clazz.equals(handler.clazz)) return;
}
Expand All @@ -40,7 +40,7 @@ public static <I extends ItemGroup> void registerOptional(ItemGroupVariantHandle
/**
* Register a given {@link ItemGroupVariantHandler} to the main registry
*/
public static <I extends ItemGroup> void register(ItemGroupVariantHandler<I> handler){
public static <I extends CreativeModeTab> void register(ItemGroupVariantHandler<I> handler){
var id = handler.getIdentifier();

if(VARIANT_HANDLERS.containsKey(id)){
Expand All @@ -54,7 +54,7 @@ public static <I extends ItemGroup> void register(ItemGroupVariantHandler<I> han
* Attempt to return an any handler for the given ItemGroup or null if not none are found
*/
@Nullable
public static ItemGroupVariantHandler<?> getHandler(ItemGroup itemGroup){
public static ItemGroupVariantHandler<?> getHandler(CreativeModeTab itemGroup){
for (var handler : VARIANT_HANDLERS.values()) {
if(handler.isVariant(itemGroup)) return handler;
}
Expand All @@ -72,30 +72,30 @@ public static Collection<ItemGroupVariantHandler<?>> getHandlers(){
//--

/**
* @return whether the {@link ItemGroup} is of the targeted variant
* @return whether the {@link CreativeModeTab} is of the targeted variant
*/
public final boolean isVariant(ItemGroup group){
public final boolean isVariant(CreativeModeTab group){
return clazz.isInstance(group);
}

/**
* Unique Identifier representing the Variant handler
*/
public final Identifier getIdentifier(){
public final ResourceLocation getIdentifier(){
return this.id;
}

//--

/**
* @return Collection of all selected tabs of the given {@link ItemGroup} Variant
* @return Collection of all selected tabs of the given {@link CreativeModeTab} Variant
*/
public abstract Collection<Integer> getSelectedTabs(ItemGroup group);
public abstract Collection<Integer> getSelectedTabs(CreativeModeTab group);

/**
* @return Get max tabs supported by this {@link ItemGroup} Variant
* @return Get max tabs supported by this {@link CreativeModeTab} Variant
*/
public abstract int getMaxTabs(ItemGroup group);
public abstract int getMaxTabs(CreativeModeTab group);

//--

Expand Down
Loading

0 comments on commit 60022ba

Please sign in to comment.