diff --git a/gradle.properties b/gradle.properties index 538976f4..3eab2eae 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,4 +17,4 @@ org.gradle.daemon=false # Dependencies modmenu_version=2.0.0-beta.7 minelp_version=4.3.6 - kirin_version=1.9.1 + kirin_version=1.9.2-beta.1 diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/SpellTraits.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/SpellTraits.java index d0bd48cc..c0e2f3f9 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/SpellTraits.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/SpellTraits.java @@ -29,6 +29,7 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.network.PacketByteBuf; import net.minecraft.text.Text; +import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import net.minecraft.util.registry.Registry; @@ -105,7 +106,7 @@ public final class SpellTraits implements Iterable> { public NbtCompound toNbt() { NbtCompound nbt = new NbtCompound(); - traits.forEach((key, value) -> nbt.putFloat(key.name(), value)); + traits.forEach((key, value) -> nbt.putFloat(key.getId().toString(), value)); return nbt; } @@ -176,11 +177,15 @@ public final class SpellTraits implements Iterable> { } for (int i = 0; i < count; i++) { - Trait trait = Trait.REGISTRY.getOrDefault(buf.readIdentifier(), null); + Identifier id = buf.readIdentifier(); float value = buf.readFloat(); - if (trait != null) { - entries.compute(trait, (k, v) -> v == null ? value : (v + value)); + if (value == 0) { + continue; } + + Trait.fromId(id).ifPresent(trait -> { + entries.compute(trait, (k, v) -> v == null ? value : (v + value)); + }); } if (entries.isEmpty()) { return Optional.empty(); @@ -190,8 +195,8 @@ public final class SpellTraits implements Iterable> { public static Stream> streamFromNbt(NbtCompound traits) { return traits.getKeys().stream().map(key -> { - Trait trait = Trait.REGISTRY.get(key.toUpperCase()); - if (trait == null && !traits.contains(key, NbtElement.NUMBER_TYPE)) { + Trait trait = Trait.fromId(key).orElse(null); + if (trait == null || !traits.contains(key, NbtElement.NUMBER_TYPE)) { return null; } return Map.entry(trait, traits.getFloat(key)); @@ -200,7 +205,7 @@ public final class SpellTraits implements Iterable> { public static Stream> streamFromJson(JsonObject traits) { return traits.entrySet().stream().map(entry -> { - Trait trait = Trait.REGISTRY.get(entry.getKey().toUpperCase()); + Trait trait = Trait.fromName(entry.getKey()).orElse(null); if (trait == null || !entry.getValue().isJsonPrimitive() && !entry.getValue().getAsJsonPrimitive().isNumber()) { return null; } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/Trait.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/Trait.java index 4915d836..1548703d 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/Trait.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/Trait.java @@ -1,7 +1,9 @@ package com.minelittlepony.unicopia.ability.magic.spell.trait; import java.util.Arrays; +import java.util.Collection; import java.util.Map; +import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; @@ -33,14 +35,14 @@ public enum Trait { POISON(TraitGroup.DARKNESS), BLOOD(TraitGroup.DARKNESS); - public static final Map REGISTRY = Arrays.stream(values()).collect(Collectors.toMap(Trait::name, Function.identity())); - + private static final Map REGISTRY = Arrays.stream(values()).collect(Collectors.toMap(Trait::name, Function.identity())); + private static final Map IDS = Arrays.stream(values()).collect(Collectors.toMap(Trait::getId, Function.identity())); private final Identifier id; private final Identifier sprite; private final TraitGroup group; Trait(TraitGroup group) { - this.id = new Identifier("unicopia", "spell/trait/" + name().toLowerCase()); + this.id = new Identifier("unicopia", name().toLowerCase()); this.sprite = new Identifier("unicopia", "textures/gui/trait/" + name().toLowerCase() + ".png"); this.group = group; } @@ -56,4 +58,20 @@ public enum Trait { public Identifier getSprite() { return sprite; } + + public static Collection all() { + return IDS.values(); + } + + public static Optional fromId(Identifier id) { + return Optional.ofNullable(IDS.getOrDefault(id, null)); + } + + public static Optional fromId(String name) { + return Optional.ofNullable(Identifier.tryParse(name)).flatMap(Trait::fromId); + } + + public static Optional fromName(String name) { + return Optional.ofNullable(REGISTRY.getOrDefault(name.toUpperCase(), null)); + } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitDiscovery.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitDiscovery.java index fc9fed54..277128a3 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitDiscovery.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitDiscovery.java @@ -27,9 +27,9 @@ import net.minecraft.util.registry.Registry; import net.minecraft.world.World; public class TraitDiscovery implements NbtSerialisable { - private final Set unreadTraits = new HashSet<>(); + private final Set unreadTraits = new HashSet<>(); - private final Set traits = new HashSet<>(); + private final Set traits = new HashSet<>(); private final Map items = new HashMap<>(); private final Pony pony; @@ -57,8 +57,8 @@ public class TraitDiscovery implements NbtSerialisable { SpellTraits traits = SpellTraits.of(item); items.put(Registry.ITEM.getId(item), traits); traits.entries().forEach(e -> { - if (this.traits.add(e.getKey().getId())) { - unreadTraits.add(e.getKey().getId()); + if (this.traits.add(e.getKey())) { + unreadTraits.add(e.getKey()); } }); pony.setDirty(); @@ -68,6 +68,14 @@ public class TraitDiscovery implements NbtSerialisable { return items.getOrDefault(Registry.ITEM.getId(item), SpellTraits.EMPTY); } + public boolean isUnread(Trait trait) { + return unreadTraits.contains(trait); + } + + public boolean isKnown(Trait trait) { + return traits.contains(trait); + } + @Environment(EnvType.CLIENT) public void appendTooltip(ItemStack stack, @Nullable World world, List tooltip) { getKnownTraits(stack.getItem()).appendTooltip(tooltip); @@ -82,11 +90,11 @@ public class TraitDiscovery implements NbtSerialisable { compound.put("items", disco); NbtList a = new NbtList(); - this.traits.forEach(id -> a.add(NbtString.of(id.toString()))); + this.traits.forEach(id -> a.add(NbtString.of(id.getId().toString()))); compound.put("traits", a); NbtList b = new NbtList(); - unreadTraits.forEach(id -> b.add(NbtString.of(id.toString()))); + unreadTraits.forEach(id -> b.add(NbtString.of(id.getId().toString()))); compound.put("unreadTraits", b); } @@ -101,12 +109,18 @@ public class TraitDiscovery implements NbtSerialisable { }); }); }); - compound.getList("traits", NbtElement.STRING_TYPE).forEach(el -> { - Optional.ofNullable(Identifier.tryParse(el.asString())).ifPresent(this.traits::add); - }); - compound.getList("unreadTraits", NbtElement.STRING_TYPE).forEach(el -> { - Optional.ofNullable(Identifier.tryParse(el.asString())).ifPresent(this.unreadTraits::add); - }); + compound.getList("traits", NbtElement.STRING_TYPE).stream() + .map(NbtElement::asString) + .map(Trait::fromId) + .filter(Optional::isPresent) + .map(Optional::get) + .forEach(this.traits::add); + compound.getList("unreadTraits", NbtElement.STRING_TYPE).stream() + .map(NbtElement::asString) + .map(Trait::fromId) + .filter(Optional::isPresent) + .map(Optional::get) + .forEach(this.unreadTraits::add); } public void copyFrom(TraitDiscovery old) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitLoader.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitLoader.java index 27e01924..0ab4ac11 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitLoader.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitLoader.java @@ -55,7 +55,7 @@ public class TraitLoader extends SinglePreparationResourceReloader a.split(":")).map(pair -> { - Trait key = Trait.REGISTRY.get(pair[0].toUpperCase()); + Trait key = Trait.fromName(pair[0]).orElse(null); if (key == null) { Unicopia.LOGGER.warn("Failed to load trait entry for item {} in {}. {} is not a valid trait", id, resource.getResourcePackName(), pair[0]); return null; diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellbookPage.java b/src/main/java/com/minelittlepony/unicopia/container/SpellbookPage.java new file mode 100644 index 00000000..b9543543 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/container/SpellbookPage.java @@ -0,0 +1,36 @@ +package com.minelittlepony.unicopia.container; + +import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; +import net.minecraft.util.math.MathHelper; + +public enum SpellbookPage { + INVENTORY, + DISCOVERIES, + RECIPES; + + public static final SpellbookPage[] VALUES = values(); + private static int current; + + private final Text label = new TranslatableText("gui.unicopia.spellbook.page." + name().toLowerCase()); + + public Text getLabel() { + return label; + } + + public boolean isFirst() { + return ordinal() == 0; + } + + public boolean isLast() { + return ordinal() == VALUES.length - 1; + } + + public static SpellbookPage getCurrent() { + return VALUES[current]; + } + + public static void swap(int increment) { + current = MathHelper.clamp(current + increment, 0, VALUES.length - 1); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreen.java b/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreen.java index 7f4c28b0..0e469800 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreen.java @@ -1,27 +1,93 @@ package com.minelittlepony.unicopia.container; +import java.util.List; + +import com.minelittlepony.common.client.gui.IViewRoot; +import com.minelittlepony.common.client.gui.ScrollContainer; +import com.minelittlepony.common.client.gui.element.Button; +import com.minelittlepony.common.client.gui.sprite.TextureSprite; +import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; +import com.minelittlepony.unicopia.ability.magic.spell.trait.TraitDiscovery; import com.minelittlepony.unicopia.container.SpellbookScreenHandler.SpellbookSlot; +import com.minelittlepony.unicopia.entity.player.Pony; +import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.screen.slot.Slot; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; public class SpellbookScreen extends HandledScreen { public static final Identifier TEXTURE = new Identifier("unicopia", "textures/gui/container/book.png"); + public static final Identifier SLOT = new Identifier("unicopia", "textures/gui/container/slot.png"); + + private final ScrollContainer container = new ScrollContainer() { + { + backgroundColor = 0xFFf9efd3; + scrollbar.layoutToEnd = true; + } + @Override + public void init(Runnable contentInitializer) { + margin.left = SpellbookScreen.this.x + backgroundWidth / 2 + 10; + margin.top = SpellbookScreen.this.y + 35; + margin.right = SpellbookScreen.this.width - backgroundWidth - SpellbookScreen.this.x + 30; + margin.bottom = SpellbookScreen.this.height - backgroundHeight - SpellbookScreen.this.y + 40; + super.init(contentInitializer); + } + + @Override + public void drawOverlays(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { + matrices.push(); + matrices.translate(margin.left, margin.top, 0); + matrices.translate(-2, -2, 0); + RenderSystem.enableBlend(); + RenderSystem.setShaderTexture(0, TEXTURE); + int tileSize = 25; + + final int bottom = height - tileSize + 4; + final int right = width - tileSize + 9; + + drawTexture(matrices, 0, 0, 405, 62, tileSize, tileSize, 512, 256); + drawTexture(matrices, right, 0, 425, 62, tileSize, tileSize, 512, 256); + + drawTexture(matrices, 0, bottom, 405, 72, tileSize, tileSize, 512, 256); + drawTexture(matrices, right, bottom, 425, 72, tileSize, tileSize, 512, 256); + + for (int i = tileSize; i < right; i += tileSize) { + drawTexture(matrices, i, 0, 415, 62, tileSize, tileSize, 512, 256); + drawTexture(matrices, i, bottom, 415, 72, tileSize, tileSize, 512, 256); + } + + for (int i = tileSize; i < bottom; i += tileSize) { + drawTexture(matrices, 0, i, 405, 67, tileSize, tileSize, 512, 256); + drawTexture(matrices, right, i, 425, 67, tileSize, tileSize, 512, 256); + } + matrices.pop(); + + super.drawOverlays(matrices, mouseX, mouseY, partialTicks); + } + }; public SpellbookScreen(SpellbookScreenHandler handler, PlayerInventory inventory, Text title) { super(handler, inventory, title); backgroundWidth = 405; backgroundHeight = 219; + titleX = 30; + titleY = 20; } @Override public void init() { super.init(); + container.init(this::initPageContent); + addDrawableChild(new PageButton(x + 350, y + 187, 1)); + addDrawableChild(new PageButton(x + 300, y + 187, -1)); } @Override @@ -34,30 +100,172 @@ public class SpellbookScreen extends HandledScreen { protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) { renderBackground(matrices, 0); RenderSystem.setShaderColor(1, 1, 1, 1); + RenderSystem.setShaderTexture(0, TEXTURE); int left = (width - backgroundWidth) / 2; int top = (height - backgroundHeight) / 2; - RenderSystem.setShaderTexture(0, TEXTURE); - drawTexture(matrices, left, top, 0, 0, backgroundWidth, backgroundHeight, 512, 256); + } - matrices.push(); - matrices.translate(this.x, this.y, 0); - + @Override + protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) { + RenderSystem.setShaderColor(1, 1, 1, 1); + RenderSystem.setShaderTexture(0, SLOT); RenderSystem.enableBlend(); for (Slot slot : handler.slots) { if (slot.isEnabled() && slot instanceof SpellbookSlot) { - drawTexture(matrices, slot.x - 1, slot.y - 1, 74, 223, 18, 18, 512, 256); - // drawStringWithShadow(matrices, this.textRenderer, ((SpellbookSlot)slot).getRing() + "", slot.x, slot.y, 0x000000FF); + drawTexture(matrices, slot.x - 8, slot.y - 8, 0, 0, 32, 32, 32, 32); } } RenderSystem.disableBlend(); - RenderSystem.enableBlend(); - drawTexture(matrices, 56, 50, 407, 2, 100, 101, 512, 256); - RenderSystem.disableBlend(); + textRenderer.draw(matrices, title, titleX, titleY, 4210752); + textRenderer.draw(matrices, SpellbookPage.getCurrent().getLabel(), 220, this.titleY, 4210752); + } - matrices.pop(); + private void initPageContent() { + container.getContentPadding().setVertical(10); + addDrawable(container); + ((IViewRoot)this).getChildElements().add(container); + + switch (SpellbookPage.getCurrent()) { + case DISCOVERIES: { + int top = 10; + int left = 25; + + int i = 0; + int cols = 4; + + for (Trait trait : Trait.all()) { + int x = i % cols; + int y = i / cols; + + container.addButton(new TraitButton(left + x * 32, top + y * 32, trait)); + i++; + } + break; + } + case INVENTORY: + case RECIPES: + } + } + + @Override + public boolean mouseReleased(double mouseX, double mouseY, int button) { + return hoveredElement(mouseX, mouseY).filter((element) -> { + setDragging(false); + return element.mouseReleased(mouseX, mouseY, button); + }).isPresent() || super.mouseReleased(mouseX, mouseY, button); + } + + @Override + public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { + return (getFocused() != null && isDragging() && button == 0 && getFocused().mouseDragged(mouseX, mouseY, button, deltaX, deltaY)) + || super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); + } + + class PageButton extends ImageButton { + private final int increment; + private final TextureSprite sprite = new TextureSprite() + .setSize(25, 13) + .setTextureSize(256, 512) + .setTextureOffset(0, 479) + .setTexture(TEXTURE); + + public PageButton(int x, int y, int increment) { + super(x, y, 25, 20); + this.increment = increment; + getStyle().setIcon(sprite); + onClick(sender -> { + SpellbookPage.swap(increment); + init(client, SpellbookScreen.this.width, SpellbookScreen.this.height); + }); + } + + @Override + public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { + + setEnabled(increment < 0 ? !SpellbookPage.getCurrent().isFirst() : !SpellbookPage.getCurrent().isLast()); + + if (!active) { + return; + } + + int state = hovered ? 1 : 0; + + sprite.setTextureOffset(23 * state, (int)(479 + 6.5F - (increment * 6.5F))); + super.renderButton(matrices, mouseX, mouseY, partialTicks); + } + } + + class TraitButton extends ImageButton { + private final Trait trait; + + public TraitButton(int x, int y, Trait trait) { + super(x, y, 16, 16); + this.trait = trait; + getStyle().setIcon(new TextureSprite() + .setTextureSize(16, 16) + .setSize(16, 16) + .setTexture(trait.getSprite())); + getStyle().setTooltip(List.of( + new TranslatableText("trait." + trait.getId().getNamespace() + "." + trait.getId().getPath() + ".name"), + new TranslatableText("trait." + trait.getId().getNamespace() + "." + trait.getId().getPath() + ".description") + )); + getStyle().setTooltip(List.of( + new LiteralText(trait.name()), + new LiteralText("Test description") + )); + } + + @Override + public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { + TraitDiscovery discoveries = Pony.of(client.player).getDiscoveries(); + setEnabled(discoveries.isKnown(trait)); + + RenderSystem.setShaderColor(1, 1, 1, 1); + RenderSystem.setShaderTexture(0, TEXTURE); + RenderSystem.enableBlend(); + drawTexture(matrices, x - 2, y - 8, 204, 219, 22, 32, 512, 256); + drawTexture(matrices, x - 2, y - 1, 74, 223, 18, 18, 512, 256); + + super.renderButton(matrices, mouseX, mouseY, partialTicks); + hovered &= active; + } + + @Override + public Button setEnabled(boolean enable) { + alpha = enable ? 1 : 0.1125F; + return super.setEnabled(enable); + } + } + + class ImageButton extends Button { + + public ImageButton(int x, int y) { + super(x, y); + } + + public ImageButton(int x, int y, int width, int height) { + super(x, y, width, height); + } + + @Override + public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { + RenderSystem.setShader(GameRenderer::getPositionTexShader); + + RenderSystem.setShaderColor(1, 1, 1, alpha); + RenderSystem.defaultBlendFunc(); + RenderSystem.blendFunc( + GlStateManager.SrcFactor.SRC_ALPHA, + GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); + + if (getStyle().hasIcon()) { + getStyle().getIcon().render(matrices, x, y, mouseX, mouseY, partialTicks); + } + + RenderSystem.setShaderColor(1, 1, 1, 1); + } } } diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreenHandler.java b/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreenHandler.java index 6cebda98..d946ecd4 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreenHandler.java +++ b/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreenHandler.java @@ -10,7 +10,11 @@ import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.URecipes; import com.minelittlepony.unicopia.util.InventoryUtil; +import com.mojang.datafixers.util.Pair; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.CraftingInventory; @@ -18,6 +22,7 @@ import net.minecraft.inventory.CraftingResultInventory; import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket; +import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandlerContext; import net.minecraft.screen.slot.CraftingResultSlot; @@ -25,10 +30,18 @@ import net.minecraft.screen.slot.Slot; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; +import net.minecraft.util.Identifier; import net.minecraft.util.collection.DefaultedList; public class SpellbookScreenHandler extends ScreenHandler { + private static final Identifier[] EMPTY_ARMOR_SLOT_TEXTURES = new Identifier[]{ + PlayerScreenHandler.EMPTY_BOOTS_SLOT_TEXTURE, + PlayerScreenHandler.EMPTY_LEGGINGS_SLOT_TEXTURE, + PlayerScreenHandler.EMPTY_CHESTPLATE_SLOT_TEXTURE, + PlayerScreenHandler.EMPTY_HELMET_SLOT_TEXTURE + }; + private final int MAX_INGREDIENTS; private final int GEM_SLOT_INDEX; @@ -73,6 +86,47 @@ public class SpellbookScreenHandler extends ScreenHandler { for (int i = 0; i < 9; ++i) { addSlot(new Slot(inventory, i, 121 + i * 18, 195)); } + for (int i = 0; i < PlayerInventory.MAIN_SIZE - 9; ++i) { + int x = i % 5; + int y = i / 5; + addSlot(new InventorySlot(inventory, i + 9, 225 + x * 20, 50 + y * 20)); + } + + for (int i = 0; i < 4; i++) { + final EquipmentSlot eq = EquipmentSlot.values()[5 - i]; + addSlot(new InventorySlot(inventory, PlayerInventory.OFF_HAND_SLOT - i - 1, 340, 50 + (i * 20)) { + @Override + public int getMaxItemCount() { + return 1; + } + + @Override + public boolean canInsert(ItemStack stack) { + return eq == MobEntity.getPreferredEquipmentSlot(stack); + } + + @Override + public boolean canTakeItems(PlayerEntity playerEntity) { + ItemStack stack = getStack(); + if (!stack.isEmpty() && !playerEntity.isCreative() && EnchantmentHelper.hasBindingCurse(stack)) { + return false; + } + return super.canTakeItems(playerEntity); + } + + @Override + public Pair getBackgroundSprite() { + return Pair.of(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, EMPTY_ARMOR_SLOT_TEXTURES[eq.getEntitySlotId()]); + } + }); + } + + addSlot(new InventorySlot(inventory, PlayerInventory.OFF_HAND_SLOT, 340, 150) { + @Override + public Pair getBackgroundSprite() { + return Pair.of(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_OFFHAND_ARMOR_SLOT); + } + }); onContentChanged(input); } @@ -126,6 +180,18 @@ public class SpellbookScreenHandler extends ScreenHandler { onContentChanged(input); return ItemStack.EMPTY; } + + if (insertItem(transferredStack, HOTBAR_END + 27, HOTBAR_END + 27 + 4, false)) { + sourceSlot.onQuickTransfer(transferredStack, stack); + onContentChanged(input); + return ItemStack.EMPTY; + } + + if (insertItem(transferredStack, HOTBAR_END, HOTBAR_END + 27, false)) { + sourceSlot.onQuickTransfer(transferredStack, stack); + onContentChanged(input); + return ItemStack.EMPTY; + } } if (transferredStack.getCount() == stack.getCount()) { @@ -279,6 +345,22 @@ public class SpellbookScreenHandler extends ScreenHandler { } } + public class InventorySlot extends Slot implements SpellbookSlot { + public InventorySlot(Inventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } + + @Override + public int getRing() { + return 0; + } + + @Override + public boolean isEnabled() { + return SpellbookPage.getCurrent() == SpellbookPage.INVENTORY; + } + } + public class InputSlot extends Slot implements SpellbookSlot { private final int ring; diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index a52350f4..cb698195 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -257,6 +257,10 @@ "gui.unicopia.tribe_selection.confirm.bads.2.changeling": " - Require love, collected from ponies or other hostile mobs to subsidise their diet", "gui.unicopia.tribe_selection.confirm.bads.3.changeling": " - Becomes sick from eating regular food and must eat love hasten a cure", + "gui.unicopia.spellbook.page.inventory": "Inventory", + "gui.unicopia.spellbook.page.discoveries": "Discoveries", + "gui.unicopia.spellbook.page.recipes": "Recipes", + "unicopia.category.name": "Pony Abilities", "key.unicopia.primary": "Primary Ability", diff --git a/src/main/resources/assets/unicopia/textures/gui/container/book.png b/src/main/resources/assets/unicopia/textures/gui/container/book.png index 301777bf..f8a73d99 100644 Binary files a/src/main/resources/assets/unicopia/textures/gui/container/book.png and b/src/main/resources/assets/unicopia/textures/gui/container/book.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/container/slot.png b/src/main/resources/assets/unicopia/textures/gui/container/slot.png new file mode 100644 index 00000000..c08b7ec0 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/gui/container/slot.png differ diff --git a/src/main/resources/data/unicopia/recipes/spellbook/burned_juice.json b/src/main/resources/data/unicopia/recipes/spellbook/burned_juice.json new file mode 100644 index 00000000..b8ccca13 --- /dev/null +++ b/src/main/resources/data/unicopia/recipes/spellbook/burned_juice.json @@ -0,0 +1,14 @@ +{ + "type": "unicopia:spellbook/crafting", + "material": { + "item": { + "item": "unicopia:gemstone" + } + }, + "traits": { + "pestilence": 1 + }, + "result": { + "item": "unicopia:burned_juice" + } +} \ No newline at end of file