mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
Fix ContainerRepair patch to prevent NPE (#3553)
This commit is contained in:
1 parent
d72888b6ab
commit
a718077a2e
2 files changed
+67
-7
No files matched your search
@@ -0,0 +1,61 @@
|
||||
package net.minecraftforge.test;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Mod(modid = IsBookEnchantableTest.MOD_ID, name = "Test for isBookEnchantable", version = "1.0")
|
||||
@Mod.EventBusSubscriber
|
||||
public class IsBookEnchantableTest
|
||||
{
|
||||
static final String MOD_ID = "is_book_enchantable_test";
|
||||
|
||||
private static final Item TEST_ITEM = new TestItem();
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItem(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().register(TEST_ITEM);
|
||||
}
|
||||
|
||||
private static class TestItem extends Item
|
||||
{
|
||||
private static final String NAME = "test_item";
|
||||
|
||||
private TestItem()
|
||||
{
|
||||
maxStackSize = 1;
|
||||
setUnlocalizedName(MOD_ID + "." + NAME);
|
||||
setRegistryName(NAME);
|
||||
setCreativeTab(CreativeTabs.MISC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnchantable(ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookEnchantable(ItemStack stack, ItemStack book)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user