Skip to content

Commit

Permalink
Implemented book lectern support
Browse files Browse the repository at this point in the history
  • Loading branch information
fuj1n committed Jun 26, 2021
1 parent 2feae15 commit d0c0ee7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"tmechworks:book"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,36 @@
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import slimeknights.mantle.client.book.BookLoader;
import slimeknights.mantle.client.book.data.BookData;
import slimeknights.mantle.client.book.repository.FileRepository;
import slimeknights.mantle.item.LecternBookItem;
import slimeknights.tmechworks.client.ClientProxy;
import slimeknights.tmechworks.common.MechworksContent;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

public class MechworksBookItem extends MechworksItem {
public class MechworksBookItem extends LecternBookItem {
public MechworksBookItem() {
super(new Item.Properties().maxStackSize(1));
super(new Item.Properties().group(MechworksContent.tabMechworks).maxStackSize(1));
}

@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
ItemStack stack = playerIn.getHeldItem(handIn);
@Nonnull
@ParametersAreNonnullByDefault
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand hand) {
ItemStack stack = playerIn.getHeldItem(hand);

if(worldIn.isRemote){
ClientProxy.book.openGui(new TranslationTextComponent("item.tmechworks.book"), stack);
ClientProxy.book.openGui(hand, stack);
}

return new ActionResult<>(ActionResultType.SUCCESS, stack);
}

@Override
@ParametersAreNonnullByDefault
public void openLecternScreenClient(BlockPos pos, ItemStack stack) {
ClientProxy.book.openGui(pos, stack);
}
}
2 changes: 2 additions & 0 deletions src/main/java/slimeknights/tmechworks/data/ItemTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ protected void registerTags() {

addNugget(MechworksTags.Items.NUGGETS_ALUMINUM, MechworksContent.Items.aluminum_nugget.get());
addNugget(MechworksTags.Items.NUGGETS_COPPER, MechworksContent.Items.copper_nugget.get());

getOrCreateBuilder(net.minecraft.tags.ItemTags.LECTERN_BOOKS).add(MechworksContent.Items.book.get());
}

private void addIngot(ITag.INamedTag<Item> tag, Item... item) {
Expand Down

0 comments on commit d0c0ee7

Please sign in to comment.