mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
Remove dead test classes.
This commit is contained in:
1 parent
f24991f3bb
commit
0c0603dc91
133 files changed
-15903
No files matched your search
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.BonemealEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
//@Mod(modid = BonemealEventTest.MODID, name = "Bonemeal Event Test", version = "1.0", acceptableRemoteVersions = "*")
|
||||
public class BonemealEventTest
|
||||
{
|
||||
public static final String MODID = "bonemealeventtest";
|
||||
|
||||
private static final boolean ENABLED = false;
|
||||
private static Logger logger;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
logger = event.getModLog();
|
||||
|
||||
if (ENABLED)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(BonemealEventTest.class);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onBonemeal(BonemealEvent event)
|
||||
{
|
||||
if (event.getHand() == EnumHand.MAIN_HAND)
|
||||
{
|
||||
// If the bone meal is being used from the main hand, set the result to ALLOW to use up the bone meal without growing the crop
|
||||
event.setResult(net.minecraftforge.eventbus.api.Event.Result.ALLOW);
|
||||
logger.info("Prevented bone meal growth effect from main hand");
|
||||
}
|
||||
else if (event.getHand() == EnumHand.OFF_HAND)
|
||||
{
|
||||
// If the bone meal is being used from the off hand, cancel the event to prevent it being used at all
|
||||
event.setCanceled(true);
|
||||
logger.info("Prevented bone meal use from off hand");
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the bone meal is being used from a dispenser or something similar, allow it
|
||||
logger.info("Allowed bone meal use from dispenser");
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.init.Enchantments;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
//@Mod(modid = CanApplyAtEnchantingTableTest.MODID, name = "CanApplyAtEnchantingTableTest", version = "0.0.0", acceptableRemoteVersions = "*")
|
||||
public class CanApplyAtEnchantingTableTest
|
||||
{
|
||||
public static final String MODID = "can_apply_at_enchanting_table_test";
|
||||
public static final boolean ENABLE = false;
|
||||
|
||||
public static final Item testItem = new Item()
|
||||
{
|
||||
@Override
|
||||
public boolean isEnchantable(ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment)
|
||||
{
|
||||
return super.canApplyAtEnchantingTable(stack, enchantment) || enchantment == Enchantments.FORTUNE;
|
||||
}
|
||||
};
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MODID)
|
||||
public static class Registration
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
if (ENABLE)
|
||||
{
|
||||
event.getRegistry().register(
|
||||
testItem.setRegistryName("test_item")
|
||||
.setUnlocalizedName("FortuneEnchantableOnly")
|
||||
.setMaxStackSize(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
|
||||
public static class ClientEventHandler
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
if (ENABLE)
|
||||
{
|
||||
ModelBakery.registerItemVariants(testItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
//@Mod(modid = CanDestroyBlocksInCreativeTest.MODID, name = "Item.canDestroyBlockInCreative() Test", version = "1.0", acceptableRemoteVersions = "*")
|
||||
public class CanDestroyBlocksInCreativeTest
|
||||
{
|
||||
public static final boolean ENABLE = true;
|
||||
public static final String MODID = "item_can_destroy_blocks_in_creative_test";
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MODID)
|
||||
public static class Registration
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
if (!ENABLE)
|
||||
return;
|
||||
|
||||
Item test = new Item()
|
||||
{
|
||||
@Override
|
||||
public boolean canDestroyBlockInCreative(World world, BlockPos pos, ItemStack stack, EntityPlayer player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}.setRegistryName(MODID, "item_test")
|
||||
.setUnlocalizedName(MODID + ".item_test")
|
||||
.setCreativeTab(CreativeTabs.TOOLS);
|
||||
|
||||
event.getRegistry().register(test);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
//@Mod(modid = ContinuousUseItemTest.MOD_ID, name = "Test for canContinueUsing", version = "1.0", acceptableRemoteVersions = "*")
|
||||
//@Mod.EventBusSubscriber
|
||||
public class ContinuousUseItemTest
|
||||
{
|
||||
static final String MOD_ID = "continuous_use_item_test";
|
||||
static final boolean ENABLED = false;
|
||||
|
||||
@GameRegistry.ObjectHolder(TestItem.NAME)
|
||||
public static final Item TEST_ITEM = null;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItem(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
if (ENABLED)
|
||||
{
|
||||
event.getRegistry().register(
|
||||
new TestItem().setRegistryName(MOD_ID, TestItem.NAME)
|
||||
.setUnlocalizedName(MOD_ID + "." + TestItem.NAME)
|
||||
.setCreativeTab(CreativeTabs.MISC)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MOD_ID)
|
||||
public static class ClientEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
if (ENABLED)
|
||||
{
|
||||
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation("minecraft:stick", "inventory"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class TestItem extends Item
|
||||
{
|
||||
static final String NAME = "test_item";
|
||||
|
||||
TestItem()
|
||||
{
|
||||
maxStackSize = 1;
|
||||
setMaxDamage(60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
return EnumAction.BOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack stack)
|
||||
{
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
|
||||
{
|
||||
playerIn.setActiveHand(handIn);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, EntityLivingBase living, int count)
|
||||
{
|
||||
if (count % 10 == 0)
|
||||
{
|
||||
stack.damageItem(1, living);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
return slotChanged || oldStack.getItem() != newStack.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canContinueUsing(ItemStack oldStack, ItemStack newStack)
|
||||
{
|
||||
return oldStack.getItem() == newStack.getItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.passive.HorseArmorType;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
|
||||
//@EventBusSubscriber
|
||||
//@Mod(modid = HorseArmorTest.MODID, name = "HorseArmorTest", version = "1.0", acceptableRemoteVersions = "*")
|
||||
public class HorseArmorTest
|
||||
{
|
||||
public static final String MODID = "horse_armor_test";
|
||||
public static final boolean ENABLED = true;
|
||||
|
||||
public static HorseArmorType testArmorType;
|
||||
@ObjectHolder("test_armor")
|
||||
public static final ItemTestHorseArmor TEST_ARMOR = null;
|
||||
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
if(ENABLED)
|
||||
testArmorType = EnumHelper.addHorseArmor("test", MODID + ":textures/entity/horse/armor/test.png", 15);
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
if(ENABLED)
|
||||
event.getRegistry().register(new ItemTestHorseArmor().setRegistryName(MODID, "test_armor").setUnlocalizedName(MODID + ".testArmor"));
|
||||
}
|
||||
|
||||
//@EventBusSubscriber(modid = MODID, value = Side.CLIENT)
|
||||
public static class ClientEventHandler
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
if(ENABLED)
|
||||
ModelLoader.setCustomModelResourceLocation(TEST_ARMOR, 0, new ModelResourceLocation(TEST_ARMOR.getRegistryName(), "inventory"));
|
||||
}
|
||||
}
|
||||
|
||||
private static class ItemTestHorseArmor extends Item
|
||||
{
|
||||
@Override
|
||||
public HorseArmorType getHorseArmorType(ItemStack stack)
|
||||
{
|
||||
return testArmorType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHorseArmorTexture(EntityLiving wearer, ItemStack stack)
|
||||
{
|
||||
return stack.isItemEnchanted() ? HorseArmorType.IRON.getTextureName() : super.getHorseArmorTexture(wearer, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHorseArmorTick(World world, EntityLiving wearer, ItemStack itemStack)
|
||||
{
|
||||
if(wearer.ticksExisted % 15 == 0)
|
||||
wearer.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 20, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
//@Mod(modid = IsBookEnchantableTest.MOD_ID, name = "Test for isBookEnchantable", version = "1.0", acceptableRemoteVersions = "*")
|
||||
//@Mod.EventBusSubscriber
|
||||
public class IsBookEnchantableTest
|
||||
{
|
||||
public static final boolean ENABLED = false;
|
||||
static final String MOD_ID = "is_book_enchantable_test";
|
||||
|
||||
private static final Item TEST_ITEM = new TestItem();
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerItem(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
if (ENABLED)
|
||||
{
|
||||
event.getRegistry().register(TEST_ITEM);
|
||||
}
|
||||
}
|
||||
|
||||
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MOD_ID)
|
||||
public static class ClientEventHandler
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
if (ENABLED)
|
||||
{
|
||||
ModelBakery.registerItemVariants(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.entity.projectile.EntityFishHook;
|
||||
import net.minecraft.init.Biomes;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.ItemFishedEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
//@Mod(modid = "itemfishtest", name = "ItemFishTest", version = "1.0.0", acceptableRemoteVersions = "*")
|
||||
public class ItemFishedEventTest
|
||||
{
|
||||
|
||||
private static final boolean ENABLE = false;
|
||||
private static Logger logger;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
if (ENABLE)
|
||||
{
|
||||
logger = event.getModLog();
|
||||
logger.info("Enabling Fishing Test mod");
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public void onItemFished(ItemFishedEvent event)
|
||||
{
|
||||
EntityFishHook hook = event.getHookEntity();
|
||||
BlockPos bobberPos = hook.getPosition();
|
||||
Biome biomeFishedAt = hook.getEntityWorld().getBiome(bobberPos);
|
||||
logger.info("Item fished in Biome {}", biomeFishedAt.getBiomeName());
|
||||
if (biomeFishedAt.equals(Biomes.OCEAN))
|
||||
{
|
||||
logger.info("Canceling the event because biome is ocean");
|
||||
event.setCanceled(true);
|
||||
}
|
||||
event.damageRodBy(50);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.MapItemRenderer;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemMap;
|
||||
import net.minecraft.item.ItemMapBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.SPacketMaps;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.MapData;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
//@Mod(modid = "mapdatatest", name = "mapdatatest", version = "1.0", acceptableRemoteVersions = "*")
|
||||
public class MapDataTest
|
||||
{
|
||||
@GameRegistry.ObjectHolder("mapdatatest:custom_map")
|
||||
public static final Item CUSTOM_MAP = null;
|
||||
|
||||
@GameRegistry.ObjectHolder("mapdatatest:empty_custom_map")
|
||||
public static final Item EMPTY_CUSTOM_MAP = null;
|
||||
|
||||
private static SimpleNetworkWrapper packetHandler;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent evt)
|
||||
{
|
||||
packetHandler = new SimpleNetworkWrapper("mapdatatest");
|
||||
packetHandler.registerMessage(CustomMapPacketHandler.class, CustomMapPacket.class, 0, Side.CLIENT);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerModels(ModelRegistryEvent evt)
|
||||
{
|
||||
ModelLoader.setCustomModelResourceLocation(EMPTY_CUSTOM_MAP, 0, new ModelResourceLocation("map", "inventory"));
|
||||
ModelLoader.setCustomMeshDefinition(CUSTOM_MAP, s -> new ModelResourceLocation("filled_map", "inventory"));
|
||||
ModelBakery.registerItemVariants(CUSTOM_MAP, new ModelResourceLocation("filled_map", "inventory"));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerItems(RegistryEvent.Register<Item> evt)
|
||||
{
|
||||
evt.getRegistry().register(new EmptyCustomMap().setUnlocalizedName("emptyCustomMap").setRegistryName("mapdatatest", "empty_custom_map"));
|
||||
evt.getRegistry().register(new CustomMap().setUnlocalizedName("customMap").setRegistryName("mapdatatest", "custom_map"));
|
||||
}
|
||||
|
||||
public static class EmptyCustomMap extends ItemMapBase
|
||||
{
|
||||
// copy of super, setting up our own map
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
|
||||
{
|
||||
ItemStack itemstack = CustomMap.setupNewMap(worldIn, playerIn.posX, playerIn.posZ, (byte) 0, true, false);
|
||||
ItemStack itemstack1 = playerIn.getHeldItem(handIn);
|
||||
itemstack1.shrink(1);
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, itemstack);
|
||||
} else
|
||||
{
|
||||
if (!playerIn.inventory.addItemStackToInventory(itemstack.copy()))
|
||||
{
|
||||
playerIn.dropItem(itemstack, false);
|
||||
}
|
||||
|
||||
playerIn.addStat(StatList.getObjectUseStats(this));
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, itemstack1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomMap extends ItemMap
|
||||
{
|
||||
private static final String PREFIX = "custommap";
|
||||
|
||||
// copy of super with own map prefix
|
||||
public static ItemStack setupNewMap(World worldIn, double worldX, double worldZ, byte scale, boolean trackingPosition, boolean unlimitedTracking)
|
||||
{
|
||||
ItemStack itemstack = new ItemStack(CUSTOM_MAP, 1, worldIn.getUniqueDataId(PREFIX));
|
||||
String s = PREFIX + "_" + itemstack.getMetadata();
|
||||
MapData mapdata = new CustomMapData(s);
|
||||
worldIn.setData(s, mapdata);
|
||||
mapdata.scale = scale;
|
||||
mapdata.calculateMapCenter(worldX, worldZ, mapdata.scale);
|
||||
mapdata.dimension = worldIn.provider.getDimension();
|
||||
mapdata.trackingPosition = trackingPosition;
|
||||
mapdata.unlimitedTracking = unlimitedTracking;
|
||||
mapdata.markDirty();
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
// copy of super with own map prefix and type
|
||||
@Nullable
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static CustomMapData loadMapData(int mapId, World worldIn)
|
||||
{
|
||||
String s = PREFIX + "_" + mapId;
|
||||
return (CustomMapData) worldIn.loadData(CustomMapData.class, s);
|
||||
}
|
||||
|
||||
// copy of super with own map prefix and type
|
||||
@Nullable
|
||||
@Override
|
||||
public CustomMapData getMapData(ItemStack stack, World worldIn)
|
||||
{
|
||||
String s = PREFIX + "_" + stack.getMetadata();
|
||||
CustomMapData mapdata = (CustomMapData) worldIn.loadData(CustomMapData.class, s);
|
||||
|
||||
if (mapdata == null && !worldIn.isRemote)
|
||||
{
|
||||
stack.setItemDamage(worldIn.getUniqueDataId(PREFIX));
|
||||
s = PREFIX + "_" + stack.getMetadata();
|
||||
mapdata = new CustomMapData(s);
|
||||
mapdata.scale = 3;
|
||||
mapdata.calculateMapCenter((double) worldIn.getWorldInfo().getSpawnX(), (double) worldIn.getWorldInfo().getSpawnZ(), mapdata.scale);
|
||||
mapdata.dimension = worldIn.provider.getDimension();
|
||||
mapdata.markDirty();
|
||||
worldIn.setData(s, mapdata);
|
||||
}
|
||||
|
||||
return mapdata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMapData(World worldIn, Entity viewer, MapData data)
|
||||
{
|
||||
// Solid red
|
||||
Arrays.fill(data.colors, (byte) (MapColor.RED.colorIndex * 4 + 1));
|
||||
}
|
||||
|
||||
// rewrap vanilla packet with own, to sync CustomMapData's extra data
|
||||
@Override
|
||||
public Packet<?> createMapDataPacket(ItemStack stack, World worldIn, EntityPlayer player)
|
||||
{
|
||||
SPacketMaps vanillaPacket = (SPacketMaps) super.createMapDataPacket(stack, worldIn, player);
|
||||
if (vanillaPacket == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return packetHandler.getPacketFrom(new CustomMapPacket(vanillaPacket));
|
||||
}
|
||||
}
|
||||
|
||||
// A custom subclass to distinguish from vanilla's type in the WorldSavedData
|
||||
public static class CustomMapData extends MapData
|
||||
{
|
||||
public CustomMapData(String mapname)
|
||||
{
|
||||
super(mapname);
|
||||
}
|
||||
}
|
||||
|
||||
// Custom map packet wrapping vanilla's because the handler needs to use our custom type
|
||||
public static class CustomMapPacket implements IMessage
|
||||
{
|
||||
public SPacketMaps vanillaPacket;
|
||||
|
||||
public CustomMapPacket() {}
|
||||
|
||||
public CustomMapPacket(SPacketMaps vanillaPacket)
|
||||
{
|
||||
this.vanillaPacket = vanillaPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
vanillaPacket = new SPacketMaps();
|
||||
try {
|
||||
vanillaPacket.readPacketData(new PacketBuffer(buf));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
try {
|
||||
vanillaPacket.writePacketData(new PacketBuffer(buf));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomMapPacketHandler implements IMessageHandler<CustomMapPacket, IMessage>
|
||||
{
|
||||
@Nullable
|
||||
@Override
|
||||
public IMessage onMessage(CustomMapPacket message, NetworkEvent.Context ctx)
|
||||
{
|
||||
// Like NetHandlerPlayClient.handleMaps but using our custom type
|
||||
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
MapItemRenderer mapitemrenderer = Minecraft.getMinecraft().entityRenderer.getMapItemRenderer();
|
||||
MapData mapdata = CustomMap.loadMapData(message.vanillaPacket.getMapId(), Minecraft.getMinecraft().world);
|
||||
|
||||
if (mapdata == null) {
|
||||
String s = CustomMap.PREFIX + "_" + message.vanillaPacket.getMapId();
|
||||
mapdata = new CustomMapData(s);
|
||||
|
||||
if (mapitemrenderer.getMapInstanceIfExists(s) != null) {
|
||||
MapData mapdata1 = mapitemrenderer.getData(mapitemrenderer.getMapInstanceIfExists(s));
|
||||
|
||||
if (mapdata1 != null) {
|
||||
mapdata = mapdata1;
|
||||
}
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().world.setData(s, mapdata);
|
||||
}
|
||||
|
||||
message.vanillaPacket.setMapdataTo(mapdata);
|
||||
mapitemrenderer.updateMapTexture(mapdata);
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Enchantments;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
//@Mod.EventBusSubscriber
|
||||
//@Mod(modid = MendingRepairTest.MOD_ID, name = "Mending repair amount test mod", version = "1.0")
|
||||
public class MendingRepairTest
|
||||
{
|
||||
static final boolean ENABLED = true;
|
||||
static final String MOD_ID = "mending_repair_test";
|
||||
|
||||
@GameRegistry.ObjectHolder(MOD_ID + ":test_item")
|
||||
public static final Item TEST_ITEM = null;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
if (!ENABLED) return;
|
||||
event.getRegistry().register(
|
||||
new TestItem()
|
||||
.setRegistryName(MOD_ID, "test_item")
|
||||
.setUnlocalizedName(MOD_ID + ".test_item")
|
||||
);
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MOD_ID, value = Side.CLIENT)
|
||||
public static final class ClientEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
if (!ENABLED) return;
|
||||
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation("minecraft:blaze_rod", "inventory"));
|
||||
}
|
||||
}
|
||||
|
||||
private static final class TestItem extends Item
|
||||
{
|
||||
TestItem()
|
||||
{
|
||||
maxStackSize = 1;
|
||||
setMaxDamage(10);
|
||||
setCreativeTab(CreativeTabs.TOOLS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items)
|
||||
{
|
||||
if (this.isInCreativeTab(tab))
|
||||
{
|
||||
ItemStack stack = new ItemStack(this);
|
||||
stack.addEnchantment(Enchantments.MENDING, 1);
|
||||
stack.setItemDamage(stack.getMaxDamage());
|
||||
items.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getXpRepairRatio(ItemStack stack)
|
||||
{
|
||||
return 0.1f;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
//@Mod(modid = NBTShareTagTest.MODID, name = "NBTShareTag Item Test", version = "1.0.0", acceptableRemoteVersions = "*")
|
||||
public class NBTShareTagTest
|
||||
{
|
||||
public static final String MODID = "nbtsharetagitemtest";
|
||||
private static final ResourceLocation itemName = new ResourceLocation(MODID, "nbt_share_tag_item");
|
||||
@ObjectHolder("nbt_share_tag_item")
|
||||
public static final Item TEST_ITEM = null;
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MODID)
|
||||
public static class Registration
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerRecipes(RegistryEvent.Register<IRecipe> event)
|
||||
{
|
||||
ItemStack crafted = new ItemStack(TEST_ITEM);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setBoolean("crafted", true);
|
||||
crafted.setTagCompound(nbt);
|
||||
|
||||
GameRegistry.addShapelessRecipe(new ResourceLocation(MODID, "nbt_share"), null, crafted, Ingredient.fromItem(Items.STICK));
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().register(new ShareTagItem().setRegistryName(itemName));
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(itemName, "inventory"));
|
||||
}
|
||||
}
|
||||
|
||||
public static class ShareTagItem extends Item
|
||||
{
|
||||
public ShareTagItem()
|
||||
{
|
||||
setCreativeTab(CreativeTabs.MISC);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public NBTTagCompound getNBTShareTag(ItemStack stack)
|
||||
{
|
||||
NBTTagCompound networkNBT = stack.getTagCompound();
|
||||
if (networkNBT == null)
|
||||
networkNBT = new NBTTagCompound();
|
||||
networkNBT.setBoolean("nbtShareTag", true);
|
||||
return networkNBT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems)
|
||||
{
|
||||
if (!this.isInCreativeTab(tab))
|
||||
return;
|
||||
ItemStack creativeMenuItem = new ItemStack(this);
|
||||
NBTTagCompound creativeMenuNBT = new NBTTagCompound();
|
||||
creativeMenuNBT.setBoolean("creativeMenu", true);
|
||||
creativeMenuItem.setTagCompound(creativeMenuNBT);
|
||||
subItems.add(creativeMenuItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack)
|
||||
{
|
||||
NBTTagCompound tagCompound = stack.getTagCompound();
|
||||
String name = "NBTShareTagItem: ";
|
||||
if (tagCompound == null)
|
||||
{
|
||||
name += "From /give. ";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tagCompound.getBoolean("nbtShareTag"))
|
||||
name += "Sent from server. ";
|
||||
|
||||
if (tagCompound.getBoolean("creativeMenu"))
|
||||
name += "From creative menu. ";
|
||||
|
||||
if (tagCompound.getBoolean("crafted"))
|
||||
name += "From crafting. ";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
//@Mod(modid = OnItemUseFirstTest.MODID, name = "OnItemUseFirstTest", version = "0.0.0", acceptableRemoteVersions = "*")
|
||||
//@Mod.EventBusSubscriber
|
||||
public class OnItemUseFirstTest
|
||||
{
|
||||
public static final boolean ENABLE = true;
|
||||
public static final String MODID = "onitemusefirsttest";
|
||||
public static CommonProxy proxy = null;
|
||||
|
||||
public static abstract class CommonProxy
|
||||
{
|
||||
public void registerItem(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
ItemTest.instance = new ItemTest().setCreativeTab(CreativeTabs.MISC);
|
||||
event.getRegistry().register(ItemTest.instance);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class ServerProxy extends CommonProxy
|
||||
{
|
||||
}
|
||||
|
||||
public static final class ClientProxy extends CommonProxy
|
||||
{
|
||||
@Override
|
||||
public void registerItem(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
super.registerItem(event);
|
||||
for (int i = 0; i < EnumActionResult.values().length; i++)
|
||||
{
|
||||
ModelLoader.setCustomModelResourceLocation(ItemTest.instance, i, new ModelResourceLocation(new ResourceLocation(MODID, "test_item"), "inventory"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItem(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
if (ENABLE)
|
||||
{
|
||||
proxy.registerItem(event);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemTest extends Item
|
||||
{
|
||||
static Item instance;
|
||||
public ItemTest()
|
||||
{
|
||||
setRegistryName(MODID, "test_item");
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
EnumActionResult ret = EnumActionResult.values()[stack.getMetadata()];
|
||||
player.sendMessage(new TextComponentString("Called onItemUseFirst in thread " + Thread.currentThread().getName() + ", returns " + ret + " in hand " + hand.name()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems)
|
||||
{
|
||||
if (isInCreativeTab(tab))
|
||||
{
|
||||
for (int i = 0; i < EnumActionResult.values().length; i++)
|
||||
{
|
||||
subItems.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack)
|
||||
{
|
||||
return "OnItemUseFirst Returns: " + EnumActionResult.values()[stack.getMetadata()];
|
||||
}
|
||||
}
|
||||
}*/
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.potion.PotionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
*/
|
||||
/**
|
||||
* Usage (use survival so you can eat food):
|
||||
* 1. Drink curable_potion from Brewing creative tab
|
||||
* 2. Relog to test that changes to curative items persist, then eat the "medicine" item to cure the effect
|
||||
* 3. Drink incurable_potion from Brewing creative tab
|
||||
* 4. Relog to test that changes to curative items persist, then try drinking milk and eating medicine: they should have no effect
|
||||
*//*
|
||||
|
||||
//@Mod(modid = PotionCurabilityTest.MODID, name = "Potion Curative Item Debug", version = "1.0", acceptableRemoteVersions = "*")
|
||||
public class PotionCurabilityTest
|
||||
{
|
||||
public static final boolean ENABLED = false;
|
||||
public static final String MODID = "potion_curative_item_debug";
|
||||
|
||||
@ObjectHolder("medicine")
|
||||
public static final Item MEDICINE = null;
|
||||
private static Potion INCURABLE_POTION;
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MODID)
|
||||
public static class Registration
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
if (!ENABLED) return;
|
||||
event.getRegistry().register(new Medicine().setRegistryName(MODID, "medicine"));
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerPotions(RegistryEvent.Register<Potion> event)
|
||||
{
|
||||
if (!ENABLED) return;
|
||||
INCURABLE_POTION = new IncurablePotion().setRegistryName(MODID, "incurable_potion");
|
||||
event.getRegistry().register(INCURABLE_POTION);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerPotionTypes(RegistryEvent.Register<PotionType> event)
|
||||
{
|
||||
if (!ENABLED) return;
|
||||
// Register PotionType that can be cured with medicine
|
||||
PotionEffect curable = new PotionEffect(INCURABLE_POTION, 1200);
|
||||
curable.setCurativeItems(Collections.singletonList(new ItemStack(MEDICINE)));
|
||||
event.getRegistry().register(new PotionType(curable).setRegistryName(MODID, "curable_potion_type"));
|
||||
|
||||
// Register PotionType that can't be cured
|
||||
event.getRegistry().register(new PotionType(new PotionEffect(INCURABLE_POTION, 1200)).setRegistryName(MODID, "incurable_potion_type"));
|
||||
}
|
||||
}
|
||||
|
||||
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
|
||||
public static class ClientEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
if (!ENABLED) return;
|
||||
ModelBakery.registerItemVariants(MEDICINE);
|
||||
}
|
||||
}
|
||||
|
||||
private static class IncurablePotion extends Potion
|
||||
{
|
||||
protected IncurablePotion()
|
||||
{
|
||||
super(false, 0x94A061);
|
||||
setPotionName("incurable_potion");
|
||||
setIconIndex(6, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getCurativeItems()
|
||||
{
|
||||
// By default, no PotionEffect of this Potion can be cured by anything
|
||||
return new ArrayList<ItemStack>();
|
||||
}
|
||||
}
|
||||
|
||||
private static class Medicine extends ItemFood
|
||||
{
|
||||
public Medicine()
|
||||
{
|
||||
super(2, 1, false);
|
||||
setUnlocalizedName("medicine");
|
||||
setAlwaysEdible();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
|
||||
{
|
||||
if (!worldIn.isRemote)
|
||||
{
|
||||
player.curePotionEffects(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
//@Mod(modid = PotionShouldRenderTest.modID, name = "No Potion Effect Render Test", version = "0.0.0", acceptableRemoteVersions = "*")
|
||||
public class PotionShouldRenderTest
|
||||
{
|
||||
public static final String modID = "nopotioneffect";
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
TestPotion INSTANCE = (TestPotion)new TestPotion(new ResourceLocation(modID, "test_potion"), false, 0xff00ff).setRegistryName(new ResourceLocation(modID, "test_potion"));
|
||||
ForgeRegistries.POTIONS.register(INSTANCE);
|
||||
}
|
||||
|
||||
public static class TestPotion extends Potion
|
||||
{
|
||||
|
||||
public TestPotion(ResourceLocation location, boolean badEffect, int potionColor)
|
||||
{
|
||||
super(badEffect, potionColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(PotionEffect effect)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemShield;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
@ObjectHolder("shield_test")
|
||||
//@EventBusSubscriber
|
||||
//@Mod(modid = "shield_test", name = "Shield Test", version = "0.0.0", acceptableRemoteVersions = "*")
|
||||
public class ShieldTest
|
||||
{
|
||||
public static final ItemShield DIAMOND_SHIELD = null;
|
||||
public static final ItemSword HEAVY_DIAMOND_SWORD = null;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
class ItemCustomShield extends ItemShield
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack)
|
||||
{
|
||||
return I18n.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name").trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShield(ItemStack stack, EntityLivingBase entity)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
class ItemHeavyDiamondSword extends ItemSword
|
||||
{
|
||||
public ItemHeavyDiamondSword()
|
||||
{
|
||||
super(ToolMaterial.DIAMOND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot slot)
|
||||
{
|
||||
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(slot);
|
||||
if(slot == EntityEquipmentSlot.MAINHAND)
|
||||
{
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 12.0F, 0));
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -5D, 0));
|
||||
}
|
||||
return multimap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDisableShield(ItemStack stack, ItemStack shield, EntityLivingBase entity, EntityLivingBase attacker)
|
||||
{
|
||||
return shield.getItem() != DIAMOND_SHIELD;
|
||||
}
|
||||
}
|
||||
event.getRegistry().register(new ItemCustomShield().setMaxDamage(2098).setUnlocalizedName("diamond_shield").setRegistryName("diamond_shield"));
|
||||
event.getRegistry().register(new ItemHeavyDiamondSword().setUnlocalizedName("heavy_diamond_sword").setRegistryName("heavy_diamond_sword"));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
ModelLoader.setCustomModelResourceLocation(DIAMOND_SHIELD, 0, new ModelResourceLocation("shield_test:diamond_shield", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(HEAVY_DIAMOND_SWORD, 0, new ModelResourceLocation("minecraft:diamond_sword", "inventory"));
|
||||
}
|
||||
}*/
|
||||
Reference in new issue
Block a user