Renamed MinecraftForge.eventBus to EVENT_BUS as it's constant.

This commit is contained in:
LexManos 2012-08-05 19:14:02 -07:00
parent bb0f84925e
commit 2d7deacead
7 changed files with 43 additions and 10 deletions

View file

@ -1,8 +1,40 @@
package net.minecraftforge.common; package net.minecraftforge.common;
import net.minecraft.src.*;
import net.minecraftforge.common.ForgeHooks.GrassEntry;
import net.minecraftforge.common.ForgeHooks.SeedEntry;
import net.minecraftforge.event.EventBus; import net.minecraftforge.event.EventBus;
public class MinecraftForge public class MinecraftForge
{ {
public static final EventBus eventBus = new EventBus(); /**
* The core Forge EventBus, all events for Forge will be fired on this,
* you should use this to register all your listeners.
* This replaces every register*Handler() function in the old version of Forge.
*/
public static final EventBus EVENT_BUS = new EventBus();
/** Register a new plant to be planted when bonemeal is used on grass.
* @param block The block to place.
* @param metadata The metadata to set for the block when being placed.
* @param weight The weight of the plant, where red flowers are
* 10 and yellow flowers are 20.
*/
public static void addGrassPlant(Block block, int metadata, int weight)
{
ForgeHooks.grassList.add(new GrassEntry(block, metadata, weight));
}
/**
* Register a new seed to be dropped when breaking tall grass.
*
* @param seed The item to drop as a seed.
* @param weight The relative probability of the seeds,
* where wheat seeds are 10.
*/
public static void addGrassSeed(ItemStack seed, int weight)
{
ForgeHooks.seedList.add(new SeedEntry(seed, weight));
}
} }

View file

@ -117,7 +117,7 @@ public class OreDictionary
ArrayList<ItemStack> ores = getOres(id); ArrayList<ItemStack> ores = getOres(id);
ore = ore.copy(); ore = ore.copy();
ores.add(ore); ores.add(ore);
MinecraftForge.eventBus.post(new OreRegisterEvent(name, ore)); MinecraftForge.EVENT_BUS.post(new OreRegisterEvent(name, ore));
} }
public static class OreRegisterEvent extends Event public static class OreRegisterEvent extends Event

View file

@ -1,3 +1,4 @@
/.mylyn/ /.mylyn/
.lock .lock
version.ini version.ini
/*.log

View file

@ -14,7 +14,7 @@
var5 = this.readChunkFromNBT(par1World, par4NBTTagCompound.getCompoundTag("Level")); var5 = this.readChunkFromNBT(par1World, par4NBTTagCompound.getCompoundTag("Level"));
} }
+ MinecraftForge.eventBus.post(new ChunkDataEvent.Load(var5, par4NBTTagCompound)); + MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(var5, par4NBTTagCompound));
return var5; return var5;
} }
} }
@ -22,7 +22,7 @@
var3.setTag("Level", var4); var3.setTag("Level", var4);
this.writeChunkToNBT(par2Chunk, par1World, var4); this.writeChunkToNBT(par2Chunk, par1World, var4);
this.func_75824_a(par2Chunk.getChunkCoordIntPair(), var3); this.func_75824_a(par2Chunk.getChunkCoordIntPair(), var3);
+ MinecraftForge.eventBus.post(new ChunkDataEvent.Save(par2Chunk, var3)); + MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Save(par2Chunk, var3));
} }
catch (Exception var5) catch (Exception var5)
{ {

View file

@ -15,7 +15,7 @@
int var2 = this.item.stackSize; int var2 = this.item.stackSize;
+ EntityItemPickupEvent event = new EntityItemPickupEvent(this, par1EntityPlayer); + EntityItemPickupEvent event = new EntityItemPickupEvent(this, par1EntityPlayer);
+ MinecraftForge.eventBus.post(event); + MinecraftForge.EVENT_BUS.post(event);
+ +
+ if (delayBeforeCanPickup == 0 && (!event.isCanceled() || item.stackSize <= 0)) + if (delayBeforeCanPickup == 0 && (!event.isCanceled() || item.stackSize <= 0))
+ { + {

View file

@ -16,7 +16,7 @@
+ int var6 = this.getMaxItemUseDuration(par1ItemStack) - par4; + int var6 = this.getMaxItemUseDuration(par1ItemStack) - par4;
+ +
+ ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, var6); + ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, var6);
+ MinecraftForge.eventBus.post(event); + MinecraftForge.EVENT_BUS.post(event);
+ if (event.isCanceled()) + if (event.isCanceled())
+ { + {
+ return; + return;
@ -36,7 +36,7 @@
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{ {
+ ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); + ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);
+ MinecraftForge.eventBus.post(event); + MinecraftForge.EVENT_BUS.post(event);
+ if (event.isCanceled()) + if (event.isCanceled())
+ { + {
+ return event.getResultStack(); + return event.getResultStack();

View file

@ -265,7 +265,7 @@
List var4 = var1[var3]; List var4 = var1[var3];
this.worldObj.addLoadedEntities(var4); this.worldObj.addLoadedEntities(var4);
} }
+ MinecraftForge.eventBus.post(new ChunkEvent.Load(this)); + MinecraftForge.EVENT_BUS.post(new ChunkEvent.Load(this));
} }
/** /**
@ -273,7 +273,7 @@
List var4 = var5[var3]; List var4 = var5[var3];
this.worldObj.unloadEntities(var4); this.worldObj.unloadEntities(var4);
} }
+ MinecraftForge.eventBus.post(new ChunkEvent.Unload(this)); + MinecraftForge.EVENT_BUS.post(new ChunkEvent.Unload(this));
} }
/** /**