ICraftingHandler, IPickupHandler are now both events.
This commit is contained in:
parent
751c5e39a4
commit
5aa0054f23
|
@ -4,7 +4,7 @@
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+import cpw.mods.fml.common.registry.GameRegistry;
|
||||
+import cpw.mods.fml.common.FMLCommonHandler;
|
||||
+
|
||||
public class EntityItem extends Entity
|
||||
{
|
||||
|
@ -13,7 +13,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
+ GameRegistry.onPickupNotification(p_70100_1_, this);
|
||||
+ FMLCommonHandler.instance().firePlayerItemPickupEvent(p_70100_1_, this);
|
||||
+
|
||||
this.field_70170_p.func_72956_a(p_70100_1_, "random.pop", 0.2F, ((this.field_70146_Z.nextFloat() - this.field_70146_Z.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
p_70100_1_.func_71001_a(this, i);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.inventory;
|
||||
|
||||
+import cpw.mods.fml.common.registry.GameRegistry;
|
||||
+import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
|
@ -11,7 +11,7 @@
|
|||
|
||||
public void func_82870_a(EntityPlayer p_82870_1_, ItemStack p_82870_2_)
|
||||
{
|
||||
+ GameRegistry.onItemCrafted(p_82870_1_, p_82870_2_, field_75239_a);
|
||||
+ FMLCommonHandler.instance().firePlayerCraftingEvent(p_82870_1_, p_82870_2_, field_75239_a);
|
||||
this.func_75208_c(p_82870_2_);
|
||||
|
||||
for (int i = 0; i < this.field_75239_a.func_70302_i_(); ++i)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.inventory;
|
||||
|
||||
+import cpw.mods.fml.common.registry.GameRegistry;
|
||||
+import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
|
@ -11,7 +11,7 @@
|
|||
|
||||
this.field_75228_b = 0;
|
||||
|
||||
+ GameRegistry.onItemSmelted(field_75229_a, p_75208_1_);
|
||||
+ FMLCommonHandler.instance().firePlayerSmeltedEvent(field_75229_a, p_75208_1_);
|
||||
+
|
||||
if (p_75208_1_.func_77973_b() == Items.field_151042_j)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,10 @@ import java.util.Set;
|
|||
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
|
@ -467,4 +470,19 @@ public class FMLCommonHandler
|
|||
{
|
||||
bus().post(new PlayerEvent.PlayerRespawnEvent(player));
|
||||
}
|
||||
|
||||
public void firePlayerItemPickupEvent(EntityPlayer player, EntityItem item)
|
||||
{
|
||||
bus().post(new PlayerEvent.ItemPickupEvent(player, item));
|
||||
}
|
||||
|
||||
public void firePlayerCraftingEvent(EntityPlayer player, ItemStack crafted, IInventory craftMatrix)
|
||||
{
|
||||
bus().post(new PlayerEvent.ItemCraftedEvent(player, crafted, craftMatrix));
|
||||
}
|
||||
|
||||
public void firePlayerSmeltedEvent(EntityPlayer player, ItemStack smelted)
|
||||
{
|
||||
bus().post(new PlayerEvent.ItemSmeltedEvent(player, smelted));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface IConsoleHandler
|
||||
{
|
||||
public boolean handleCommand(String command, Object... data);
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Return a crafting handler for the mod container to call
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface ICraftingHandler
|
||||
{
|
||||
/**
|
||||
* The object array contains these three arguments
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
* @param craftMatrix
|
||||
*/
|
||||
void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix);
|
||||
|
||||
/**
|
||||
* The object array contains these two arguments
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
void onSmelting(EntityPlayer player, ItemStack item);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public interface IPickupNotifier
|
||||
{
|
||||
void notifyPickup(EntityItem item, EntityPlayer player);
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package cpw.mods.fml.common.gameevent;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class PlayerEvent extends Event {
|
||||
|
@ -10,6 +13,34 @@ public class PlayerEvent extends Event {
|
|||
this.player = player;
|
||||
}
|
||||
|
||||
public static class ItemPickupEvent extends PlayerEvent {
|
||||
public final EntityItem pickedUp;
|
||||
public ItemPickupEvent(EntityPlayer player, EntityItem pickedUp)
|
||||
{
|
||||
super(player);
|
||||
this.pickedUp = pickedUp;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemCraftedEvent extends PlayerEvent {
|
||||
public final ItemStack crafting;
|
||||
public final IInventory craftMatrix;
|
||||
public ItemCraftedEvent(EntityPlayer player, ItemStack crafting, IInventory craftMatrix)
|
||||
{
|
||||
super(player);
|
||||
this.crafting = crafting;
|
||||
this.craftMatrix = craftMatrix;
|
||||
}
|
||||
}
|
||||
public static class ItemSmeltedEvent extends PlayerEvent {
|
||||
public final ItemStack smelting;
|
||||
public ItemSmeltedEvent(EntityPlayer player, ItemStack crafting)
|
||||
{
|
||||
super(player);
|
||||
this.smelting = crafting;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlayerLoggedInEvent extends PlayerEvent {
|
||||
public PlayerLoggedInEvent(EntityPlayer player)
|
||||
{
|
||||
|
|
|
@ -17,12 +17,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -33,14 +29,14 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IFuelHandler;
|
||||
import cpw.mods.fml.common.IPickupNotifier;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.LoaderException;
|
||||
|
@ -51,8 +47,6 @@ public class GameRegistry
|
|||
{
|
||||
private static Set<IWorldGenerator> worldGenerators = Sets.newHashSet();
|
||||
private static List<IFuelHandler> fuelHandlers = Lists.newArrayList();
|
||||
private static List<ICraftingHandler> craftingHandlers = Lists.newArrayList();
|
||||
private static List<IPickupNotifier> pickupHandlers = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* Register a world generator - something that inserts new block types into the world
|
||||
|
@ -242,40 +236,6 @@ public class GameRegistry
|
|||
return fuelValue;
|
||||
}
|
||||
|
||||
public static void registerCraftingHandler(ICraftingHandler handler)
|
||||
{
|
||||
craftingHandlers.add(handler);
|
||||
}
|
||||
|
||||
public static void onItemCrafted(EntityPlayer player, ItemStack item, IInventory craftMatrix)
|
||||
{
|
||||
for (ICraftingHandler handler : craftingHandlers)
|
||||
{
|
||||
handler.onCrafting(player, item, craftMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onItemSmelted(EntityPlayer player, ItemStack item)
|
||||
{
|
||||
for (ICraftingHandler handler : craftingHandlers)
|
||||
{
|
||||
handler.onSmelting(player, item);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerPickupHandler(IPickupNotifier handler)
|
||||
{
|
||||
pickupHandlers.add(handler);
|
||||
}
|
||||
|
||||
public static void onPickupNotification(EntityPlayer player, EntityItem item)
|
||||
{
|
||||
for (IPickupNotifier notify : pickupHandlers)
|
||||
{
|
||||
notify.notifyPickup(item, player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a mod block in the global "named item list"
|
||||
* @param modId The modid owning the block
|
||||
|
|
Loading…
Reference in New Issue