Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.

Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
This commit is contained in:
Lex Manos committed 2014-11-26 00:00:54 -08:00
1 parent 0e91787efb
commit 53659fca06
410 files changed
+8717 -14103

No files matched your search

@@ -1,7 +1,7 @@
package net.minecraftforge.event;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.item.ItemStack;
/**
@@ -1,7 +1,7 @@
package net.minecraftforge.event;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
@@ -2,60 +2,81 @@ package net.minecraftforge.event;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.common.eventhandler.Event.Result;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.entity.player.EntityPlayer.EnumStatus;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.storage.IPlayerFileData;
import net.minecraft.world.storage.SaveHandler;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.IExtendedEntityProperties;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
import net.minecraftforge.event.entity.item.ItemExpireEvent;
import net.minecraftforge.event.entity.living.LivingPackSizeEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent.AllowDespawn;
import net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent;
import net.minecraftforge.event.entity.player.BonemealEvent;
import net.minecraftforge.event.entity.player.EntityInteractEvent;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.entity.player.PlayerFlyableFallEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
import net.minecraftforge.event.entity.player.PlayerWakeUpEvent;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.MultiPlaceEvent;
import net.minecraftforge.event.world.BlockEvent.PlaceEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
public class ForgeEventFactory
{
public static MultiPlaceEvent onPlayerMultiBlockPlace(EntityPlayer player, List<BlockSnapshot> blockSnapshots, ForgeDirection direction)
public static MultiPlaceEvent onPlayerMultiBlockPlace(EntityPlayer player, List<BlockSnapshot> blockSnapshots, EnumFacing direction)
{
Block placedAgainst = blockSnapshots.get(0).world.getBlock(blockSnapshots.get(0).x + direction.getOpposite().offsetX, blockSnapshots.get(0).y + direction.getOpposite().offsetY, blockSnapshots.get(0).z + direction.getOpposite().offsetZ);
BlockSnapshot snap = blockSnapshots.get(0);
IBlockState placedAgainst = snap.world.getBlockState(snap.pos.offset(direction.getOpposite()));
MultiPlaceEvent event = new MultiPlaceEvent(blockSnapshots, placedAgainst, player);
MinecraftForge.EVENT_BUS.post(event);
return event;
}
public static PlaceEvent onPlayerBlockPlace(EntityPlayer player, BlockSnapshot blockSnapshot, ForgeDirection direction)
public static PlaceEvent onPlayerBlockPlace(EntityPlayer player, BlockSnapshot blockSnapshot, EnumFacing direction)
{
Block placedAgainst = blockSnapshot.world.getBlock(blockSnapshot.x + direction.getOpposite().offsetX, blockSnapshot.y + direction.getOpposite().offsetY, blockSnapshot.z + direction.getOpposite().offsetZ);
IBlockState placedAgainst = blockSnapshot.world.getBlockState(blockSnapshot.pos.offset(direction.getOpposite()));
PlaceEvent event = new PlaceEvent(blockSnapshot, placedAgainst, player);
MinecraftForge.EVENT_BUS.post(event);
return event;
@@ -68,26 +89,15 @@ public class ForgeEventFactory
return event.success;
}
@Deprecated // Location version below
public static float getBreakSpeed(EntityPlayer player, Block block, int metadata, float original)
public static float getBreakSpeed(EntityPlayer player, IBlockState state, float original, BlockPos pos)
{
return getBreakSpeed(player, block, metadata, original, 0, -1, 0);
}
public static float getBreakSpeed(EntityPlayer player, Block block, int metadata, float original, int x, int y, int z)
{
PlayerEvent.BreakSpeed event = new PlayerEvent.BreakSpeed(player, block, metadata, original, x, y, z);
PlayerEvent.BreakSpeed event = new PlayerEvent.BreakSpeed(player, state, original, pos);
return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.newSpeed);
}
@Deprecated
public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, int x, int y, int z, int face)
public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, World world, BlockPos pos, EnumFacing face)
{
return onPlayerInteract(player, action, x, y, z, face, null);
}
public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, int x, int y, int z, int face, World world)
{
PlayerInteractEvent event = new PlayerInteractEvent(player, action, x, y, z, face, world);
PlayerInteractEvent event = new PlayerInteractEvent(player, action, pos, face, world);
MinecraftForge.EVENT_BUS.post(event);
return event;
}
@@ -116,9 +126,9 @@ public class ForgeEventFactory
return event.getResult();
}
public static List<BiomeGenBase.SpawnListEntry> getPotentialSpawns(WorldServer world, EnumCreatureType type, int x, int y, int z, List<BiomeGenBase.SpawnListEntry> oldList)
public static List<BiomeGenBase.SpawnListEntry> getPotentialSpawns(WorldServer world, EnumCreatureType type, BlockPos pos, List<BiomeGenBase.SpawnListEntry> oldList)
{
WorldEvent.PotentialSpawns event = new WorldEvent.PotentialSpawns(world, type, x, y, z, oldList);
WorldEvent.PotentialSpawns event = new WorldEvent.PotentialSpawns(world, type, pos, oldList);
if (MinecraftForge.EVENT_BUS.post(event))
{
return null;
@@ -140,9 +150,9 @@ public class ForgeEventFactory
return event.displayname;
}
public static float fireBlockHarvesting(ArrayList<ItemStack> drops, World world, Block block, int x, int y, int z, int meta, int fortune, float dropChance, boolean silkTouch, EntityPlayer player)
public static float fireBlockHarvesting(List<ItemStack> drops, World world, BlockPos pos, IBlockState state, int fortune, float dropChance, boolean silkTouch, EntityPlayer player)
{
BlockEvent.HarvestDropsEvent event = new BlockEvent.HarvestDropsEvent(x, y, z, world, block, meta, fortune, dropChance, drops, player, silkTouch);
BlockEvent.HarvestDropsEvent event = new BlockEvent.HarvestDropsEvent(world, pos, state, fortune, dropChance, drops, player, silkTouch);
MinecraftForge.EVENT_BUS.post(event);
return event.dropChance;
}
@@ -216,4 +226,138 @@ public class ForgeEventFactory
File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, "playersDirectory", "field_"+"75771_c");
MinecraftForge.EVENT_BUS.post(new PlayerEvent.LoadFromFile(player, dir, uuidString));
}
public static IChatComponent onClientChat(byte type, IChatComponent message)
{
ClientChatReceivedEvent event = new ClientChatReceivedEvent(type, message);
return MinecraftForge.EVENT_BUS.post(event) ? null : event.message;
}
public static int onHoeUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos)
{
UseHoeEvent event = new UseHoeEvent(player, stack, worldIn, pos);
if (MinecraftForge.EVENT_BUS.post(event)) return -1;
if (event.getResult() == Result.ALLOW)
{
stack.damageItem(1, player);
return 1;
}
return 0;
}
public static int onApplyBonemeal(EntityPlayer player, World world, BlockPos pos, IBlockState state, ItemStack stack)
{
BonemealEvent event = new BonemealEvent(player, world, pos, state);
if (MinecraftForge.EVENT_BUS.post(event)) return -1;
if (event.getResult() == Result.ALLOW)
{
if (!world.isRemote)
stack.stackSize--;
return 1;
}
return 0;
}
public static ItemStack onBucketUse(EntityPlayer player, World world, ItemStack stack, MovingObjectPosition target)
{
FillBucketEvent event = new FillBucketEvent(player, stack, world, target);
if (MinecraftForge.EVENT_BUS.post(event)) return stack;
if (event.getResult() == Result.ALLOW)
{
if (player.capabilities.isCreativeMode)
return stack;
if (--stack.stackSize <= 0)
return event.result;
if (!player.inventory.addItemStackToInventory(event.result))
player.dropPlayerItemWithRandomChoice(event.result, false);
return stack;
}
return null;
}
public static boolean canEntityUpdate(Entity entity)
{
EntityEvent.CanUpdate event = new EntityEvent.CanUpdate(entity);
MinecraftForge.EVENT_BUS.post(event);
return event.canUpdate;
}
public static String onPlaySoundAt(Entity entity, String name, float volume, float pitch)
{
PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(entity, name, volume, pitch);
MinecraftForge.EVENT_BUS.post(event);
return event.name;
}
public static HashMap<String, IExtendedEntityProperties> onEntityConstructing(Entity entity, World world)
{
HashMap<String, IExtendedEntityProperties> ret = new HashMap<String, IExtendedEntityProperties>();
MinecraftForge.EVENT_BUS.post(new EntityEvent.EntityConstructing(entity));
for (IExtendedEntityProperties props : ret.values())
{
props.init(entity, world);
}
return ret;
}
public static int onItemExpire(EntityItem entity, ItemStack item)
{
if (item == null) return -1;
ItemExpireEvent event = new ItemExpireEvent(entity, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, entity.worldObj)));
if (!MinecraftForge.EVENT_BUS.post(event)) return -1;
return event.extraLife;
}
public static int onItemPickup(EntityItem entityItem, EntityPlayer entityIn, ItemStack itemstack)
{
Event event = new EntityItemPickupEvent(entityIn, entityItem);
if (MinecraftForge.EVENT_BUS.post(event)) return -1;
return event.getResult() == Result.ALLOW ? 1 : 0;
}
public static void onPlayerDrops(EntityPlayer player, DamageSource cause, List<EntityItem> capturedDrops, boolean recentlyHit)
{
PlayerDropsEvent event = new PlayerDropsEvent(player, cause, capturedDrops, recentlyHit);
if (!MinecraftForge.EVENT_BUS.post(event))
{
for (EntityItem item : capturedDrops)
{
player.joinEntityItemWithWorld(item);
}
}
}
public static boolean canInteractWith(EntityPlayer player, Entity entity)
{
return MinecraftForge.EVENT_BUS.post(new EntityInteractEvent(player, entity));
}
public static EnumStatus onPlayerSleepInBed(EntityPlayer player, BlockPos pos)
{
PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(player, pos);
MinecraftForge.EVENT_BUS.post(event);
return event.result;
}
public static void onPlayerWakeup(EntityPlayer player)
{
MinecraftForge.EVENT_BUS.post(new PlayerWakeUpEvent(player));
}
public static void onPlayerFall(EntityPlayer player, float distance, float multiplier)
{
MinecraftForge.EVENT_BUS.post(new PlayerFlyableFallEvent(player, distance, multiplier));
}
public static void onPlayerClone(EntityPlayer player, EntityPlayer oldPlayer, boolean wasDeath)
{
MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerEvent.Clone(player, oldPlayer, wasDeath));
}
}
@@ -1,7 +1,7 @@
package net.minecraftforge.event;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ChatComponentTranslation;
@@ -1,6 +1,6 @@
package net.minecraftforge.event.brewing;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.item.ItemStack;
/**
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.entity.Entity;
/**
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.EntityLightningBolt;
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.Entity;
/**
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.item;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.item.EntityItem;
/**
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.item;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.living;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.EntityLivingBase;
/**
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.living;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.util.DamageSource;
import net.minecraft.entity.EntityLivingBase;
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.living;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.util.DamageSource;
import net.minecraft.entity.EntityLivingBase;
@@ -1,15 +1,15 @@
package net.minecraftforge.event.entity.living;
import java.util.ArrayList;
import java.util.List;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.util.DamageSource;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.EntityLivingBase;
/**
* LivingDropsEvent is fired when an Entity's death causes dropped items to appear.<br>
* This event is fired whenever an Entity dies and drops items in
* This event is fired whenever an Entity dies and drops items in
* EntityLivingBase#onDeath(DamageSource).<br>
* <br>
* This event is fired via the {@link ForgeHooks#onLivingDrops(EntityLivingBase, DamageSource, ArrayList<EntityItem>, int, boolean, int)}.<br>
@@ -18,7 +18,6 @@ import net.minecraft.entity.EntityLivingBase;
* {@link #drops} contains the ArrayList of EntityItems that will be dropped.<br>
* {@link #lootingLevel} contains the amount of loot that will be dropped.<br>
* {@link #recentlyHit} determines whether the Entity doing the drop has recently been damaged.<br>
* {@link #specialDropValue} contains the special drop value for this even.<br>
* <br>
* This event is {@link Cancelable}.<br>
* If this event is canceled, the Entity does not drop anything.<br>
@@ -31,18 +30,16 @@ import net.minecraft.entity.EntityLivingBase;
public class LivingDropsEvent extends LivingEvent
{
public final DamageSource source;
public final ArrayList<EntityItem> drops;
public final List<EntityItem> drops;
public final int lootingLevel;
public final boolean recentlyHit;
public final int specialDropValue;
public LivingDropsEvent(EntityLivingBase entity, DamageSource source, ArrayList<EntityItem> drops, int lootingLevel, boolean recentlyHit, int specialDropValue)
public LivingDropsEvent(EntityLivingBase entity, DamageSource source, List<EntityItem> drops, int lootingLevel, boolean recentlyHit)
{
super(entity);
this.source = source;
this.drops = drops;
this.lootingLevel = lootingLevel;
this.recentlyHit = recentlyHit;
this.specialDropValue = specialDropValue;
}
}
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.living;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraftforge.event.entity.EntityEvent;
@@ -1,11 +1,11 @@
package net.minecraftforge.event.entity.living;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.EntityLivingBase;
/**
* LivingFallEvent is fired when an Entity is set to be falling.<br>
* This event is fired whenever an Entity is set to fall in
* This event is fired whenever an Entity is set to fall in
* EntityLivingBase#fall(float).<br>
* <br>
* This event is fired via the {@link ForgeHooks#onLivingFall(EntityLivingBase, float)}.<br>
@@ -23,9 +23,11 @@ import net.minecraft.entity.EntityLivingBase;
public class LivingFallEvent extends LivingEvent
{
public float distance;
public LivingFallEvent(EntityLivingBase entity, float distance)
public float damageMultiplier;
public LivingFallEvent(EntityLivingBase entity, float distance, float damageMultiplier)
{
super(entity);
this.distance = distance;
this.damageMultiplier = damageMultiplier;
}
}
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.living;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.util.DamageSource;
import net.minecraft.entity.EntityLivingBase;
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.living;
import cpw.mods.fml.common.eventhandler.Event.HasResult;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.entity.EntityLiving;
@HasResult
@@ -1,7 +1,7 @@
package net.minecraftforge.event.entity.living;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event.HasResult;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.entity.EntityLiving;
import net.minecraft.world.World;
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.living;
import cpw.mods.fml.common.eventhandler.Event.HasResult;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.world.World;
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.minecart;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.player.EntityPlayer;
@@ -1,15 +1,14 @@
package net.minecraftforge.event.entity.minecart;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.util.BlockPos;
/**
* MinecartUpdateEvent is fired when a minecart is updated.<br>
* This event is fired whenever a minecart is updated in
* EntityMinecart#onUpdate().<br>
* <br>
* {@link #x} contains the x-coordinate of the minecart Entity.<br>
* {@link #y} contains the y-coordinate of the minecart Entity.<br>
* {@link #z} contains the z-coordinate of the minecart Entity.<br>
* {@link #pos} contains the coordinate of the track the entity is on {if applicable}.<br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
@@ -19,15 +18,11 @@ import net.minecraft.entity.item.EntityMinecart;
**/
public class MinecartUpdateEvent extends MinecartEvent
{
public final float x;
public final float y;
public final float z;
public final BlockPos pos;
public MinecartUpdateEvent(EntityMinecart minecart, float x, float y, float z)
public MinecartUpdateEvent(EntityMinecart minecart, BlockPos pos)
{
super(minecart);
this.x = x;
this.y = y;
this.z = z;
this.pos = pos;
}
}
@@ -2,8 +2,8 @@ package net.minecraftforge.event.entity.player;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.stats.Achievement;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
/**
* When the player receives an achievement. If canceled the player will not receive anything.
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@@ -1,9 +1,11 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
@Cancelable
@@ -13,26 +15,22 @@ public class BonemealEvent extends PlayerEvent
/**
* This event is called when a player attempts to use Bonemeal on a block.
* It can be canceled to completely prevent any further processing.
*
* You can also set the result to ALLOW to mark the event as processed
*
* You can also set the result to ALLOW to mark the event as processed
* and use up a bonemeal from the stack but do no further processing.
*
*
* setResult(ALLOW) is the same as the old setHandeled()
*/
public final World world;
public final Block block;
public final int x;
public final int y;
public final int z;
public BonemealEvent(EntityPlayer player, World world, Block block, int x, int y, int z)
public final BlockPos pos;
public final IBlockState block;
public BonemealEvent(EntityPlayer player, World world, BlockPos pos, IBlockState block)
{
super(player);
this.world = world;
this.pos = pos;
this.block = block;
this.x = x;
this.y = y;
this.z = z;
}
}
@@ -1,7 +1,7 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event.HasResult;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@@ -1,7 +1,7 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@@ -1,7 +1,7 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -1,8 +1,8 @@
package net.minecraftforge.event.entity.player;
import java.util.ArrayList;
import java.util.List;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.item.EntityItem;
@@ -23,17 +23,17 @@ public class PlayerDropsEvent extends LivingDropsEvent
/**
* Creates a new event containing all the items that will drop into the
* world when a player dies.
* @param entity The dying player.
* @param entity The dying player.
* @param source The source of the damage which is killing the player.
* @param drops List of all drops entering the world.
*/
public PlayerDropsEvent(EntityPlayer entity, DamageSource source, ArrayList<EntityItem> drops, boolean recentlyHit)
public PlayerDropsEvent(EntityPlayer entity, DamageSource source, List<EntityItem> drops, boolean recentlyHit)
{
super(entity, source, drops,
(source.getEntity() instanceof EntityPlayer) ?
super(entity, source, drops,
(source.getEntity() instanceof EntityPlayer) ?
EnchantmentHelper.getLootingModifier(((EntityPlayer)source.getEntity())) : 0,
recentlyHit, 0);
recentlyHit);
this.entityPlayer = entity;
}
}
@@ -1,16 +1,17 @@
package net.minecraftforge.event.entity.player;
import java.io.File;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraftforge.event.entity.living.LivingEvent;
/**
* PlayerEvent is fired whenever an event involving Living entities occurs. <br>
* If a method utilizes this {@link Event} as its parameter, the method will
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
@@ -23,7 +24,7 @@ public class PlayerEvent extends LivingEvent
super(player);
entityPlayer = player;
}
/**
* HarvestCheck is fired when a player attempts to harvest a block.<br>
* This event is fired whenever a player attempts to harvest a block in
@@ -58,15 +59,12 @@ public class PlayerEvent extends LivingEvent
* This event is fired whenever a player attempts to harvest a block in
* EntityPlayer#canHarvestBlock(Block).<br>
* <br>
* This event is fired via the {@link ForgeEventFactory#getBreakSpeed(EntityPlayer, Block, int, float, int, int, int)}.<br>
* This event is fired via the {@link ForgeEventFactory#getBreakSpeed(EntityPlayer, IBlockState, float, BlockPos)}.<br>
* <br>
* {@link #block} contains the block being broken. <br>
* {@link #metadata} contains the metadata of the block being broken. <br>
* {@link #state} contains the block being broken. <br>
* {@link #originalSpeed} contains the original speed at which the player broke the block. <br>
* {@link #newSpeed} contains the newSpeed at which the player will break the block. <br>
* {@link #x} contains the x-coordinate at which this event is occurring. <br>
* {@link #y} contains the y-coordinate at which this event is occurring. <br>
* {@link #z} contains the z-coordinate at which this event is occurring. <br>
* {@link #pos} contains the coordinates at which this event is occurring. Y value -1 means location is unknown.<br>
* <br>
* This event is {@link Cancelable}.<br>
* If it is canceled, the player is unable to break the block.<br>
@@ -78,30 +76,18 @@ public class PlayerEvent extends LivingEvent
@Cancelable
public static class BreakSpeed extends PlayerEvent
{
public final Block block;
public final int metadata;
public final IBlockState state;
public final float originalSpeed;
public float newSpeed = 0.0f;
public final int x;
public final int y; // -1 notes unknown location
public final int z;
public final BlockPos pos; // Y position of -1 notes unknown location
@Deprecated
public BreakSpeed(EntityPlayer player, Block block, int metadata, float original)
{
this(player, block, metadata, original, 0, -1, 0);
}
public BreakSpeed(EntityPlayer player, Block block, int metadata, float original, int x, int y, int z)
public BreakSpeed(EntityPlayer player, IBlockState state, float original, BlockPos pos)
{
super(player);
this.block = block;
this.metadata = metadata;
this.state = state;
this.originalSpeed = original;
this.newSpeed = original;
this.x = x;
this.y = y;
this.z = z;
this.pos = pos;
}
}
@@ -156,37 +142,37 @@ public class PlayerEvent extends LivingEvent
this.wasDeath = wasDeath;
}
}
/**
* Fired when an Entity is started to be "tracked" by this player (the player receives updates about this entity, e.g. motion).
*
*/
public static class StartTracking extends PlayerEvent {
/**
* The Entity now being tracked.
*/
public final Entity target;
public StartTracking(EntityPlayer player, Entity target)
{
super(player);
this.target = target;
}
}
/**
* Fired when an Entity is stopped to be "tracked" by this player (the player no longer receives updates about this entity, e.g. motion).
*
*/
public static class StopTracking extends PlayerEvent {
/**
* The Entity no longer being tracked.
*/
public final Entity target;
public StopTracking(EntityPlayer player, Entity target)
{
super(player);
@@ -9,13 +9,13 @@ import net.minecraft.entity.player.EntityPlayer;
*/
public class PlayerFlyableFallEvent extends PlayerEvent
{
public float distance;
public float multipler;
public PlayerFlyableFallEvent(EntityPlayer player, float f)
public PlayerFlyableFallEvent(EntityPlayer player, float distance, float multiplier)
{
super(player);
this.distance = f;
this.distance = distance;
this.multipler = multiplier;
}
}
@@ -1,10 +1,12 @@
package net.minecraftforge.event.entity.player;
import static cpw.mods.fml.common.eventhandler.Event.Result.DEFAULT;
import static cpw.mods.fml.common.eventhandler.Event.Result.DENY;
import static net.minecraftforge.fml.common.eventhandler.Event.Result.DEFAULT;
import static net.minecraftforge.fml.common.eventhandler.Event.Result.DENY;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
/**
* PlayerInteractEvent is fired when a player interacts in some way.
@@ -15,13 +17,11 @@ import cpw.mods.fml.common.eventhandler.Cancelable;
* ItemInWorldManager#activateBlockOrUseItem(EntityPlayer, World, ItemStack, int, int, int, int, float, float, float),
* ItemInWorldManager#onBlockClicked(int, int, int, int). <br>
* <br>
* This event is fired via the {@link ForgeEventFactory#onPlayerInteract(EntityPlayer, Action, int, int, int, int)}.
* This event is fired via the {@link ForgeEventFactory#onPlayerInteract(EntityPlayer, Action, BlockPos, EnumFacing)}.
* <br>
* {@link #action} contains the Action the player performed durin this interaction. <br>
* {@link #x} contains the x-coordinate of where this event occurred. <br>
* {@link #y} contains the y-coordinate of where this event occurred. <br>
* {@link #z} contains the z-coordinate of where this event occurred. <br>
* {@link #face} contains the face of the block that was interacted with. <br>
* {@link #pos} contains the coordinate of where this event occurred.<br>
* {@link #face} contains the face of the block that was interacted with. May be null if unknown. <br>
* {@link #world} contains the world in which this event is occurring. <br>
* <br>
* This event is {@link Cancelable}.<br>
@@ -40,35 +40,25 @@ public class PlayerInteractEvent extends PlayerEvent
RIGHT_CLICK_BLOCK,
LEFT_CLICK_BLOCK
}
public final Action action;
public final int x;
public final int y;
public final int z;
public final int face;
public final World world;
public final BlockPos pos;
public final EnumFacing face; // Can be null if unknown
public Result useBlock = DEFAULT;
public Result useItem = DEFAULT;
@Deprecated
public PlayerInteractEvent(EntityPlayer player, Action action, int x, int y, int z, int face)
{
this(player, action, x, y, z, face, player.worldObj);
}
public PlayerInteractEvent(EntityPlayer player, Action action, int x, int y, int z, int face, World world)
public PlayerInteractEvent(EntityPlayer player, Action action, BlockPos pos, EnumFacing face, World world)
{
super(player);
this.action = action;
this.x = x;
this.y = y;
this.z = z;
this.pos = pos;
this.face = face;
if (face == -1) useBlock = DENY;
if (face == null) useBlock = DENY;
this.world = world;
}
@Override
public void setCanceled(boolean cancel)
{
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Event.HasResult;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
@@ -13,12 +13,12 @@ public class PlayerOpenContainerEvent extends PlayerEvent
/**
* This event is fired when a player attempts to view a container during
* player tick.
*
*
* setResult ALLOW to allow the container to stay open
* setResult DENY to force close the container (denying access)
*
* DEFAULT is vanilla behaviour
*
*
* DEFAULT is vanilla behavior
*
*/
public PlayerOpenContainerEvent(EntityPlayer player, Container openContainer)
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
@@ -2,12 +2,13 @@ package net.minecraftforge.event.entity.player;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayer.EnumStatus;
import net.minecraft.util.BlockPos;
/**
* PlayerSleepInBedEvent is fired when a player sleeps in a bed.
* <br>
* This event is fired whenever a player sleeps in a bed in
* EntityPlayer#sleepInBedAt(int, int, int).<br>
* EntityPlayer#sleepInBedAt(BlockPos).<br>
* <br>
* {@link #result} contains whether the player is able to sleep. <br>
* <br>
@@ -20,16 +21,12 @@ import net.minecraft.entity.player.EntityPlayer.EnumStatus;
public class PlayerSleepInBedEvent extends PlayerEvent
{
public EnumStatus result = null;
public final int x;
public final int y;
public final int z;
public final BlockPos pos;
public PlayerSleepInBedEvent(EntityPlayer player, int x, int y, int z)
public PlayerSleepInBedEvent(EntityPlayer player, BlockPos pos)
{
super(player);
this.x = x;
this.y = y;
this.z = z;
this.pos = pos;
}
}
@@ -1,6 +1,6 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -1,38 +1,35 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
@Cancelable
@Event.HasResult
public class UseHoeEvent extends PlayerEvent
{
/**
* This event is fired when a player attempts to use a Hoe on a block, it
* This event is fired when a player attempts to use a Hoe on a block, it
* can be canceled to completely prevent any further processing.
*
* You can also set the result to ALLOW to mark the event as processed
*
* You can also set the result to ALLOW to mark the event as processed
* and damage the hoe.
*
*
* setResult(ALLOW) is the same as the old setHandeled();
*/
public final ItemStack current;
public final World world;
public final int x;
public final int y;
public final int z;
public UseHoeEvent(EntityPlayer player, ItemStack current, World world, int x, int y, int z)
public final BlockPos pos;
public UseHoeEvent(EntityPlayer player, ItemStack current, World world, BlockPos pos)
{
super(player);
this.current = current;
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.pos = pos;
}
}
@@ -1,14 +1,15 @@
package net.minecraftforge.event.terraingen;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.Event.HasResult;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
/**
* BiomeEvent is fired whenever an event involving biomes occurs.<br>
* If a method utilizes this {@link Event} as its parameter, the method will
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.
@@ -21,7 +22,7 @@ public class BiomeEvent extends Event
{
this.biome = biome;
}
/**
* CreateDecorator is fired when a BiomeDecorator is created.<br>
* This event is fired whenever a BiomeDecorator is created in
@@ -40,7 +41,7 @@ public class BiomeEvent extends Event
{
public final BiomeDecorator originalBiomeDecorator;
public BiomeDecorator newBiomeDecorator;
public CreateDecorator(BiomeGenBase biome, BiomeDecorator original)
{
super(biome);
@@ -51,7 +52,7 @@ public class BiomeEvent extends Event
/**
* BiomeColor is fired whenever an event involving biome colors occurs. <br>
* If a method utilizes this {@link Event} as its parameter, the method will
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.
@@ -60,7 +61,7 @@ public class BiomeEvent extends Event
{
public final int originalColor;
public int newColor;
public BiomeColor(BiomeGenBase biome, int original)
{
super(biome);
@@ -68,51 +69,28 @@ public class BiomeEvent extends Event
newColor = original;
}
}
/**
* This event is fired when the village generator attempts to choose a block ID
* based on the village's biome.
*
*
* You can cancel the event to override default values
*/
@HasResult
public static class GetVillageBlockID extends BiomeEvent
{
public final Block original;
public final int type;
public Block replacement;
public final IBlockState original;
public IBlockState replacement;
public GetVillageBlockID(BiomeGenBase biome, Block original, int type)
public GetVillageBlockID(BiomeGenBase biome, IBlockState original)
{
super(biome);
this.original = original;
this.type = type;
}
}
/**
* This event is fired when the village generator attempts to choose a block
* metadata based on the village's biome.
*
* You can set the result to DENY to prevent the default block metadata selection.
*/
@HasResult
public static class GetVillageBlockMeta extends BiomeEvent
{
public final Block original;
public final int type;
public int replacement;
public GetVillageBlockMeta(BiomeGenBase biome, Block original, int type)
{
super(biome);
this.original = original;
this.type = type;
}
}
/**
* This event is fired when a biome is queried for its grass color.
* This event is fired when a biome is queried for its grass color.
*/
public static class GetGrassColor extends BiomeColor
{
@@ -121,9 +99,9 @@ public class BiomeEvent extends Event
super(biome, original);
}
}
/**
* This event is fired when a biome is queried for its grass color.
* This event is fired when a biome is queried for its grass color.
*/
public static class GetFoliageColor extends BiomeColor
{
@@ -132,9 +110,9 @@ public class BiomeEvent extends Event
super(biome, original);
}
}
/**
* This event is fired when a biome is queried for its water color.
* This event is fired when a biome is queried for its water color.
*/
public static class GetWaterColor extends BiomeColor
{
@@ -1,9 +1,10 @@
package net.minecraftforge.event.terraingen;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.chunk.IChunkProvider;
public class ChunkProviderEvent extends Event
@@ -25,33 +26,17 @@ public class ChunkProviderEvent extends Event
@HasResult
public static class ReplaceBiomeBlocks extends ChunkProviderEvent
{
public final int chunkX;
public final int chunkZ;
public final Block[] blockArray;
public final byte[] metaArray; // CAN BE NULL
public final BiomeGenBase[] biomeArray;
public final int x;
public final int z;
public final ChunkPrimer primer;
public final World world; // CAN BE NULL
@Deprecated // TODO: Remove in 1.8
public ReplaceBiomeBlocks(IChunkProvider chunkProvider, int chunkX, int chunkZ, Block[] blockArray, BiomeGenBase[] biomeArray)
{
this(chunkProvider, chunkX, chunkZ, blockArray, new byte[256], biomeArray, null);
}
@Deprecated // TODO: Remove in 1.8
public ReplaceBiomeBlocks(IChunkProvider chunkProvider, int chunkX, int chunkZ, Block[] blockArray, byte[] metaArray, BiomeGenBase[] biomeArray)
{
this(chunkProvider, chunkZ, chunkZ, blockArray, metaArray, biomeArray, null);
}
public ReplaceBiomeBlocks(IChunkProvider chunkProvider, int chunkX, int chunkZ, Block[] blockArray, byte[] metaArray, BiomeGenBase[] biomeArray, World world)
public ReplaceBiomeBlocks(IChunkProvider chunkProvider, int x, int z, ChunkPrimer primer, World world)
{
super(chunkProvider);
this.chunkX = chunkX;
this.chunkZ = chunkZ;
this.blockArray = blockArray;
this.biomeArray = biomeArray;
this.metaArray = metaArray;
this.x = x;
this.z = z;
this.primer = primer;
this.world = world;
}
@@ -1,9 +1,9 @@
package net.minecraftforge.event.terraingen;
import java.util.Random;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.Event.HasResult;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
/**DecorateBiomeEvent is fired when a BiomeDecorator is created.
@@ -12,9 +12,8 @@ import net.minecraft.world.World;
* DeferredBiomeDecorator#fireCreateEventAndReplace(BiomeGenBase).<br>
* <br>
* {@link #world} contains the world that is being decorated. <br>
* {@link #rand} contains an instane of Random to be used. <br>
* {@link #chunkX} contains the x-coordinate of the Chunk being decorated. <br>
* {@link #chunkZ} contains the z-coordinate of the Chunk being decorated. <br>
* {@link #rand} contains an instance of Random to be used. <br>
* {@link #pos} contains the coordinates of the Chunk being decorated. <br>
* <br>
* This event is not {@link Cancelable}.
* <br>
@@ -26,42 +25,40 @@ public class DecorateBiomeEvent extends Event
{
public final World world;
public final Random rand;
public final int chunkX;
public final int chunkZ;
public DecorateBiomeEvent(World world, Random rand, int worldX, int worldZ)
public final BlockPos pos;
public DecorateBiomeEvent(World world, Random rand, BlockPos pos)
{
this.world = world;
this.rand = rand;
this.chunkX = worldX;
this.chunkZ = worldZ;
this.pos = pos;
}
/**
* This event is fired before a chunk is decorated with a biome feature.
*/
public static class Pre extends DecorateBiomeEvent
{
public Pre(World world, Random rand, int worldX, int worldZ)
public Pre(World world, Random rand, BlockPos pos)
{
super(world, rand, worldX, worldZ);
super(world, rand, pos);
}
}
/**
* This event is fired after a chunk is decorated with a biome feature.
*/
public static class Post extends DecorateBiomeEvent
{
public Post(World world, Random rand, int worldX, int worldZ)
public Post(World world, Random rand, BlockPos pos)
{
super(world, rand, worldX, worldZ);
super(world, rand, pos);
}
}
/**
* This event is fired when a chunk is decorated with a biome feature.
*
*
* You can set the result to DENY to prevent the default biome decoration.
*/
@HasResult
@@ -69,13 +66,13 @@ public class DecorateBiomeEvent extends Event
{
/** Use CUSTOM to filter custom event types
*/
public static enum EventType { BIG_SHROOM, CACTUS, CLAY, DEAD_BUSH, LILYPAD, FLOWERS, GRASS, LAKE, PUMPKIN, REED, SAND, SAND_PASS2, SHROOM, TREE, CUSTOM }
public static enum EventType { BIG_SHROOM, CACTUS, CLAY, DEAD_BUSH, LILYPAD, FLOWERS, GRASS, LAKE_WATER, LAKE_LAVA, PUMPKIN, REED, SAND, SAND_PASS2, SHROOM, TREE, CUSTOM }
public final EventType type;
public Decorate(World world, Random rand, int worldX, int worldZ, EventType type)
public Decorate(World world, Random rand, BlockPos pos, EventType type)
{
super(world, rand, worldX, worldZ);
super(world, rand, pos);
this.type = type;
}
}
@@ -1,7 +1,7 @@
package net.minecraftforge.event.terraingen;
import java.util.Random;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
@@ -16,11 +16,11 @@ public class DeferredBiomeDecorator extends BiomeDecorator {
}
@Override
public void decorateChunk(World par1World, Random par2Random, BiomeGenBase biome, int par3, int par4)
public void func_180292_a(World par1World, Random par2Random, BiomeGenBase biome, BlockPos pos)
{
fireCreateEventAndReplace(biome);
// On first call to decorate, we fire and substitute ourselves, if we haven't already done so
biome.theBiomeDecorator.decorateChunk(par1World, par2Random, biome, par3, par4);
biome.theBiomeDecorator.func_180292_a(par1World, par2Random, biome, pos);
}
public void fireCreateEventAndReplace(BiomeGenBase biome)
{
@@ -38,7 +38,7 @@ public class DeferredBiomeDecorator extends BiomeDecorator {
wrapped.sandPerChunk2 = sandPerChunk2;
wrapped.treesPerChunk = treesPerChunk;
wrapped.waterlilyPerChunk = waterlilyPerChunk;
BiomeEvent.CreateDecorator event = new BiomeEvent.CreateDecorator(biome, wrapped);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
biome.theBiomeDecorator = event.newBiomeDecorator;
@@ -1,6 +1,6 @@
package net.minecraftforge.event.terraingen;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.world.gen.MapGenBase;
public class InitMapGenEvent extends Event
@@ -1,21 +1,20 @@
package net.minecraftforge.event.terraingen;
import java.util.Random;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.Event.HasResult;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
/**
* OreGenEvent is fired when an event involving ore generation occurs.<br>
* If a method utilizes this {@link Event} as its parameter, the method will
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* {@link #world} contains the world this event is occurring in.<br>
* {@link #rand} contains an instance of random that can be used in this event.<br>
* {@link #worldX} contains the x-coordinate of the block position currently being populated with ores.<br>
* {@link #worldZ} contains the z-coordinate of the block position currently being populated with ores.<br>
* {@link #pos} contains the coordinates of the chunk position currently being populated with ores.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#ORE_GEN_BUS}.<br>
**/
@@ -23,20 +22,18 @@ public class OreGenEvent extends Event
{
public final World world;
public final Random rand;
public final int worldX;
public final int worldZ;
public OreGenEvent(World world, Random rand, int worldX, int worldZ)
public final BlockPos pos;
public OreGenEvent(World world, Random rand, BlockPos pos)
{
this.world = world;
this.rand = rand;
this.worldX = worldX;
this.worldZ = worldZ;
this.pos = pos;
}
/**
* OreGenEvent.Pre is fired just before a chunk is populated with ores.<br>
* This event is fired just before ore generation in
* This event is fired just before ore generation in
* BiomeDecorator#generateOres().<br>
* <br>
* This event is not {@link Cancelable}.<br>
@@ -47,15 +44,15 @@ public class OreGenEvent extends Event
**/
public static class Pre extends OreGenEvent
{
public Pre(World world, Random rand, int worldX, int worldZ)
public Pre(World world, Random rand, BlockPos pos)
{
super(world, rand, worldX, worldZ);
super(world, rand, pos);
}
}
/**
* OreGenEvent.Post is fired just after a chunk is populated with ores.<br>
* This event is fired just after ore generation in
* This event is fired just after ore generation in
* BiomeDecorator#generateOres().<br>
* <br>
* This event is not {@link Cancelable}.<br>
@@ -63,18 +60,18 @@ public class OreGenEvent extends Event
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#ORE_GEN_BUS}.<br>
**/
**/
public static class Post extends OreGenEvent
{
public Post(World world, Random rand, int worldX, int worldZ)
public Post(World world, Random rand, BlockPos pos)
{
super(world, rand, worldX, worldZ);
super(world, rand, pos);
}
}
/**
* GenerateMinable is fired when a mineable block is generated in a chunk.<br>
* This event is fired just after ore generation in
* This event is fired just after ore generation in
* BiomeDecorator#generateOres().<br>
* <br>
* {@link #type} contains the enum value for the Ore attempting to be generated.<br>
@@ -86,18 +83,18 @@ public class OreGenEvent extends Event
* This result determines whether the ore is allowed to be generated.<br>
* <br>
* This event is fired on the {@link MinecraftForge#ORE_GEN_BUS}.<br>
**/
**/
@HasResult
public static class GenerateMinable extends OreGenEvent
{
public static enum EventType { COAL, DIAMOND, DIRT, GOLD, GRAVEL, IRON, LAPIS, REDSTONE, QUARTZ, CUSTOM }
public static enum EventType { COAL, DIAMOND, DIRT, GOLD, GRAVEL, IRON, LAPIS, REDSTONE, QUARTZ, DIORITE, GRANITE, ANDESITE, CUSTOM }
public final EventType type;
public final WorldGenerator generator;
public GenerateMinable(World world, Random rand, WorldGenerator generator, int worldX, int worldZ, EventType type)
public GenerateMinable(World world, Random rand, WorldGenerator generator, BlockPos pos, EventType type)
{
super(world, rand, worldX, worldZ);
super(world, rand, pos);
this.generator = generator;
this.type = type;
}
@@ -2,8 +2,8 @@ package net.minecraftforge.event.terraingen;
import java.util.Random;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.Event.HasResult;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
@@ -27,7 +27,7 @@ public class PopulateChunkEvent extends ChunkProviderEvent
public final int chunkX;
public final int chunkZ;
public final boolean hasVillageGenerated;
public PopulateChunkEvent(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated)
{
super(chunkProvider);
@@ -37,12 +37,12 @@ public class PopulateChunkEvent extends ChunkProviderEvent
this.chunkZ = chunkZ;
this.hasVillageGenerated = hasVillageGenerated;
}
/**
* PopulateChunkEvent.Pre is fired just before a chunk is populated a terrain feature.<br>
* This event is fired just before terrain feature generation in
* This event is fired just before terrain feature generation in
* ChunkProviderEnd#populate(IChunkProvider, int, int),
* ChunkProviderGenerate#populate(IChunkProvider, int, int),
* ChunkProviderGenerate#populate(IChunkProvider, int, int),
* and ChunkProviderHell#populate(IChunkProvider, int, int). <br>
* <br>
* This event is not {@link Cancelable}.<br>
@@ -58,12 +58,12 @@ public class PopulateChunkEvent extends ChunkProviderEvent
super(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated);
}
}
/**
* PopulateChunkEvent.Post is fired just after a chunk is populated with a terrain feature.<br>
* This event is fired just after terrain feature generation in
* This event is fired just after terrain feature generation in
* ChunkProviderEnd#populate(IChunkProvider, int, int),
* ChunkProviderGenerate#populate(IChunkProvider, int, int),
* ChunkProviderGenerate#populate(IChunkProvider, int, int),
* and ChunkProviderHell#populate(IChunkProvider, int, int). <br>
* <br>
* This event is not {@link Cancelable}.<br>
@@ -79,7 +79,7 @@ public class PopulateChunkEvent extends ChunkProviderEvent
super(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated);
}
}
/**
* PopulateChunkEvent.Populate is fired when a chunk is populated with a terrain feature.<br>
* This event is fired during terrain feature generation in
@@ -101,8 +101,8 @@ public class PopulateChunkEvent extends ChunkProviderEvent
{
/** Use CUSTOM to filter custom event types
*/
public static enum EventType { DUNGEON, FIRE, GLOWSTONE, ICE, LAKE, LAVA, NETHER_LAVA, ANIMALS, CUSTOM }
public static enum EventType { DUNGEON, FIRE, GLOWSTONE, ICE, LAKE, LAVA, NETHER_LAVA, NETHER_LAVA2, ANIMALS, CUSTOM }
public final EventType type;
public Populate(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, EventType type)
@@ -1,19 +1,17 @@
package net.minecraftforge.event.terraingen;
import java.util.Random;
import cpw.mods.fml.common.eventhandler.Event.HasResult;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.event.world.WorldEvent;
/**
* SaplingGrowTreeEvent is fired when a spling grows into a tree.<br>
* SaplingGrowTreeEvent is fired when a sapling grows into a tree.<br>
* This event is fired during sapling growth in
* BlockSapling#func_149878_d(World, int, int, int, Random).<br>
* BlockSapling#func_149878_d(World, BlockPos, Random).<br>
* <br>
* {@link #x} contains the x-coordinate of the growing sapling. <br>
* {@link #y} contains the y-coordinate of the growing sapling. <br>
* {@link #z} contains the z-coordinate of the growing sapling. <br>
* {@link #pos} contains the coordinates of the growing sapling. <br>
* {@link #rand} contains an instance of Random for use. <br>
* <br>
* This event is not {@link Cancelable}.<br>
@@ -26,17 +24,13 @@ import net.minecraftforge.event.world.WorldEvent;
@HasResult
public class SaplingGrowTreeEvent extends WorldEvent
{
public final int x;
public final int y;
public final int z;
public final BlockPos pos;
public final Random rand;
public SaplingGrowTreeEvent(World world, Random rand, int x, int y, int z)
public SaplingGrowTreeEvent(World world, Random rand, BlockPos pos)
{
super(world);
this.rand = rand;
this.x = x;
this.y = y;
this.z = z;
this.pos = pos;
}
}
@@ -1,9 +1,8 @@
package net.minecraftforge.event.terraingen;
import java.util.Random;
import cpw.mods.fml.common.eventhandler.Event.*;
import net.minecraftforge.fml.common.eventhandler.Event.*;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.MapGenBase;
@@ -29,31 +28,31 @@ public abstract class TerrainGen
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.newGen;
}
public static boolean populate(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, Populate.EventType type)
{
PopulateChunkEvent.Populate event = new PopulateChunkEvent.Populate(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated, type);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.getResult() != Result.DENY;
}
public static boolean decorate(World world, Random rand, int chunkX, int chunkZ, Decorate.EventType type)
public static boolean decorate(World world, Random rand, BlockPos pos, Decorate.EventType type)
{
Decorate event = new Decorate(world, rand, chunkX, chunkZ, type);
Decorate event = new Decorate(world, rand, pos, type);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.getResult() != Result.DENY;
}
public static boolean generateOre(World world, Random rand, WorldGenerator generator, int worldX, int worldZ, GenerateMinable.EventType type)
public static boolean generateOre(World world, Random rand, WorldGenerator generator, BlockPos pos, GenerateMinable.EventType type)
{
GenerateMinable event = new GenerateMinable(world, rand, generator, worldX, worldZ, type);
GenerateMinable event = new GenerateMinable(world, rand, generator, pos, type);
MinecraftForge.ORE_GEN_BUS.post(event);
return event.getResult() != Result.DENY;
}
public static boolean saplingGrowTree(World world, Random rand, int x, int y, int z)
public static boolean saplingGrowTree(World world, Random rand, BlockPos pos)
{
SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(world, rand, x, y, z);
SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(world, rand, pos);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.getResult() != Result.DENY;
}
@@ -1,6 +1,6 @@
package net.minecraftforge.event.terraingen;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.WorldType;
@@ -39,10 +39,10 @@ public class WorldTypeEvent extends Event
**/
public static class BiomeSize extends WorldTypeEvent
{
public final byte originalSize;
public byte newSize;
public BiomeSize(WorldType worldType, byte original)
public final int originalSize;
public int newSize;
public BiomeSize(WorldType worldType, int original)
{
super(worldType);
originalSize = original;
@@ -52,7 +52,7 @@ public class WorldTypeEvent extends Event
/**
* InitBiomeGens is fired when vanilla Minecraft attempts to initialize the biome generators.<br>
* This event is fired just during biome generator initialization in
* This event is fired just during biome generator initialization in
* WorldChunkManager#WorldChunkManager(long, WorldType). <br>
* <br>
* {@link #seed} the seed of the world. <br>
@@ -71,7 +71,7 @@ public class WorldTypeEvent extends Event
public final long seed;
public final GenLayer[] originalBiomeGens;
public GenLayer[] newBiomeGens;
public InitBiomeGens(WorldType worldType, long seed, GenLayer[] original)
{
super(worldType);
@@ -3,59 +3,56 @@ package net.minecraftforge.event.world;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.ImmutableList;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
public class BlockEvent extends Event {
import com.google.common.collect.ImmutableList;
public class BlockEvent extends Event
{
private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockEvent", "false"));
public final int x;
public final int y;
public final int z;
public final World world;
public final Block block;
public final int blockMetadata;
public BlockEvent(int x, int y, int z, World world, Block block, int blockMetadata)
public final BlockPos pos;
public final IBlockState state;
public BlockEvent(World world, BlockPos pos, IBlockState state)
{
this.x = x;
this.y = y;
this.z = z;
this.pos = pos;
this.world = world;
this.block = block;
this.blockMetadata = blockMetadata;
this.state = state;
}
/**
* Fired when a block is about to drop it's harvested items. The {@link #drops} array can be amended, as can the {@link #dropChance}.
* <strong>Note well:</strong> the {@link #harvester} player field is null in a variety of scenarios. Code expecting null.
*
* The {@link #dropChance} is used to determine which items in this array will actually drop, compared to a random number. If you wish, you
*
* The {@link #dropChance} is used to determine which items in this array will actually drop, compared to a random number. If you wish, you
* can pre-filter yourself, and set {@link #dropChance} to 1.0f to always drop the contents of the {@link #drops} array.
*
*
* {@link #isSilkTouching} is set if this is considered a silk touch harvesting operation, vs a normal harvesting operation. Act accordingly.
*
*
* @author cpw
*/
public static class HarvestDropsEvent extends BlockEvent {
public static class HarvestDropsEvent extends BlockEvent
{
public final int fortuneLevel;
public final ArrayList<ItemStack> drops;
public final List<ItemStack> drops;
public final boolean isSilkTouching;
public float dropChance; // Change to e.g. 1.0f, if you manipulate the list and want to guarantee it always drops
public final EntityPlayer harvester; // May be null for non-player harvesting such as explosions or machines
public HarvestDropsEvent(int x, int y, int z, World world, Block block, int blockMetadata, int fortuneLevel, float dropChance, ArrayList<ItemStack> drops, EntityPlayer harvester, boolean isSilkTouching)
public HarvestDropsEvent(World world, BlockPos pos, IBlockState state, int fortuneLevel, float dropChance, List<ItemStack> drops, EntityPlayer harvester, boolean isSilkTouching)
{
super(x, y, z, world, block, blockMetadata);
super(world, pos, state);
this.fortuneLevel = fortuneLevel;
this.dropChance = dropChance;
this.drops = drops;
@@ -63,33 +60,32 @@ public class BlockEvent extends Event {
this.harvester = harvester;
}
}
/**
* Event that is fired when an Block is about to be broken by a player
* Canceling this event will prevent the Block from being broken.
*/
@Cancelable
public static class BreakEvent extends BlockEvent
public static class BreakEvent extends BlockEvent
{
/** Reference to the Player who broke the block. If no player is available, use a EntityFakePlayer */
private final EntityPlayer player;
private int exp;
public BreakEvent(int x, int y, int z, World world, Block block, int blockMetadata, EntityPlayer player)
public BreakEvent(World world, BlockPos pos, IBlockState state, EntityPlayer player)
{
super(x, y, z, world, block, blockMetadata);
super(world, pos, state);
this.player = player;
if (block == null || !ForgeHooks.canHarvestBlock(block, player, blockMetadata) || // Handle empty block or player unable to break block scenario
block.canSilkHarvest(world, player, x, y, z, blockMetadata) && EnchantmentHelper.getSilkTouchModifier(player)) // If the block is being silk harvested, the exp dropped is 0
if (state == null || !ForgeHooks.canHarvestBlock(state.getBlock(), player, world, pos) || // Handle empty block or player unable to break block scenario
(state.getBlock().canSilkHarvest(world, pos, world.getBlockState(pos), player) && EnchantmentHelper.getSilkTouchModifier(player))) // If the block is being silk harvested, the exp dropped is 0
{
this.exp = 0;
}
else
{
int meta = block.getDamageValue(world, x, y, z);
int bonusLevel = EnchantmentHelper.getFortuneModifier(player);
this.exp = block.getExpDrop(world, meta, bonusLevel);
this.exp = state.getBlock().getExpDrop(world, pos, bonusLevel);
}
}
@@ -97,7 +93,7 @@ public class BlockEvent extends Event {
{
return player;
}
/**
* Get the experience dropped by the block after the event has processed
*
@@ -125,16 +121,17 @@ public class BlockEvent extends Event {
* If a Block Place event is cancelled, the block will not be placed.
*/
@Cancelable
public static class PlaceEvent extends BlockEvent {
public static class PlaceEvent extends BlockEvent
{
public final EntityPlayer player;
public final ItemStack itemInHand;
public final BlockSnapshot blockSnapshot;
public final Block placedBlock;
public final Block placedAgainst;
public final IBlockState placedBlock;
public final IBlockState placedAgainst;
public PlaceEvent(BlockSnapshot blockSnapshot, Block placedAgainst, EntityPlayer player) {
super(blockSnapshot.x, blockSnapshot.y, blockSnapshot.z, blockSnapshot.world, blockSnapshot.getCurrentBlock(), blockSnapshot.meta);
public PlaceEvent(BlockSnapshot blockSnapshot, IBlockState placedAgainst, EntityPlayer player)
{
super(blockSnapshot.world, blockSnapshot.pos, blockSnapshot.getCurrentBlock());
this.player = player;
this.itemInHand = player.getCurrentEquippedItem();
this.blockSnapshot = blockSnapshot;
@@ -150,15 +147,17 @@ public class BlockEvent extends Event {
/**
* Fired when a single block placement action of a player triggers the
* creation of multiple blocks(e.g. placing a bed block). The block returned
* by {@link #block} and its related methods is the block where
* by {@link #state} and its related methods is the block where
* the placed block would exist if the placement only affected a single
* block.
*/
@Cancelable
public static class MultiPlaceEvent extends PlaceEvent {
public static class MultiPlaceEvent extends PlaceEvent
{
private final List<BlockSnapshot> blockSnapshots;
public MultiPlaceEvent(List<BlockSnapshot> blockSnapshots, Block placedAgainst, EntityPlayer player) {
public MultiPlaceEvent(List<BlockSnapshot> blockSnapshots, IBlockState placedAgainst, EntityPlayer player)
{
super(blockSnapshots.get(0), placedAgainst, player);
this.blockSnapshots = ImmutableList.copyOf(blockSnapshots);
if (DEBUG)
@@ -173,7 +172,8 @@ public class BlockEvent extends Event {
*
* @return immutable list of replaced BlockSnapshots
*/
public List<BlockSnapshot> getReplacedBlockSnapshots() {
public List<BlockSnapshot> getReplacedBlockSnapshots()
{
return blockSnapshots;
}
}
@@ -14,18 +14,18 @@ import net.minecraft.world.chunk.Chunk;
public class ChunkEvent extends WorldEvent
{
private final Chunk chunk;
public ChunkEvent(Chunk chunk)
{
super(chunk.worldObj);
super(chunk.getWorld());
this.chunk = chunk;
}
public Chunk getChunk()
{
return chunk;
}
/**
* ChunkEvent.Load is fired when vanilla Minecraft attempts to load a Chunk into the world.<br>
* This event is fired during chunk loading in <br>
@@ -45,7 +45,7 @@ public class ChunkEvent extends WorldEvent
super(chunk);
}
}
/**
* ChunkEvent.Unload is fired when vanilla Minecraft attempts to unload a Chunk from the world.<br>
* This event is fired during chunk unloading in <br>
@@ -1,6 +1,6 @@
package net.minecraftforge.event.world;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -3,11 +3,13 @@ package net.minecraftforge.event.world;
import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.event.world.BlockEvent;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
/**
* Base class for Noteblock Events
@@ -17,12 +19,12 @@ public class NoteBlockEvent extends BlockEvent
{
private int noteId;
NoteBlockEvent(World world, int x, int y, int z, int meta, int note)
NoteBlockEvent(World world, BlockPos pos, IBlockState state, int note)
{
super(x, y, z, world, Blocks.noteblock, meta);
super(world, pos, state);
this.noteId = note;
}
/**
* Get the Note the Noteblock is tuned to
* @return the Note
@@ -33,7 +35,7 @@ public class NoteBlockEvent extends BlockEvent
}
/**
* Get the Octave of the note this Noteblock is tuned to
* Get the Octave of the note this Noteblock is tuned to
* @return the Octave
*/
public Octave getOctave()
@@ -52,7 +54,7 @@ public class NoteBlockEvent extends BlockEvent
/**
* Set Note and Octave for this event.<br>
* If octave is Octave.HIGH, note may only be Note.F_SHARP
* If octave is Octave.HIGH, note may only be Note.F_SHARP
* @param note the Note
* @param octave the Octave
*/
@@ -71,13 +73,13 @@ public class NoteBlockEvent extends BlockEvent
{
public Instrument instrument;
public Play(World world, int x, int y, int z, int meta, int note, int instrument)
public Play(World world, BlockPos pos, IBlockState state, int note, int instrument)
{
super(world, x, y, z, meta, note);
super(world, pos, state, note);
this.instrument = Instrument.fromId(instrument);
}
}
/**
* Fired when a Noteblock is changed. You can adjust the note it will change to via {@link #setNote(Note, Octave)}.
* Canceling this event will not change the note and also stop the Noteblock from playing it's note.
@@ -87,15 +89,15 @@ public class NoteBlockEvent extends BlockEvent
{
public final Note oldNote;
public final Octave oldOctave;
public Change(World world, int x, int y, int z, int meta, int oldNote, int newNote)
public Change(World world, BlockPos pos, IBlockState state, int oldNote, int newNote)
{
super(world, x, y, z, meta, newNote);
super(world, pos, state, newNote);
this.oldNote = Note.fromId(oldNote);
this.oldOctave = Octave.fromId(oldNote);
}
}
}
/**
* Describes the types of musical Instruments that can be played by a Noteblock.
* The Instrument being played can be overridden with {@link NoteBlockEvent.Play#setInstrument(Instrument)}
@@ -107,19 +109,19 @@ public class NoteBlockEvent extends BlockEvent
SNARE,
CLICKS,
BASSGUITAR;
// cache to avoid creating a new array every time
private static final Instrument[] values = values();
static Instrument fromId(int id)
{
return id < 0 || id > 4 ? PIANO : values[id];
}
}
/**
* Information about the pitch of a Noteblock note.
* For altered notes such as G-Sharp / A-Flat the Sharp variant is used here.
* For altered notes such as G-Sharp / A-Flat the Sharp variant is used here.
*
*/
public static enum Note
@@ -136,15 +138,15 @@ public class NoteBlockEvent extends BlockEvent
D_SHARP,
E,
F;
private static final Note[] values = values();
static Note fromId(int id)
{
return values[id % 12];
}
}
}
/**
* Describes the Octave of a Note being played by a Noteblock.
* Together with {@link Note} it fully describes the note.
@@ -155,7 +157,7 @@ public class NoteBlockEvent extends BlockEvent
LOW,
MID,
HIGH; // only valid for F_SHARP
static Octave fromId(int id)
{
return id < 12 ? LOW : id == 24 ? HIGH : MID;
@@ -2,16 +2,16 @@ package net.minecraftforge.event.world;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
/**
* WorldEvent is fired when an event involving the world occurs.<br>
* If a method utilizes this {@link Event} as its parameter, the method will
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* {@link #world} contains the World this event is occuring in.<br>
@@ -31,8 +31,8 @@ public class WorldEvent extends Event
* WorldEvent.Load is fired when Minecraft loads a world.<br>
* This event is fired when a world is loaded in
* WorldClient#WorldClient(NetHandlerPlayClient, WorldSettings, int, EnumDifficulty, Profiler),
* MinecraftServer#loadAllWorlds(String, String, long, WorldType, String),
* DimensionManager#initDimension(int),
* MinecraftServer#loadAllWorlds(String, String, long, WorldType, String),
* DimensionManager#initDimension(int),
* and ForgeInternalHandler#onDimensionLoad(Load). <br>
* <br>
* This event is not {@link Cancelable}.<br>
@@ -49,10 +49,10 @@ public class WorldEvent extends Event
/**
* WorldEvent.Unload is fired when Minecraft unloads a world.<br>
* This event is fired when a world is unloaded in
* Minecraft#loadWorld(WorldClient, String),
* MinecraftServer#deleteWorldAndStopServer(),
* MinecraftServer#stopServer(),
* DimensionManager#unloadWorlds(Hashtable<Integer, long[]>),
* Minecraft#loadWorld(WorldClient, String),
* MinecraftServer#deleteWorldAndStopServer(),
* MinecraftServer#stopServer(),
* DimensionManager#unloadWorlds(Hashtable<Integer, long[]>),
* ForgeInternalHandler#onDimensionUnload(Unload). <br>
* <br>
* This event is not {@link Cancelable}.<br>
@@ -69,7 +69,7 @@ public class WorldEvent extends Event
/**
* WorldEvent.Save is fired when Minecraft saves a world.<br>
* This event is fired when a world is saved in
* WorldServer#saveAllChunks(boolean, IProgressUpdate),
* WorldServer#saveAllChunks(boolean, IProgressUpdate),
* ForgeInternalHandler#onDimensionSave(Save). <br>
* <br>
* This event is not {@link Cancelable}.<br>
@@ -91,17 +91,13 @@ public class WorldEvent extends Event
public static class PotentialSpawns extends WorldEvent
{
public final EnumCreatureType type;
public final int x;
public final int y;
public final int z;
public final BlockPos pos;
public final List<SpawnListEntry> list;
public PotentialSpawns(World world, EnumCreatureType type, int x, int y, int z, List<SpawnListEntry> oldList)
public PotentialSpawns(World world, EnumCreatureType type, BlockPos pos, List<SpawnListEntry> oldList)
{
super(world);
this.x = x;
this.y = y;
this.z = z;
this.pos = pos;
this.type = type;
if (oldList != null)
{