本文整理汇总了Java中net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent类的典型用法代码示例。如果您正苦于以下问题:Java ItemCraftedEvent类的具体用法?Java ItemCraftedEvent怎么用?Java ItemCraftedEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ItemCraftedEvent类属于net.minecraftforge.fml.common.gameevent.PlayerEvent包,在下文中一共展示了ItemCraftedEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemCrafted
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent event)
{
if (event.player.worldObj.isRemote) { return; } // Server side only
if (event.crafting.getItem() instanceof LeaderRequiredItem) // Only leaders can craft this item
{
if (TerritoryHandler.getFactionPlayerIsLeaderOf(event.player) == null)
{
Main.console("Item is leader-only, but the player is not a leader. Removing the item.");
event.crafting.stackSize = 0; // Not having it
//event.setCanceled(true); // That event cannot be cancelled. How do I reliably stop the creation of this item? Setting the stack size itself seems to be delayed until the metadata changes,
// or some time passes and a sync is started
//TODO: Refund the items used?
}
// else, is leader of at least one faction. Checks out.
}
}
示例2: onCrafting
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onCrafting(@Nonnull final ItemCraftedEvent event) {
if (!ModOptions.enableCraftingSound)
return;
if (this.craftSoundThrottle >= (EnvironState.getTickCounter() - 30))
return;
if (event.player == null || event.player.world == null)
return;
if (event.player.world.isRemote && EnvironState.isPlayer(event.player)) {
this.craftSoundThrottle = EnvironState.getTickCounter();
final BasicSound<?> sound = makeSound(Sounds.CRAFTING);
SoundEffectHandler.INSTANCE.playSound(sound);
}
}
示例3: onItemCraft
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void onItemCraft(ItemCraftedEvent event) {
Item item = event.crafting.getItem();
if (item == HFItems.seeds_hemp_crushed || item == HFItems.seeds_indica_crushed
|| item == HFItems.seeds_sativa_crushed) {
for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) {
if (event.craftMatrix.getStackInSlot(i) != null) {
ItemStack stack = event.craftMatrix.getStackInSlot(i);
if (stack.getItem() instanceof ItemShears) {
if (stack.getItemDamage() < stack.getMaxDamage()) {
stack.shrink(1);
stack.setItemDamage(stack.getItemDamage() + 1);
event.craftMatrix.setInventorySlotContents(i, stack);
}
}
}
}
}
}
示例4: onItemCraftedEvent
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onItemCraftedEvent(ItemCraftedEvent event) {
if (event.crafting != null) {
if (event.crafting.getItem() instanceof ICustomCraftingHandler)
((ICustomCraftingHandler) event.crafting.getItem()).onCrafing(event.player, event.crafting, event.craftMatrix);
else if (event.crafting.getItem() instanceof ItemBlock && ((ItemBlock) event.crafting.getItem()).block instanceof ICustomCraftingHandler)
((ICustomCraftingHandler) ((ItemBlock) event.crafting.getItem()).block).onCrafing(event.player, event.crafting, event.craftMatrix);
}
for (int i = 0;i < event.craftMatrix.getSizeInventory();i++) {
ItemStack s = event.craftMatrix.getStackInSlot(i);
if (s != null) {
if (s.getItem() instanceof ICustomCraftingHandler)
((ICustomCraftingHandler) s.getItem()).onUsing(event.player, event.crafting, event.craftMatrix, s);
else if (s.getItem() instanceof ItemBlock && ((ItemBlock) s.getItem()).block instanceof ICustomCraftingHandler)
((ICustomCraftingHandler) ((ItemBlock) s.getItem()).block).onCrafing(event.player, event.crafting, event.craftMatrix);
}
}
if (event.crafting != null) {
Item item = event.crafting.getItem();
if (item == Item.getItemFromBlock(CoreInit.researchTable)) {
AchievementHandler.giveAchievement(event.player, "researchTable");
} else if (item == CoreInit.treeTap) {
AchievementHandler.giveAchievement(event.player, "treetap");
}
}
}
示例5: onCrafted
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onCrafted(ItemCraftedEvent event) {
if (event.crafting.getItem() == Item.getItemFromBlock(AlloycraftBlocks.forgeoff)) {
event.player.addStat(AlloycraftMain.alloyforge);
}
if (event.crafting.getItem() == AlloycraftItems.alloy) {
event.player.addStat(AlloycraftMain.alloy);
}
if (event.crafting.getItem() == AlloycraftItems.alloyaxe) {
event.player.addStat(AlloycraftMain.alloyaxe);
}
if (event.crafting.getItem() == AlloycraftItems.alloysword) {
event.player.addStat(AlloycraftMain.alloysword);
}
if (event.crafting.getItem() == AlloycraftItems.alloypickaxe) {
event.player.addStat(AlloycraftMain.alloypick);
}
if (event.crafting.getItem() == AlloycraftItems.alloyshovel) {
event.player.addStat(AlloycraftMain.alloyshovel);
}
if (event.crafting.getItem() == AlloycraftItems.alloyhoe) {
event.player.addStat(AlloycraftMain.alloyhoe);
}
}
示例6: craftingHandler
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent
public void craftingHandler(ItemCraftedEvent craftedEvent) {
for (int i = 0; i < craftedEvent.craftMatrix.getSizeInventory(); i++) {
ItemStack stack = craftedEvent.craftMatrix.getStackInSlot(i);
if (!stack.isEmpty() && stack.getItem() instanceof ICraftingTool && !(craftedEvent.crafting.getItem() instanceof ICraftingTool)) {
ItemStack craftingTool = new ItemStack(stack.getItem(), 2, stack.getItemDamage() + 1);
if (NBTHelper.hasTag(stack) && stack.getTagCompound() != null) {
craftingTool.setTagCompound(stack.getTagCompound());
}
if (craftingTool.getItemDamage() >= craftingTool.getMaxDamage()) {
craftingTool.shrink(1);
}
craftedEvent.craftMatrix.setInventorySlotContents(i, craftingTool);
}
}
}
示例7: onEvent
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@Override
public void onEvent(Object event)
{
if(event instanceof ItemCraftedEvent)
{
ItemCraftedEvent newEvent = (ItemCraftedEvent) event;
RecipeWrapper recipe = RecipeHelper.getWrappedRecipefromItemStack((newEvent.crafting));
if(recipe!= null && recipe.getSkill() == this.id)
{
this.calculateGain(this.tracker.trackedEntity, new SkillDifficulty("woodworking").setDifficulty(recipe.getDifficulty()));
}
}else if(event instanceof ItemSmeltedEvent)
{
}
}
示例8: onEvent
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@Override
public void onEvent(Object event)
{
if(event instanceof ItemCraftedEvent)
{
ItemCraftedEvent newEvent = (ItemCraftedEvent) event;
RecipeWrapper recipe = RecipeHelper.getWrappedRecipefromItemStack((newEvent.crafting));
if(recipe!= null && recipe.getSkill() == this.id)
{
this.calculateGain(this.tracker.trackedEntity, new SkillDifficulty(this.id).setDifficulty(recipe.getDifficulty()));
}
}
}
示例9: onCrafting
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onCrafting(ItemCraftedEvent craftedEvent) {
//ItemStack item = craftedEvent.crafting;
IInventory craftMatrix = craftedEvent.craftMatrix;
for(int i=0; i < craftMatrix.getSizeInventory(); i++)
{
if(craftMatrix.getStackInSlot(i) != null)
{
ItemStack j = craftMatrix.getStackInSlot(i);
if(j.getItem() != null && isDamageCrafting(j))
{
if(j.getItemDamage() + 1 < j.getItem().getMaxDamage()) {
ItemStack k = new ItemStack(j.getItem(), 2, j.getItemDamage() + 1);
craftMatrix.setInventorySlotContents(i, k);
}
}
}
}
}
示例10: onPlayerItemCrafted
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerItemCrafted(ItemCraftedEvent event)
{
for(int slot = 0; slot < event.craftMatrix.getSizeInventory(); slot++)
{
ItemStack item = event.craftMatrix.getStackInSlot(slot);
if(item != null)
{
if(item.getItem() == setItems.mortar_and_pestle)
{
ItemStack newitem = new ItemStack(setItems.mortar_and_pestle, 2, item.getItemDamage() + 1);
if(newitem.getItemDamage() >= newitem.getMaxDamage())
{
newitem.shrink(1);
}
event.craftMatrix.setInventorySlotContents(slot, newitem);
}
}
}
}
示例11: onItemCraftedEvent
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.NORMAL)
public void onItemCraftedEvent(ItemCraftedEvent event){
//System.out.println(event.crafting.getUnlocalizedName());
if (event.crafting.getUnlocalizedName().equals("item.stick")){
int random_number = (int) (Math.random() * 4);
if (!event.player.world.isRemote) {
event.player.inventory.addItemStackToInventory(new ItemStack(ModItems.brokenstick, random_number));
event.crafting.shrink(random_number);
if (event.player instanceof EntityPlayerMP){
((EntityPlayerMP) event.player).sendContainerToPlayer(event.player.inventoryContainer);
}
}
}
}
示例12: onCrafted
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onCrafted(ItemCraftedEvent e) {
if (e.crafting.getItem() instanceof ItemDankNull) {
for (int i = 0; i < e.craftMatrix.getSizeInventory(); ++i) {
if (!e.craftMatrix.getStackInSlot(i).isEmpty() && e.craftMatrix.getStackInSlot(i).getItem() instanceof ItemDankNull) {
NBTTagCompound oldCompound = e.craftMatrix.getStackInSlot(i).getTagCompound();
e.crafting.setTagCompound(oldCompound);
break;
}
ItemUtils.setItem(e.crafting, e.crafting.getItem());
}
}
}
示例13: onCrafting
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onCrafting(ItemCraftedEvent event)
{
EntityPlayer player = event.player;
ItemStack stack = event.crafting;
if (stack.getItem() == ItemsAether.holystone_pickaxe)
{
player.addStat(AchievementList.BUILD_BETTER_PICKAXE);
}
if (stack.getItem() == ItemsAether.skyroot_pickaxe)
{
player.addStat(AchievementList.BUILD_PICKAXE);
}
if (stack.getItem() == ItemsAether.skyroot_sword)
{
player.addStat(AchievementList.BUILD_SWORD);
}
if (stack.getItem() == Item.getItemFromBlock(BlocksAether.enchanter))
{
player.addStat(AchievementsAether.enchanter);
}
if (isGravititeTool(stack.getItem()))
{
player.addStat(AchievementsAether.grav_tools);
}
}
示例14: playerCrafted
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent
public void playerCrafted(ItemCraftedEvent event) {
if (event.player.worldObj.isRemote)
return;
if (isPlayerFake(event.player))
return;
if (event.crafting == null || event.crafting.getItem() == null)
return;
String itemName = "craft." + event.crafting.getItem().getUnlocalizedName(event.crafting);
PlayerResearchHelper.progressResearch(event.player, itemName, 1, true);
}
示例15: drumstickCraftedEvent
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; //导入依赖的package包/类
@SubscribeEvent
public void drumstickCraftedEvent(ItemCraftedEvent event) {
ItemStack stack = event.crafting;
if (stack.getItem() == ModItems.MEAT && stack.getItemDamage() == MeatType.CHICKEN_NUGGET.getMetadata()) {
Random rand = event.player.getRNG();
InventoryHandlerHelper.giveItem(event.player, EnumHand.MAIN_HAND, new ItemStack(ModItems.MEAT, rand.nextInt(5) == 1 ? 2 : 1, MeatType.DRUMSTICK.getMetadata()));
}
}