diff options
| author | Danielshe <shekwancheung0528@gmail.com> | 2019-11-03 14:44:52 +0800 |
|---|---|---|
| committer | Danielshe <shekwancheung0528@gmail.com> | 2019-11-03 14:44:59 +0800 |
| commit | 9f5a9eae9a7863412cc5eb433bf15e5ee71da616 (patch) | |
| tree | 0e6b0b94af061c5e9023b1ff19f339a6c30149be /src/main/java | |
| parent | 3e3e25855b9f6df507a7d4c8a07c64b9a502fae2 (diff) | |
| download | RoughlyEnoughItems-9f5a9eae9a7863412cc5eb433bf15e5ee71da616.tar.gz RoughlyEnoughItems-9f5a9eae9a7863412cc5eb433bf15e5ee71da616.tar.bz2 RoughlyEnoughItems-9f5a9eae9a7863412cc5eb433bf15e5ee71da616.zip | |
3.2.1
Diffstat (limited to 'src/main/java')
73 files changed, 2423 insertions, 1122 deletions
diff --git a/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java b/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java deleted file mode 100644 index c32053447..000000000 --- a/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.zeitheron.hammercore.client.utils; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.Window; -import org.lwjgl.opengl.GL11; - -/** - * This is originally the part of Hammer Lib, repacked in REI with permission. - * Adapted GL scissor for minecraft pixel resolution and adjusts (0;0) as left-top corner. - * - * @author Zeitheron - */ -public class Scissors { - /** - * Starts the scissor test - */ - public static void begin() { - GL11.glEnable(GL11.GL_SCISSOR_TEST); - } - - /** - * Setup the scissor bounds - * - * @param x the top left x coordinates - * @param y the top left y coordinates - * @param width the width of the bounds - * @param height the height of the bounds - */ - public static void scissor(int x, int y, int width, int height) { - Window window = MinecraftClient.getInstance().getWindow(); - - int sw = window.getWidth(); - int sh = window.getHeight(); - float dw = window.getScaledWidth(); - float dh = window.getScaledHeight(); - - x = Math.round(sw * (x / dw)); - y = Math.round(sh * (y / dh)); - - width = Math.round(sw * (width / dw)); - height = Math.round(sh * (height / dh)); - - GL11.glScissor(x, sh - height - y, width, height); - } - - /** - * Stops the scissor test - */ - public static void end() { - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } -}
\ No newline at end of file diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index 1b6d91e5b..dc65ed688 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -136,9 +136,10 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { registerClothEvents(); discoverPluginEntries(); - FabricLoader.getInstance().getAllMods().stream().map(ModContainer::getMetadata).filter(metadata -> metadata.containsCustomValue("roughlyenoughitems:plugins")).forEach(modMetadata -> { - RoughlyEnoughItemsCore.LOGGER.error("[REI] REI plugin from " + modMetadata.getId() + " is not loaded because it is too old!"); - }); + for (ModContainer modContainer : FabricLoader.getInstance().getAllMods()) { + if (modContainer.getMetadata().containsCustomValue("roughlyenoughitems:plugins")) + RoughlyEnoughItemsCore.LOGGER.error("[REI] REI plugin from " + modContainer.getMetadata().getId() + " is not loaded because it is too old!"); + } ClientSidePacketRegistry.INSTANCE.register(RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, (packetContext, packetByteBuf) -> { ItemStack stack = packetByteBuf.readItemStack(); diff --git a/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/src/main/java/me/shedaniel/rei/api/ClientHelper.java index 458379457..b72e86ea0 100644 --- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java +++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java @@ -55,28 +55,40 @@ public interface ClientHelper { void registerFabricKeyBinds(); /** - * Tries to cheat items using either packets or commands. + * Tries to cheat stack using either packets or commands. * * @param stack the stack to cheat in * @return whether it failed */ - boolean tryCheatingStack(ItemStack stack); + boolean tryCheatingEntry(EntryStack stack); + + default boolean tryCheatingStack(ItemStack stack) { + return tryCheatingEntry(EntryStack.create(stack)); + } /** - * Finds recipe for the item and opens the recipe screen. + * Finds recipe for the stack and opens the recipe screen. * * @param stack the stack to find recipe for * @return whether the stack has any recipes to show */ - boolean executeRecipeKeyBind(ItemStack stack); + boolean executeRecipeKeyBind(EntryStack stack); + + default boolean executeRecipeKeyBind(ItemStack stack) { + return executeRecipeKeyBind(EntryStack.create(stack)); + } /** - * Finds usage for the item and opens the recipe screen. + * Finds usage for the stack and opens the recipe screen. * * @param stack the stack to find usage for * @return whether the stack has any usages to show */ - boolean executeUsageKeyBind(ItemStack stack); + boolean executeUsageKeyBind(EntryStack stack); + + default boolean executeUsageKeyBind(ItemStack stack) { + return executeUsageKeyBind(EntryStack.create(stack)); + } FabricKeyBinding getFocusSearchFieldKeyBinding(); diff --git a/src/main/java/me/shedaniel/rei/api/Entry.java b/src/main/java/me/shedaniel/rei/api/Entry.java index fca8f9fd2..c0eb609bb 100644 --- a/src/main/java/me/shedaniel/rei/api/Entry.java +++ b/src/main/java/me/shedaniel/rei/api/Entry.java @@ -5,6 +5,7 @@ package me.shedaniel.rei.api; +import me.shedaniel.rei.api.annotations.ToBeRemoved; import me.shedaniel.rei.impl.FluidEntry; import me.shedaniel.rei.impl.ItemStackEntry; import net.minecraft.fluid.Fluid; @@ -12,7 +13,9 @@ import net.minecraft.item.ItemStack; import javax.annotation.Nullable; -public interface Entry { +@Deprecated +@ToBeRemoved +public interface Entry extends Cloneable { @SuppressWarnings("deprecation") static Entry create(ItemStack itemStack) { return new ItemStackEntry(itemStack); @@ -31,6 +34,18 @@ public interface Entry { @Nullable Fluid getFluid(); + Entry clone(); + + default EntryStack toEntryStack() { + if (getEntryType() == Type.ITEM) + return EntryStack.create(getItemStack()); + if (getEntryType() == Type.FLUID) + return EntryStack.create(getFluid()); + return EntryStack.empty(); + } + + boolean equalsEntry(Entry other, boolean checkTags); + public static enum Type { ITEM, FLUID } diff --git a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java index effd1c8a4..9a811a127 100644 --- a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java +++ b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java @@ -5,10 +5,13 @@ package me.shedaniel.rei.api; +import me.shedaniel.rei.api.annotations.ToBeRemoved; +import me.shedaniel.rei.utils.CollectionUtils; import net.minecraft.fluid.Fluid; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import java.util.Collections; import java.util.List; public interface EntryRegistry { @@ -18,7 +21,17 @@ public interface EntryRegistry { * * @return an unmodifiable item list */ - List<Entry> getEntryList(); + @Deprecated + default List<Entry> getEntryList() { + return Collections.unmodifiableList(getModifiableEntryList()); + } + + /** + * Gets the current modifiable stacks list + * + * @return a stacks list + */ + List<EntryStack> getStacksList(); /** * Gets the current modifiable item list @@ -26,7 +39,9 @@ public interface EntryRegistry { * @return an modifiable item list */ @Deprecated - List<Entry> getModifiableEntryList(); + default List<Entry> getModifiableEntryList() { + return CollectionUtils.map(getStacksList(), EntryStack::toEntry); + } /** * Gets all possible stacks from an item @@ -42,31 +57,66 @@ public interface EntryRegistry { * @param afterItem the stack to put after * @param stack the stack to register */ - void registerItemStack(Item afterItem, ItemStack stack); + @Deprecated + default void registerItemStack(Item afterItem, ItemStack stack) { + registerEntryAfter(EntryStack.create(afterItem), EntryStack.create(stack)); + } - void registerFluid(Fluid fluid); + @Deprecated + default void registerFluid(Fluid fluid) { + registerEntry(EntryStack.create(fluid)); + } + + default void registerEntry(EntryStack stack) { + registerEntryAfter(null, stack); + } + + void registerEntryAfter(EntryStack afterEntry, EntryStack stack); + + @ToBeRemoved + @Deprecated + default void registerItemStack(Item afterItem, ItemStack... stacks) { + EntryStack afterStack = EntryStack.create(afterItem); + for (int i = stacks.length - 1; i >= 0; i--) { + ItemStack stack = stacks[i]; + if (stack != null && !stack.isEmpty()) + registerEntryAfter(afterStack, EntryStack.create(stack)); + } + } /** * Registers multiple stacks to the item list * - * @param afterItem the stack to put after - * @param stacks the stacks to register + * @param afterStack the stack to put after + * @param stacks the stacks to register */ - default void registerItemStack(Item afterItem, ItemStack... stacks) { + default void registerEntriesAfter(EntryStack afterStack, EntryStack... stacks) { for (int i = stacks.length - 1; i >= 0; i--) { - ItemStack stack = stacks[i]; + EntryStack stack = stacks[i]; if (stack != null && !stack.isEmpty()) - registerItemStack(afterItem, stack); + registerEntryAfter(afterStack, stack); } } + @ToBeRemoved + @Deprecated + default void registerItemStack(ItemStack... stacks) { + registerItemStack(null, stacks); + } + /** * Registers multiple stacks to the item list * * @param stacks the stacks to register */ - default void registerItemStack(ItemStack... stacks) { - registerItemStack(null, stacks); + default void registerEntries(EntryStack... stacks) { + registerEntriesAfter(null, stacks); + } + + @ToBeRemoved |
