Skip to content

Commit

Permalink
Clean up (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: Caedis <[email protected]>
  • Loading branch information
0hwx and Caedis authored Jan 1, 2025
1 parent 6e31b63 commit a7bae97
Show file tree
Hide file tree
Showing 18 changed files with 129 additions and 185 deletions.
3 changes: 2 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ dependencies {
compileOnly("com.github.GTNewHorizons:Draconic-Evolution:1.3.14-GTNH:dev")
compileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-503-GTNH:dev")
compileOnly("com.github.GTNewHorizons:EnderStorage:1.6.4:dev")
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.12.14-GTNH:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:GT5-Unofficial:5.09.51.15:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:Botania:1.12.1-GTNH:dev")



compileOnly rfg.deobf('curse.maven:projecte-226410:2340786')
compileOnly rfg.deobf('curse.maven:rftools-224641:2287287')
compileOnly rfg.deobf("curse.maven:mcjtylib-233105:2272449")
compileOnly rfg.deobf('curse.maven:thermal_expansion-69163:2388758')
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/com/cleanroommc/bogosorter/BogoSortAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public static boolean isPlayerInventory(IInventory itemHandler) {

@Override
public int hashCode(ItemStack o) {
return Objects.hash(o.getItem(), o.getItemDamage(), o.getTagCompound()); //, getItemAccessor(o).getCapNBT());
return Objects.hash(o.getItem(), o.getItemDamage(), o.getTagCompound());
}

@Override
Expand All @@ -307,7 +307,7 @@ public boolean equals(ItemStack a, ItemStack b) {
return (a == null && b == null) ||
(a.getItem()==b.getItem() &&
a.getItemDamage()==b.getItemDamage() &&
Objects.equals(a.getTagCompound(), b.getTagCompound())); // && Objects.equals(getItemAccessor(a).getCapNBT(), getItemAccessor(b).getCapNBT()));
Objects.equals(a.getTagCompound(), b.getTagCompound()));
}
};

Expand All @@ -327,7 +327,4 @@ public boolean equals(ItemStack a, ItemStack b) {
}
};

// public static ItemStackAccessor getItemAccessor(ItemStack itemStack) {
// return (ItemStackAccessor) (Object) itemStack;
// }
}
3 changes: 1 addition & 2 deletions src/main/java/com/cleanroommc/bogosorter/BogoSorter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
version = BogoSorter.VERSION,
dependencies = "required-after:gtnhmixins;" +
"required-after:modularui2;")
//@EventBusSubscriber()
public class BogoSorter {

public static final String ID = "bogosorter";
Expand All @@ -54,7 +53,7 @@ public class BogoSorter {

@Mod.EventHandler
public void onPreInit(FMLPreInitializationEvent event) {
IntegrationLoader.INSTANCE.load();
IntegrationLoader.load();
FMLCommonHandler.instance().bus().register(this);
MinecraftForge.EVENT_BUS.register(this);
NetworkHandler.init();
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/com/cleanroommc/bogosorter/ClientEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ public void onRenderWorldLastEvent(RenderWorldLastEvent event) {

// handle all inputs in one method
public static boolean handleInput(@Nullable GuiContainer container) {
// if (container != null) {// && container.isFocused()) {
// return false;
// }

if (container != null && canDoShortcutAction()) {
if (moveAll.isFirstPress() && ShortcutHandler.moveAllItems(container, false)) {
shortcutAction();
Expand Down Expand Up @@ -268,8 +266,6 @@ public static boolean handleInput(@Nullable GuiContainer container) {

private static boolean canSort(@Nullable ISlot slot) {
return !Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode ||
// sortKey.getKeyModifier().isActive(null) != Minecraft.getMinecraft().gameSettings.keyBindPickBlock.getKeyModifier().isActive(null) ||
// sortKey.getKeyCode() != Minecraft.getMinecraft().gameSettings.keyBindPickBlock.getKeyCode() ||
(Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null && (slot == null || slot.bogo$getStack() == null));
}

Expand All @@ -278,7 +274,7 @@ private static boolean isButtonPressed(int button) {
}

private static boolean isKeyDown(KeyBinding key) {
// if (!key.getKeyModifier().isActive(null)) return false;

if (key.getKeyCode() < 0) {
return isButtonPressed(key.getKeyCode() + 100);
}
Expand Down Expand Up @@ -324,7 +320,7 @@ public static boolean sort(GuiScreen guiScreen, @Nullable ISlot slot) {
boolean color = sortRules.contains(BogoSortAPI.INSTANCE.getItemSortRule("color"));
boolean name = sortRules.contains(BogoSortAPI.INSTANCE.getItemSortRule("display_name"));
NetworkHandler.sendToServer(new CSort(createSortData(slotGroup, color, name), BogoSorterConfig.sortRules, BogoSorterConfig.nbtSortRules, slot.bogo$getSlotNumber(), slotGroup.isPlayerInventory()));
// SortHandler.playSortSound();
SortHandler.playSortSound();

return true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import com.cleanroommc.bogosorter.BogoSortAPI;
import com.cleanroommc.bogosorter.common.config.BogoSorterConfig;
import com.cleanroommc.bogosorter.compat.loader.Mods;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import gregtech.api.items.MetaGeneratedTool;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
Expand All @@ -14,13 +16,13 @@
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import tconstruct.library.util.IToolPart;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.Set;

//@EventBusSubscriber()
public class OreDictHelper {

private static final Map<ItemStack, Set<String>> ORE_DICTS = new Object2ObjectOpenCustomHashMap<>(BogoSortAPI.ITEM_META_HASH_STRATEGY);
Expand Down Expand Up @@ -75,12 +77,12 @@ public static Set<String> getOreDicts(ItemStack item) {
}

public static String getMaterial(ItemStack item) {
// if (BogoSorter.isGTCEuLoaded() && item.getItem() instanceof IGTTool) {
// return getGtToolMaterial(item);
// }
// if (BogoSorter.isTConstructLoaded() && item.getItem() instanceof IMaterialItem) {
// return ((IMaterialItem) item.getItem()).getMaterialID(item);
// }
if (Mods.GT5u.isLoaded() && item.getItem() instanceof MetaGeneratedTool) {
return getGtToolMaterial(item);
}
if (Mods.Tconstruct.isLoaded() && item.getItem() instanceof IToolPart) {
return String.valueOf(((IToolPart) item.getItem()).getMaterialID(item));
}
return MATERIALS.get(item);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import cpw.mods.fml.relauncher.SideOnly;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;


import java.util.ArrayList;
Expand Down Expand Up @@ -94,11 +95,11 @@ public static void load(JsonObject json) {
DropOffButtonHandler.buttonX = JsonHelper.getInt(general, 80, "dropoffButtonX");
DropOffButtonHandler.buttonY = JsonHelper.getInt(general, 12, "dropoffButtonY");
HotbarSwap.setEnabled(JsonHelper.getBoolean(general, true, "enableHotbarSwap"));
// SortHandler.sortSound = JsonHelper.getElement(general, SoundEvents.UI_BUTTON_CLICK, element -> {
// if (element.isJsonNull()) return null;
// SoundEvent soundEvent = SoundEvent.REGISTRY.getObject(new ResourceLocation(element.getAsString()));
// return soundEvent != null ? soundEvent : SoundEvents.UI_BUTTON_CLICK;
// }, "sortSound");
SortHandler.sortSound = JsonHelper.getElement(general, new ResourceLocation("gui.button.press"), element -> {
if (element.isJsonNull()) return null;
ResourceLocation soundEvent = new ResourceLocation(element.getAsString());
return soundEvent != null ? soundEvent : new ResourceLocation("gui.button.press");
}, "sortSound");
buttonColor = JsonHelper.getColor(general, 0xFFFFFFFF, "buttonColor");
}
sortRules.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ public class RefillHandler {
public RefillHandler(){
}

// private static final Class<?> gtToolClass;
//
// static {
// Class<?> clazz;
// try {
// clazz = Class.forName("gregtech.api.items.MetaGeneratedTool", false, RefillHandler.class.getClassLoader());
// } catch (Exception ignored) {
// clazz = null;
// }
// gtToolClass = clazz;
// }

private static final int[][] INVENTORY_PROXIMITY_MAP = {
{1, 2, 3, 4, 5, 6, 7, 8, 27, 18, 9, 28, 19, 10, 29, 20, 11, 30, 21, 12, 31, 22, 13, 32, 23, 14, 33, 24, 15, 34, 25, 16, 35, 26, 17},
Expand Down Expand Up @@ -129,10 +118,6 @@ public boolean handleRefill() {
}
}

private static boolean isGT5uTool(ItemStack itemStack) {
return itemStack.getItem() instanceof MetaGeneratedTool;
}

private boolean findItem(boolean exactOnly) {
ItemStack firstItemMatch = null;
int firstItemMatchSlot = -1;
Expand Down Expand Up @@ -242,14 +227,14 @@ private void setAndSyncSlot(int index, ItemStack item) {
private ItemStack getItem(int index) {
if (index < 36) return this.inventory.mainInventory[index];
if (index < 40) return this.inventory.mainInventory[index - 36];
return null; //this.inventory.offHandInventory.get(0);
return null;
}

private static boolean matchTags(ItemStack stackA, ItemStack stackB) {
if (stackA.getTagCompound() == null && stackB.getTagCompound() != null) {
return false;
} else {
return (stackA.getTagCompound() == null || stackA.getTagCompound().equals(stackB.getTagCompound())); // && stackA.areCapsCompatible(stackB);
return (stackA.getTagCompound() == null || stackA.getTagCompound().equals(stackB.getTagCompound()));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.cleanroommc.bogosorter.common.sort;

import com.cleanroommc.bogosorter.BogoSortAPI;
import com.cleanroommc.bogosorter.BogoSorter;
import com.cleanroommc.bogosorter.compat.loader.Mods;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraftforge.common.util.Constants;

Expand All @@ -29,13 +29,13 @@ public static void init(BogoSortAPI api) {
api.registerItemSortingRule("saturation", ItemCompareHelper::compareSaturation);
api.registerClientItemSortingRule("color", ItemCompareHelper::compareColor, ItemCompareHelper::compareColor);

// if (Loader.isModLoaded("projecte")) {
// api.registerItemSortingRule("emc", ItemCompareHelper::compareEMC);
// }
if (Mods.ProjectE.isLoaded()) {
api.registerItemSortingRule("emc", ItemCompareHelper::compareEMC);
}

api.registerNbtSortingRule("potion", "Potion", Constants.NBT.TAG_STRING, ItemCompareHelper::comparePotionId, DefaultRules::getPotionId);
// api.registerNbtSortingRule("enchantment", "ench", Constants.NBT.TAG_LIST, ItemCompareHelper::compareEnchantments, nbtBase -> (NBTTagList) nbtBase);
// api.registerNbtSortingRule("enchantment_book", "StoredEnchantments", Constants.NBT.TAG_LIST, ItemCompareHelper::compareEnchantments, nbtBase -> (NBTTagList) nbtBase);
api.registerNbtSortingRule("enchantment", "ench", Constants.NBT.TAG_LIST, ItemCompareHelper::compareEnchantments, nbtBase -> (NBTTagList) nbtBase);
api.registerNbtSortingRule("enchantment_book", "StoredEnchantments", Constants.NBT.TAG_LIST, ItemCompareHelper::compareEnchantments, nbtBase -> (NBTTagList) nbtBase);
if (Mods.GT5u.isLoaded()) {
api.registerNbtSortingRule("gt_circ_config", "Configuration", Constants.NBT.TAG_INT);
api.registerNbtSortingRule("gt_item_damage", "GT.ToolStats/Dmg", Constants.NBT.TAG_INT);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.cleanroommc.bogosorter.common.sort;

import com.cleanroommc.bogosorter.BogoSortAPI;
import com.cleanroommc.bogosorter.BogoSorter;
import com.cleanroommc.bogosorter.api.ISlot;
import com.cleanroommc.bogosorter.api.ISlotGroup;
import com.cleanroommc.bogosorter.api.ISortableContainer;
Expand Down
Loading

0 comments on commit a7bae97

Please sign in to comment.