mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
Implemented BonemealEvent (IBonemealHandler replacement), and bonemeal making grass.
This commit is contained in:
1 parent
2d7deacead
commit
cc74f7d7d0
5 files changed
+199
-550
No files matched your search
@@ -0,0 +1,51 @@
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ForgeHooks
|
||||
{
|
||||
static class GrassEntry extends WeightedRandomItem
|
||||
{
|
||||
public final Block block;
|
||||
public final int metadata;
|
||||
public GrassEntry(Block block, int meta, int weight)
|
||||
{
|
||||
super(weight);
|
||||
this.block = block;
|
||||
this.metadata = meta;
|
||||
}
|
||||
}
|
||||
|
||||
static class SeedEntry extends WeightedRandomItem
|
||||
{
|
||||
public final ItemStack seed;
|
||||
public SeedEntry(ItemStack seed, int weight)
|
||||
{
|
||||
super(weight);
|
||||
this.seed = seed;
|
||||
}
|
||||
}
|
||||
static final List<GrassEntry> grassList = new ArrayList<GrassEntry>();
|
||||
static final List<SeedEntry> seedList = new ArrayList<SeedEntry>();
|
||||
|
||||
public static void plantGrass(World world, int x, int y, int z)
|
||||
{
|
||||
GrassEntry grass = (GrassEntry)WeightedRandom.getRandomItem(world.rand, grassList);
|
||||
if (grass == null || grass.block == null || !grass.block.canBlockStay(world, x, y, z))
|
||||
{
|
||||
return;
|
||||
}
|
||||
world.setBlockAndMetadataWithNotify(x, y, z, grass.block.blockID, grass.metadata);
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
grassList.add(new GrassEntry(Block.plantYellow, 0, 20));
|
||||
grassList.add(new GrassEntry(Block.plantRed, 0, 10));
|
||||
seedList.add(new SeedEntry(new ItemStack(Item.seeds), 10));
|
||||
System.out.printf("MinecraftForge v%s Initialized\n", ForgeVersion.getVersion());
|
||||
ModLoader.getLogger().info(String.format("MinecraftForge v%s Initialized", ForgeVersion.getVersion()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package net.minecraftforge.event.entity;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class BonemealEvent extends PlayerEvent
|
||||
{
|
||||
public final World world;
|
||||
public final int ID;
|
||||
public final int X;
|
||||
public final int Y;
|
||||
public final int Z;
|
||||
private boolean handeled = false;
|
||||
|
||||
public BonemealEvent(EntityPlayer player, World world, int id, int x, int y, int z)
|
||||
{
|
||||
super(player);
|
||||
this.world = world;
|
||||
this.ID = id;
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.Z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setHandeled()
|
||||
{
|
||||
handeled = true;
|
||||
}
|
||||
|
||||
public boolean isHandeled()
|
||||
{
|
||||
return handeled;
|
||||
}
|
||||
}
|
||||
@@ -40,472 +40,6 @@ import java.util.logging.Level;
|
||||
|
||||
public class ForgeHooks
|
||||
{
|
||||
// List Handling Hooks
|
||||
// ------------------------------------------------------------
|
||||
public static void onTakenFromCrafting(EntityPlayer player, ItemStack stack, IInventory craftMatrix)
|
||||
{
|
||||
for (ICraftingHandler handler : craftingHandlers)
|
||||
{
|
||||
handler.onTakenFromCrafting(player, stack, craftMatrix);
|
||||
}
|
||||
}
|
||||
static LinkedList<ICraftingHandler> craftingHandlers = new LinkedList<ICraftingHandler>();
|
||||
|
||||
public static void onDestroyCurrentItem(EntityPlayer player, ItemStack orig)
|
||||
{
|
||||
for (IDestroyToolHandler handler : destroyToolHandlers)
|
||||
{
|
||||
handler.onDestroyCurrentItem(player, orig);
|
||||
}
|
||||
}
|
||||
static LinkedList<IDestroyToolHandler> destroyToolHandlers = new LinkedList<IDestroyToolHandler>();
|
||||
|
||||
public static boolean onUseBonemeal(World world, int blockID, int x, int y, int z)
|
||||
{
|
||||
for (IBonemealHandler handler : bonemealHandlers)
|
||||
{
|
||||
if (handler.onUseBonemeal(world, blockID, x, y, z))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static LinkedList<IBonemealHandler> bonemealHandlers = new LinkedList<IBonemealHandler>();
|
||||
|
||||
public static boolean onUseHoe(ItemStack hoe, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
for (IHoeHandler handler : hoeHandlers)
|
||||
{
|
||||
if (handler.onUseHoe(hoe, player, world, x, y, z))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static LinkedList<IHoeHandler> hoeHandlers = new LinkedList<IHoeHandler>();
|
||||
|
||||
public static EnumStatus sleepInBedAt(EntityPlayer player, int x, int y, int z)
|
||||
{
|
||||
for (ISleepHandler handler : sleepHandlers)
|
||||
{
|
||||
EnumStatus status = handler.sleepInBedAt(player, x, y, z);
|
||||
if (status != null)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
static LinkedList<ISleepHandler> sleepHandlers = new LinkedList<ISleepHandler>();
|
||||
|
||||
|
||||
public static void onMinecartUpdate(EntityMinecart minecart, int x, int y, int z)
|
||||
{
|
||||
for (IMinecartHandler handler : minecartHandlers)
|
||||
{
|
||||
handler.onMinecartUpdate(minecart, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onMinecartEntityCollision(EntityMinecart minecart, Entity entity)
|
||||
{
|
||||
for (IMinecartHandler handler : minecartHandlers)
|
||||
{
|
||||
handler.onMinecartEntityCollision(minecart, entity);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean onMinecartInteract(EntityMinecart minecart, EntityPlayer player)
|
||||
{
|
||||
boolean canceled = true;
|
||||
for (IMinecartHandler handler : minecartHandlers)
|
||||
{
|
||||
boolean tmp = handler.onMinecartInteract(minecart, player, canceled);
|
||||
canceled = canceled && tmp;
|
||||
}
|
||||
return canceled;
|
||||
}
|
||||
|
||||
static LinkedList<IMinecartHandler> minecartHandlers = new LinkedList<IMinecartHandler>();
|
||||
|
||||
public static void onConnect(NetworkManager network)
|
||||
{
|
||||
for (IConnectionHandler handler : connectionHandlers)
|
||||
{
|
||||
handler.onConnect(network);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onLogin(NetworkManager network, Packet1Login login)
|
||||
{
|
||||
for (IConnectionHandler handler : connectionHandlers)
|
||||
{
|
||||
handler.onLogin(network, login);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onDisconnect(NetworkManager network, String message, Object[] args)
|
||||
{
|
||||
for (IConnectionHandler handler : connectionHandlers)
|
||||
{
|
||||
handler.onDisconnect(network, message, args);
|
||||
}
|
||||
}
|
||||
static LinkedList<IConnectionHandler> connectionHandlers = new LinkedList<IConnectionHandler>();
|
||||
|
||||
public static boolean onItemPickup(EntityPlayer player, EntityItem item)
|
||||
{
|
||||
boolean cont = true;
|
||||
for (IPickupHandler handler : pickupHandlers)
|
||||
{
|
||||
cont = cont && handler.onItemPickup(player, item);
|
||||
if (!cont || item.item.stackSize <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return cont;
|
||||
}
|
||||
static LinkedList<IPickupHandler> pickupHandlers = new LinkedList<IPickupHandler>();
|
||||
|
||||
public static void addActiveChunks(World world, Set<ChunkCoordIntPair> chunkList)
|
||||
{
|
||||
for(IChunkLoadHandler loader : chunkLoadHandlers)
|
||||
{
|
||||
loader.addActiveChunks(world, chunkList);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canUnloadChunk(Chunk chunk)
|
||||
{
|
||||
for(IChunkLoadHandler loader : chunkLoadHandlers)
|
||||
{
|
||||
if(!loader.canUnloadChunk(chunk))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean canUpdateEntity(Entity entity)
|
||||
{
|
||||
for(IChunkLoadHandler loader : chunkLoadHandlers)
|
||||
{
|
||||
if(loader.canUpdateEntity(entity))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static LinkedList<IChunkLoadHandler> chunkLoadHandlers = new LinkedList<IChunkLoadHandler>();
|
||||
|
||||
public static boolean onEntityInteract(EntityPlayer player, Entity entity, boolean isAttack)
|
||||
{
|
||||
for (IEntityInteractHandler handler : entityInteractHandlers)
|
||||
{
|
||||
if (!handler.onEntityInteract(player, entity, isAttack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static LinkedList<IEntityInteractHandler> entityInteractHandlers = new LinkedList<IEntityInteractHandler>();
|
||||
|
||||
public static String onServerChat(EntityPlayer player, String message)
|
||||
{
|
||||
for (IChatHandler handler : chatHandlers)
|
||||
{
|
||||
message = handler.onServerChat(player, message);
|
||||
if (message == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static boolean onChatCommand(EntityPlayer player, boolean isOp, String command)
|
||||
{
|
||||
for (IChatHandler handler : chatHandlers)
|
||||
{
|
||||
if (handler.onChatCommand(player, isOp, command))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean onServerCommand(Object listener, String username, String command)
|
||||
{
|
||||
for (IChatHandler handler : chatHandlers)
|
||||
{
|
||||
if (handler.onServerCommand(listener, username, command))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String onServerCommandSay(Object listener, String username, String message)
|
||||
{
|
||||
for (IChatHandler handler : chatHandlers)
|
||||
{
|
||||
message = handler.onServerCommandSay(listener, username, message);
|
||||
if (message == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String onClientChatRecv(String message)
|
||||
{
|
||||
for (IChatHandler handler : chatHandlers)
|
||||
{
|
||||
message = handler.onClientChatRecv(message);
|
||||
if (message == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
static LinkedList<IChatHandler> chatHandlers = new LinkedList<IChatHandler>();
|
||||
|
||||
public static void onWorldLoad(World world)
|
||||
{
|
||||
for (ISaveEventHandler handler : saveHandlers)
|
||||
{
|
||||
handler.onWorldLoad(world);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onWorldSave(World world)
|
||||
{
|
||||
for (ISaveEventHandler handler : saveHandlers)
|
||||
{
|
||||
handler.onWorldSave(world);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onChunkLoad(World world, Chunk chunk)
|
||||
{
|
||||
for (ISaveEventHandler handler : saveHandlers)
|
||||
{
|
||||
handler.onChunkLoad(world, chunk);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onChunkUnload(World world, Chunk chunk)
|
||||
{
|
||||
for (ISaveEventHandler handler : saveHandlers)
|
||||
{
|
||||
handler.onChunkUnload(world, chunk);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onChunkLoadData(World world, Chunk chunk, NBTTagCompound data)
|
||||
{
|
||||
for (ISaveEventHandler handler : saveHandlers)
|
||||
{
|
||||
handler.onChunkLoadData(world, chunk, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onChunkSaveData(World world, Chunk chunk, NBTTagCompound data)
|
||||
{
|
||||
for (ISaveEventHandler handler : saveHandlers)
|
||||
{
|
||||
handler.onChunkSaveData(world, chunk, data);
|
||||
}
|
||||
}
|
||||
static LinkedList<ISaveEventHandler> saveHandlers = new LinkedList<ISaveEventHandler>();
|
||||
|
||||
public static int getItemBurnTime(ItemStack stack)
|
||||
{
|
||||
for (IFuelHandler handler : fuelHandlers)
|
||||
{
|
||||
int ret = handler.getItemBurnTime(stack);
|
||||
if (ret > 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static LinkedList<IFuelHandler> fuelHandlers = new LinkedList<IFuelHandler>();
|
||||
|
||||
@SuppressWarnings("deprecation") //Internal use only, I don't want to see these yet
|
||||
public static boolean onEntitySpawnSpecial(EntityLiving entity, World world, float x, float y, float z)
|
||||
{
|
||||
for (ISpecialMobSpawnHandler handler : specialMobSpawnHandlers)
|
||||
{
|
||||
if (handler.onSpecialEntitySpawn(entity, world, x, y, z))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
static LinkedList<ISpecialMobSpawnHandler> specialMobSpawnHandlers = new LinkedList<ISpecialMobSpawnHandler>();
|
||||
|
||||
|
||||
public static boolean onEntityLivingSpawn(EntityLiving entity, World world, float x, float y, float z)
|
||||
{
|
||||
for (IEntityLivingHandler handler : entityLivingHandlers)
|
||||
{
|
||||
if (handler.onEntityLivingSpawn(entity, world, x, y, z))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean onEntityLivingDeath(EntityLiving entity, DamageSource killer)
|
||||
{
|
||||
for (IEntityLivingHandler handler : entityLivingHandlers)
|
||||
{
|
||||
if (handler.onEntityLivingDeath(entity, killer))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean onEntityLivingUpdate(EntityLiving entity)
|
||||
{
|
||||
for (IEntityLivingHandler handler : entityLivingHandlers)
|
||||
{
|
||||
if (handler.onEntityLivingUpdate(entity))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void onEntityLivingJump(EntityLiving entity)
|
||||
{
|
||||
for (IEntityLivingHandler handler : entityLivingHandlers)
|
||||
{
|
||||
handler.onEntityLivingJump(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean onEntityLivingFall(EntityLiving entity, float distance)
|
||||
{
|
||||
for (IEntityLivingHandler handler : entityLivingHandlers)
|
||||
{
|
||||
if (handler.onEntityLivingFall(entity, distance))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean onEntityLivingAttacked(EntityLiving entity, DamageSource attack, int damage)
|
||||
{
|
||||
for (IEntityLivingHandler handler : entityLivingHandlers)
|
||||
{
|
||||
if (handler.onEntityLivingAttacked(entity, attack, damage))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void onEntityLivingSetAttackTarget(EntityLiving entity, EntityLiving target)
|
||||
{
|
||||
for (IEntityLivingHandler handler : entityLivingHandlers)
|
||||
{
|
||||
handler.onEntityLivingSetAttackTarget(entity, target);
|
||||
}
|
||||
}
|
||||
|
||||
public static int onEntityLivingHurt(EntityLiving entity, DamageSource source, int damage)
|
||||
{
|
||||
for (IEntityLivingHandler handler : entityLivingHandlers)
|
||||
{
|
||||
damage = handler.onEntityLivingHurt(entity, source, damage);
|
||||
if (damage == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return damage;
|
||||
}
|
||||
|
||||
public static void onEntityLivingDrops(EntityLiving entity, DamageSource source, ArrayList<EntityItem> drops, int lootingLevel, boolean recentlyHit, int specialDropValue)
|
||||
{
|
||||
for (IEntityLivingHandler handler : entityLivingHandlers)
|
||||
{
|
||||
handler.onEntityLivingDrops(entity, source, drops, lootingLevel, recentlyHit, specialDropValue);
|
||||
}
|
||||
}
|
||||
|
||||
static LinkedList<IEntityLivingHandler> entityLivingHandlers = new LinkedList<IEntityLivingHandler>();
|
||||
|
||||
// Plant Management
|
||||
// ------------------------------------------------------------
|
||||
static class ProbableItem
|
||||
{
|
||||
public ProbableItem(int item, int metadata, int quantity, int start, int end)
|
||||
{
|
||||
WeightStart = start;
|
||||
WeightEnd = end;
|
||||
ItemID = item;
|
||||
Metadata = metadata;
|
||||
Quantity = quantity;
|
||||
}
|
||||
int WeightStart, WeightEnd;
|
||||
int ItemID, Metadata;
|
||||
int Quantity;
|
||||
}
|
||||
|
||||
static ProbableItem getRandomItem(List<ProbableItem> list, int prop)
|
||||
{
|
||||
int n = Collections.binarySearch(list, prop, new Comparator()
|
||||
{
|
||||
public int compare(Object o1, Object o2)
|
||||
{
|
||||
ProbableItem pi = (ProbableItem)o1;
|
||||
Integer i1 = (Integer)o2;
|
||||
if (i1 < pi.WeightStart)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (i1 >= pi.WeightEnd)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
if (n < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list.get(n);
|
||||
}
|
||||
|
||||
static List<ProbableItem> plantGrassList;
|
||||
static int plantGrassWeight;
|
||||
|
||||
static List<ProbableItem> seedGrassList;
|
||||
static int seedGrassWeight;
|
||||
|
||||
public static void plantGrassPlant(World world, int x, int y, int z)
|
||||
{
|
||||
@@ -522,12 +56,6 @@ public class ForgeHooks
|
||||
world.setBlockAndMetadataWithNotify(x, y, z, item.ItemID, item.Metadata);
|
||||
}
|
||||
|
||||
public static void addPlantGrass(int item, int metadata, int probability)
|
||||
{
|
||||
plantGrassList.add(new ProbableItem(item, metadata, 1, plantGrassWeight, plantGrassWeight + probability));
|
||||
plantGrassWeight += probability;
|
||||
}
|
||||
|
||||
public static ItemStack getGrassSeed(World world)
|
||||
{
|
||||
int index = world.rand.nextInt(seedGrassWeight);
|
||||
@@ -539,12 +67,6 @@ public class ForgeHooks
|
||||
return new ItemStack(item.ItemID, item.Quantity, item.Metadata);
|
||||
}
|
||||
|
||||
public static void addGrassSeed(int item, int metadata, int quantity, int probability)
|
||||
{
|
||||
seedGrassList.add(new ProbableItem(item, metadata, quantity, seedGrassWeight, seedGrassWeight + probability));
|
||||
seedGrassWeight += probability;
|
||||
}
|
||||
|
||||
// Tool Path
|
||||
// ------------------------------------------------------------
|
||||
public static boolean canHarvestBlock(Block block, EntityPlayer player, int metadata)
|
||||
@@ -714,78 +236,6 @@ public class ForgeHooks
|
||||
public static Hashtable<Integer, NetworkMod> networkMods = new Hashtable<Integer, NetworkMod>();
|
||||
public static Hashtable<BaseMod, IGuiHandler> guiHandlers = new Hashtable<BaseMod, IGuiHandler>();
|
||||
|
||||
public static boolean onArrowLoose(ItemStack itemstack, World world, EntityPlayer player, int heldTime)
|
||||
{
|
||||
for (IArrowLooseHandler handler : arrowLooseHandlers)
|
||||
{
|
||||
if (handler.onArrowLoose(itemstack, world, player, heldTime))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ArrayList<IArrowLooseHandler> arrowLooseHandlers = new ArrayList<IArrowLooseHandler>();
|
||||
|
||||
public static ItemStack onArrowNock(ItemStack itemstack, World world, EntityPlayer player)
|
||||
{
|
||||
for (IArrowNockHandler handler : arrowNockHandlers)
|
||||
{
|
||||
ItemStack ret = handler.onArrowNock(itemstack, world, player);
|
||||
if (ret != null)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static ArrayList<IArrowNockHandler> arrowNockHandlers = new ArrayList<IArrowNockHandler>();
|
||||
|
||||
//This number is incremented every Minecraft version, and never reset
|
||||
public static final int majorVersion = 3;
|
||||
//This number is incremented every official release, and reset every Minecraft version
|
||||
public static final int minorVersion = 4;
|
||||
//This number is incremented every time a interface changes, and reset every Minecraft version
|
||||
public static final int revisionVersion = 9;
|
||||
//This number is incremented every time Jenkins builds Forge, and never reset. Should always be 0 in the repo code.
|
||||
public static final int buildVersion = 0;
|
||||
|
||||
public static int getMajorVersion()
|
||||
{
|
||||
return majorVersion;
|
||||
}
|
||||
|
||||
public static int getMinorVersion()
|
||||
{
|
||||
return minorVersion;
|
||||
}
|
||||
|
||||
public static int getRevisionVersion()
|
||||
{
|
||||
return revisionVersion;
|
||||
}
|
||||
|
||||
public static int getBuildVersion()
|
||||
{
|
||||
return buildVersion;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
plantGrassList = new ArrayList<ProbableItem>();
|
||||
plantGrassList.add(new ProbableItem(Block.plantYellow.blockID, 0, 1, 0, 20));
|
||||
plantGrassList.add(new ProbableItem(Block.plantRed.blockID, 0, 1, 20, 30));
|
||||
plantGrassWeight = 30;
|
||||
|
||||
seedGrassList = new ArrayList<ProbableItem>();
|
||||
seedGrassList.add(new ProbableItem(Item.seeds.shiftedIndex, 0, 1, 0, 10));
|
||||
seedGrassWeight = 10;
|
||||
|
||||
System.out.printf("MinecraftForge v%d.%d.%d.%d Initialized\n", majorVersion, minorVersion, revisionVersion, buildVersion);
|
||||
ModLoader.getLogger().info(String.format("MinecraftForge v%d.%d.%d.%d Initialized", majorVersion, minorVersion, revisionVersion, buildVersion));
|
||||
}
|
||||
|
||||
static boolean toolInit = false;
|
||||
static HashMap toolClasses = new HashMap();
|
||||
static HashMap toolHarvestLevels = new HashMap();
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
--- ../src_base/minecraft/net/minecraft/src/ItemDye.java
|
||||
+++ ../src_work/minecraft/net/minecraft/src/ItemDye.java
|
||||
@@ -1,6 +1,10 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
+
|
||||
+import net.minecraftforge.common.ForgeHooks;
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+import net.minecraftforge.event.entity.BonemealEvent;
|
||||
|
||||
public class ItemDye extends Item
|
||||
{
|
||||
@@ -45,6 +49,22 @@
|
||||
if (par1ItemStack.getItemDamage() == 15)
|
||||
{
|
||||
var11 = par3World.getBlockId(par4, par5, par6);
|
||||
+
|
||||
+ BonemealEvent event = new BonemealEvent(par2EntityPlayer, par3World, var11, par4, par5, par6);
|
||||
+ MinecraftForge.EVENT_BUS.post(event);
|
||||
+ if (event.isCanceled())
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (event.isHandeled())
|
||||
+ {
|
||||
+ if (!par3World.isRemote)
|
||||
+ {
|
||||
+ par1ItemStack.stackSize--;
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
|
||||
if (var11 == Block.sapling.blockID)
|
||||
{
|
||||
@@ -144,16 +164,9 @@
|
||||
par3World.setBlockAndMetadataWithNotify(var13, var14, var15, Block.tallGrass.blockID, 1);
|
||||
}
|
||||
}
|
||||
- else if (itemRand.nextInt(3) != 0)
|
||||
+ else
|
||||
{
|
||||
- if (Block.plantYellow.canBlockStay(par3World, var13, var14, var15))
|
||||
- {
|
||||
- par3World.setBlockWithNotify(var13, var14, var15, Block.plantYellow.blockID);
|
||||
- }
|
||||
- }
|
||||
- else if (Block.plantRed.canBlockStay(par3World, var13, var14, var15))
|
||||
- {
|
||||
- par3World.setBlockWithNotify(var13, var14, var15, Block.plantRed.blockID);
|
||||
+ ForgeHooks.plantGrass(par3World, var13, var14, var15);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
--- ../src_base/minecraft_server/net/minecraft/src/ItemDye.java
|
||||
+++ ../src_work/minecraft_server/net/minecraft/src/ItemDye.java
|
||||
@@ -1,4 +1,8 @@
|
||||
package net.minecraft.src;
|
||||
+
|
||||
+import net.minecraftforge.common.ForgeHooks;
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+import net.minecraftforge.event.entity.BonemealEvent;
|
||||
|
||||
public class ItemDye extends Item
|
||||
{
|
||||
@@ -34,6 +38,22 @@
|
||||
if (par1ItemStack.getItemDamage() == 15)
|
||||
{
|
||||
var11 = par3World.getBlockId(par4, par5, par6);
|
||||
+
|
||||
+ BonemealEvent event = new BonemealEvent(par2EntityPlayer, par3World, var11, par4, par5, par6);
|
||||
+ MinecraftForge.EVENT_BUS.post(event);
|
||||
+ if (event.isCanceled())
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (event.isHandeled())
|
||||
+ {
|
||||
+ if (!par3World.isRemote)
|
||||
+ {
|
||||
+ par1ItemStack.stackSize--;
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
|
||||
if (var11 == Block.sapling.blockID)
|
||||
{
|
||||
@@ -133,16 +153,9 @@
|
||||
par3World.setBlockAndMetadataWithNotify(var13, var14, var15, Block.tallGrass.blockID, 1);
|
||||
}
|
||||
}
|
||||
- else if (itemRand.nextInt(3) != 0)
|
||||
+ else
|
||||
{
|
||||
- if (Block.plantYellow.canBlockStay(par3World, var13, var14, var15))
|
||||
- {
|
||||
- par3World.setBlockWithNotify(var13, var14, var15, Block.plantYellow.blockID);
|
||||
- }
|
||||
- }
|
||||
- else if (Block.plantRed.canBlockStay(par3World, var13, var14, var15))
|
||||
- {
|
||||
- par3World.setBlockWithNotify(var13, var14, var15, Block.plantRed.blockID);
|
||||
+ ForgeHooks.plantGrass(par3World, var13, var14, var15);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user