Skip to content

Commit

Permalink
Fix enchanting guide dropping items (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Dec 16, 2023
1 parent 41c44ba commit ab917ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.EnchantmentHelper;

import java.util.List;

public class EnchantingGuideMenu extends GhostItemMenu<ItemStack> {
private static final Component NO_ENCHANTMENT = LANG.translate("gui.enchanting_guide.no_enchantment").component();
private ImmutableList<Component> previousEnchantments;
Expand All @@ -35,6 +37,8 @@ public class EnchantingGuideMenu extends GhostItemMenu<ItemStack> {
@Nullable
BlockPos blockPos = null;

private static final List<Integer> listOfBrokenSlots = List.of(8, 17, 26, 35);

public EnchantingGuideMenu(MenuType<?> type, int id, Inventory inv, FriendlyByteBuf extraData) {
super(type, id, inv, extraData);
directItemStackEdit = extraData.readBoolean();
Expand Down Expand Up @@ -139,6 +143,10 @@ public void setChanged() {

@Override
public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
if (listOfBrokenSlots.contains(slotId) && clickTypeIn == ClickType.THROW) {
clickTypeIn = ClickType.PICKUP;
}

if (slotId < 36) {
super.clicked(slotId, dragType, clickTypeIn, player);
return;
Expand All @@ -160,6 +168,7 @@ public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player play
}

@Override
@SuppressWarnings("UnstableApiUsage")
public ItemStack quickMoveStack(Player playerIn, int index) {
if (index < 36) {
ItemStack stackToInsert = playerInventory.getItem(index);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package plus.dragons.createenchantmentindustry.content.contraptions.enchanting.enchanter;

import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.gui.menu.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.widget.Label;
Expand All @@ -12,7 +11,6 @@
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory;
import plus.dragons.createdragonlib.gui.ComponentLabel;
import plus.dragons.createenchantmentindustry.entry.CeiPackets;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -63,7 +61,7 @@ protected void init() {
);
index = menu.contentHolder.getOrCreateTag().getInt("index");
scrollInput = new SelectionScrollInput(guideX + 40, guideY + 22, 120, 16);
scrollInputLabel = new ComponentLabel(guideX + 43, guideY + 26, Components.immutableEmpty()).withShadow();
scrollInputLabel = new Label(guideX + 43, guideY + 26, Components.immutableEmpty()).withShadow();
scrollInput.calling(index -> this.index = index).writingTo(scrollInputLabel);
addRenderableWidget(scrollInputLabel);
addRenderableWidget(scrollInput);
Expand Down

0 comments on commit ab917ad

Please sign in to comment.