Removed RenderWorldEvent, encapsulated all public event fields.

This commit is contained in:
RainWarrior committed 2016-03-24 22:22:21 +03:00
1 parent 08c00662a0
commit 756c58d5cb
110 files changed
+1642 -680

No files matched your search

@@ -14,19 +14,29 @@ import net.minecraft.item.ItemStack;
@Cancelable
public class AnvilUpdateEvent extends Event
{
public final ItemStack left; // The left side of the input
public final ItemStack right; // The right side of the input
public final String name; // The name to set the item, if the user specified one.
public ItemStack output; // Set this to set the output stack
public int cost; // The base cost, set this to change it if output != null
public int materialCost; // The number of items from the right slot to be consumed during the repair. Leave as 0 to consume the entire stack.
private final ItemStack left; // The left side of the input
private final ItemStack right; // The right side of the input
private final String name; // The name to set the item, if the user specified one.
private ItemStack output; // Set this to set the output stack
private int cost; // The base cost, set this to change it if output != null
private int materialCost; // The number of items from the right slot to be consumed during the repair. Leave as 0 to consume the entire stack.
public AnvilUpdateEvent(ItemStack left, ItemStack right, String name, int cost)
{
this.left = left;
this.right = right;
this.name = name;
this.cost = cost;
this.materialCost = 0;
this.setCost(cost);
this.setMaterialCost(0);
}
public ItemStack getLeft() { return left; }
public ItemStack getRight() { return right; }
public String getName() { return name; }
public ItemStack getOutput() { return output; }
public void setOutput(ItemStack output) { this.output = output; }
public int getCost() { return cost; }
public void setCost(int cost) { this.cost = cost; }
public int getMaterialCost() { return materialCost; }
public void setMaterialCost(int materialCost) { this.materialCost = materialCost; }
}
@@ -26,15 +26,22 @@ import net.minecraft.command.ICommandSender;
public class CommandEvent extends Event
{
public final ICommand command;
public final ICommandSender sender;
public String[] parameters;
public Throwable exception;
private final ICommand command;
private final ICommandSender sender;
private String[] parameters;
private Throwable exception;
public CommandEvent(ICommand command, ICommandSender sender, String[] parameters)
{
this.command = command;
this.sender = sender;
this.parameters = parameters;
this.setParameters(parameters);
}
public ICommand getCommand() { return command; }
public ICommandSender getSender() { return sender; }
public String[] getParameters() { return parameters; }
public void setParameters(String[] parameters) { this.parameters = parameters; }
public Throwable getException() { return exception; }
public void setException(Throwable exception) { this.exception = exception; }
}
@@ -125,7 +125,7 @@ public class ForgeEventFactory
public static float getBreakSpeed(EntityPlayer player, IBlockState state, float original, BlockPos pos)
{
PlayerEvent.BreakSpeed event = new PlayerEvent.BreakSpeed(player, state, original, pos);
return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.newSpeed);
return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getNewSpeed());
}
@Deprecated
@@ -182,28 +182,28 @@ public class ForgeEventFactory
{
return null;
}
return event.list;
return event.getList();
}
public static int getMaxSpawnPackSize(EntityLiving entity)
{
LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity);
MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent);
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.maxPackSize : entity.getMaxSpawnedInChunk();
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.getMaxPackSize() : entity.getMaxSpawnedInChunk();
}
public static String getPlayerDisplayName(EntityPlayer player, String username)
{
PlayerEvent.NameFormat event = new PlayerEvent.NameFormat(player, username);
MinecraftForge.EVENT_BUS.post(event);
return event.displayname;
return event.getDisplayname();
}
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(world, pos, state, fortune, dropChance, drops, player, silkTouch);
MinecraftForge.EVENT_BUS.post(event);
return event.dropChance;
return event.getDropChance();
}
public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, EntityPlayer entityPlayer, List<String> toolTip, boolean showAdvancedItemTooltips)
@@ -228,13 +228,13 @@ public class ForgeEventFactory
public static int onItemUseStart(EntityLivingBase entity, ItemStack item, int duration)
{
LivingEntityUseItemEvent event = new LivingEntityUseItemEvent.Start(entity, item, duration);
return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.duration;
return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getDuration();
}
public static int onItemUseTick(EntityLivingBase entity, ItemStack item, int duration)
{
LivingEntityUseItemEvent event = new LivingEntityUseItemEvent.Tick(entity, item, duration);
return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.duration;
return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getDuration();
}
public static boolean onUseItemStop(EntityLivingBase entity, ItemStack item, int duration)
@@ -246,7 +246,7 @@ public class ForgeEventFactory
{
LivingEntityUseItemEvent.Finish event = new LivingEntityUseItemEvent.Finish(entity, item, duration, result);
MinecraftForge.EVENT_BUS.post(event);
return event.result;
return event.getResultStack();
}
public static void onStartEntityTracking(Entity entity, EntityPlayer player)
@@ -279,7 +279,7 @@ public class ForgeEventFactory
public static ITextComponent onClientChat(byte type, ITextComponent message)
{
ClientChatReceivedEvent event = new ClientChatReceivedEvent(type, message);
return MinecraftForge.EVENT_BUS.post(event) ? null : event.message;
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage();
}
public static int onHoeUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos)
@@ -332,7 +332,7 @@ public class ForgeEventFactory
{
EntityEvent.CanUpdate event = new EntityEvent.CanUpdate(entity);
MinecraftForge.EVENT_BUS.post(event);
return event.canUpdate;
return event.getCanUpdate();
}
public static PlaySoundAtEntityEvent onPlaySoundAtEntity(Entity entity, SoundEvent name, SoundCategory category, float volume, float pitch)
@@ -347,7 +347,7 @@ public class ForgeEventFactory
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;
return event.getExtraLife();
}
public static int onItemPickup(EntityItem entityItem, EntityPlayer entityIn, ItemStack itemstack)
@@ -391,7 +391,7 @@ public class ForgeEventFactory
{
PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(player, pos);
MinecraftForge.EVENT_BUS.post(event);
return event.result;
return event.getResultStatus();
}
public static void onPlayerWakeup(EntityPlayer player, boolean wakeImmediately, boolean updateWorldFlag, boolean setSpawn)
@@ -442,7 +442,7 @@ public class ForgeEventFactory
public static float onLivingHeal(EntityLivingBase entity, float amount)
{
LivingHealEvent event = new LivingHealEvent(entity, amount);
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.amount);
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount());
}
public static boolean onPotionAttemptBrew(ItemStack[] stacks)
@@ -73,8 +73,7 @@ public class PotionBrewEvent extends Event
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
@SuppressWarnings("deprecation")
public static class Post extends PotionBrewedEvent
public static class Post extends PotionBrewEvent
{
public Post(ItemStack[] stacks)
{
@@ -1,32 +0,0 @@
package net.minecraftforge.event.brewing;
import net.minecraft.item.ItemStack;
/**
* PotionBrewedEvent is fired when a potion is brewed in the brewing stand.
* <br>
* The event is fired during the TileEntityBrewingStand#brewPotions() method invocation.<br>
* <br>
* {@link #brewingStacks} contains the itemstack array from the TileEntityBrewer holding all items in Brewer.<br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
@Deprecated // remove in 1.9
public class PotionBrewedEvent extends PotionBrewEvent
{
/**
* The brewing stacks in the brewing stand. Each index has the possibility to be null, so make sure you check.
* Changing this array to another one has no effect.
*/
@Deprecated
public ItemStack[] brewingStacks;
public PotionBrewedEvent(ItemStack[] brewingStacks)
{
super(brewingStacks);
this.brewingStacks = brewingStacks;
}
}
@@ -14,13 +14,18 @@ import net.minecraft.entity.Entity;
**/
public class EntityEvent extends Event
{
public final Entity entity;
private final Entity entity;
public EntityEvent(Entity entity)
{
this.entity = entity;
}
public Entity getEntity()
{
return entity;
}
/**
* EntityConstructing is fired when an Entity is being created. <br>
* This event is fired within the constructor of the Entity.<br>
@@ -54,11 +59,21 @@ public class EntityEvent extends Event
**/
public static class CanUpdate extends EntityEvent
{
public boolean canUpdate = false;
private boolean canUpdate = false;
public CanUpdate(Entity entity)
{
super(entity);
}
public boolean getCanUpdate()
{
return canUpdate;
}
public void setCanUpdate(boolean canUpdate)
{
this.canUpdate = canUpdate;
}
}
/**
@@ -74,18 +89,27 @@ public class EntityEvent extends Event
**/
public static class EnteringChunk extends EntityEvent
{
public int newChunkX;
public int newChunkZ;
public int oldChunkX;
public int oldChunkZ;
private int newChunkX;
private int newChunkZ;
private int oldChunkX;
private int oldChunkZ;
public EnteringChunk(Entity entity, int newChunkX, int newChunkZ, int oldChunkX, int oldChunkZ)
{
super(entity);
this.newChunkX = newChunkX;
this.newChunkZ = newChunkZ;
this.oldChunkX = oldChunkX;
this.oldChunkZ = oldChunkZ;
this.setNewChunkX(newChunkX);
this.setNewChunkZ(newChunkZ);
this.setOldChunkX(oldChunkX);
this.setOldChunkZ(oldChunkZ);
}
public int getNewChunkX() { return newChunkX; }
public void setNewChunkX(int newChunkX) { this.newChunkX = newChunkX; }
public int getNewChunkZ() { return newChunkZ; }
public void setNewChunkZ(int newChunkZ) { this.newChunkZ = newChunkZ; }
public int getOldChunkX() { return oldChunkX; }
public void setOldChunkX(int oldChunkX) { this.oldChunkX = oldChunkX; }
public int getOldChunkZ() { return oldChunkZ; }
public void setOldChunkZ(int oldChunkZ) { this.oldChunkZ = oldChunkZ; }
}
}
@@ -22,11 +22,16 @@ import net.minecraft.world.World;
public class EntityJoinWorldEvent extends EntityEvent
{
public final World world;
private final World world;
public EntityJoinWorldEvent(Entity entity, World world)
{
super(entity);
this.world = world;
}
public World getWorld()
{
return world;
}
}
@@ -23,9 +23,9 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
public class EntityMountEvent extends EntityEvent
{
public final Entity entityMounting;
public final Entity entityBeingMounted;
public final World worldObj;
private final Entity entityMounting;
private final Entity entityBeingMounted;
private final World worldObj;
private final boolean isMounting;
@@ -48,4 +48,18 @@ public class EntityMountEvent extends EntityEvent
return !isMounting;
}
public Entity getEntityMounting()
{
return entityMounting;
}
public Entity getEntityBeingMounted()
{
return entityBeingMounted;
}
public World getWorldObj()
{
return worldObj;
}
}
@@ -21,11 +21,16 @@ import net.minecraft.entity.effect.EntityLightningBolt;
@Cancelable
public class EntityStruckByLightningEvent extends EntityEvent
{
public final EntityLightningBolt lightning;
private final EntityLightningBolt lightning;
public EntityStruckByLightningEvent(Entity entity, EntityLightningBolt lightning)
{
super(entity);
this.lightning = lightning;
}
public EntityLightningBolt getLightning()
{
return lightning;
}
}
@@ -19,11 +19,16 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
@Cancelable
public class EntityTravelToDimensionEvent extends EntityEvent
{
public final int dimension;
private final int dimension;
public EntityTravelToDimensionEvent(Entity entity, int dimension)
{
super(entity);
this.dimension = dimension;
}
public int getDimension()
{
return dimension;
}
}
@@ -11,10 +11,7 @@ import net.minecraftforge.event.entity.EntityEvent;
*/
public class ItemEvent extends EntityEvent
{
/**
* The relevant EntityItem for this event, already cast for you.
*/
public final EntityItem entityItem;
private final EntityItem entityItem;
/**
* Creates a new event for an EntityItem.
@@ -26,4 +23,12 @@ public class ItemEvent extends EntityEvent
super(itemEntity);
this.entityItem = itemEntity;
}
/**
* The relevant EntityItem for this event, already cast for you.
*/
public EntityItem getEntityItem()
{
return entityItem;
}
}
@@ -13,7 +13,7 @@ import net.minecraft.entity.item.EntityItem;
public class ItemExpireEvent extends ItemEvent
{
public int extraLife;
private int extraLife;
/**
* Creates a new event for an expiring EntityItem.
@@ -24,6 +24,16 @@ public class ItemExpireEvent extends ItemEvent
public ItemExpireEvent(EntityItem entityItem, int extraLife)
{
super(entityItem);
this.setExtraLife(extraLife);
}
public int getExtraLife()
{
return extraLife;
}
public void setExtraLife(int extraLife)
{
this.extraLife = extraLife;
}
}
@@ -14,10 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
public class ItemTossEvent extends ItemEvent
{
/**
* The player tossing the item.
*/
public final EntityPlayer player;
private final EntityPlayer player;
/**
* Creates a new event for EntityItems tossed by a player.
@@ -30,4 +27,12 @@ public class ItemTossEvent extends ItemEvent
super(entityItem);
this.player = player;
}
/**
* The player tossing the item.
*/
public EntityPlayer getPlayer()
{
return player;
}
}
@@ -12,17 +12,26 @@ import net.minecraft.entity.EntityLivingBase;
public class EnderTeleportEvent extends LivingEvent
{
public double targetX;
public double targetY;
public double targetZ;
public float attackDamage;
private double targetX;
private double targetY;
private double targetZ;
private float attackDamage;
public EnderTeleportEvent(EntityLivingBase entity, double targetX, double targetY, double targetZ, float attackDamage)
{
super(entity);
this.targetX = targetX;
this.targetY = targetY;
this.targetZ = targetZ;
this.attackDamage = attackDamage;
this.setTargetX(targetX);
this.setTargetY(targetY);
this.setTargetZ(targetZ);
this.setAttackDamage(attackDamage);
}
public double getTargetX() { return targetX; }
public void setTargetX(double targetX) { this.targetX = targetX; }
public double getTargetY() { return targetY; }
public void setTargetY(double targetY) { this.targetY = targetY; }
public double getTargetZ() { return targetZ; }
public void setTargetZ(double targetZ) { this.targetZ = targetZ; }
public float getAttackDamage() { return attackDamage; }
public void setAttackDamage(float attackDamage) { this.attackDamage = attackDamage; }
}
@@ -25,10 +25,15 @@ import net.minecraft.entity.EntityLivingBase;
@Cancelable
public class LivingDeathEvent extends LivingEvent
{
public final DamageSource source;
private final DamageSource source;
public LivingDeathEvent(EntityLivingBase entity, DamageSource source)
{
super(entity);
this.source = source;
}
public DamageSource getSource()
{
return source;
}
}
@@ -29,10 +29,10 @@ import net.minecraft.entity.EntityLivingBase;
@Cancelable
public class LivingDropsEvent extends LivingEvent
{
public final DamageSource source;
public final List<EntityItem> drops;
public final int lootingLevel;
public final boolean recentlyHit;
private final DamageSource source;
private final List<EntityItem> drops;
private final int lootingLevel;
private final boolean recentlyHit;
public LivingDropsEvent(EntityLivingBase entity, DamageSource source, List<EntityItem> drops, int lootingLevel, boolean recentlyHit)
{
@@ -42,4 +42,24 @@ public class LivingDropsEvent extends LivingEvent
this.lootingLevel = lootingLevel;
this.recentlyHit = recentlyHit;
}
public DamageSource getSource()
{
return source;
}
public List<EntityItem> getDrops()
{
return drops;
}
public int getLootingLevel()
{
return lootingLevel;
}
public boolean isRecentlyHit()
{
return recentlyHit;
}
}
@@ -6,13 +6,28 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
public abstract class LivingEntityUseItemEvent extends LivingEvent
{
public final ItemStack item;
public int duration;
private final ItemStack item;
private int duration;
private LivingEntityUseItemEvent(EntityLivingBase entity, ItemStack item, int duration)
{
super(entity);
this.item = item;
this.setDuration(duration);
}
public ItemStack getItem()
{
return item;
}
public int getDuration()
{
return duration;
}
public void setDuration(int duration)
{
this.duration = duration;
}
@@ -84,10 +99,20 @@ public abstract class LivingEntityUseItemEvent extends LivingEvent
*/
public static class Finish extends LivingEntityUseItemEvent
{
public ItemStack result;
private ItemStack result;
public Finish(EntityLivingBase entity, ItemStack item, int duration, ItemStack result)
{
super(entity, item, duration);
this.setResultStack(result);
}
public ItemStack getResultStack()
{
return result;
}
public void setResultStack(ItemStack result)
{
this.result = result;
}
}
@@ -13,13 +13,18 @@ import net.minecraftforge.event.entity.EntityEvent;
**/
public class LivingEvent extends EntityEvent
{
public final EntityLivingBase entityLiving;
private final EntityLivingBase entityLiving;
public LivingEvent(EntityLivingBase entity)
{
super(entity);
entityLiving = entity;
}
public EntityLivingBase getEntityLiving()
{
return entityLiving;
}
/**
* LivingUpdateEvent is fired when an Entity is updated. <br>
* This event is fired whenever an Entity is updated in
@@ -12,10 +12,10 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
@Cancelable
public class LivingExperienceDropEvent extends LivingEvent
{
final EntityPlayer attackingPlayer;
final int originalExperiencePoints;
private final EntityPlayer attackingPlayer;
private final int originalExperiencePoints;
int droppedExperiencePoints;
private int droppedExperiencePoints;
public LivingExperienceDropEvent(EntityLivingBase entity, EntityPlayer attackingPlayer, int originalExperience)
{
@@ -22,12 +22,17 @@ import net.minecraft.entity.EntityLivingBase;
@Cancelable
public class LivingFallEvent extends LivingEvent
{
public float distance;
public float damageMultiplier;
private float distance;
private float damageMultiplier;
public LivingFallEvent(EntityLivingBase entity, float distance, float damageMultiplier)
{
super(entity);
this.distance = distance;
this.damageMultiplier = damageMultiplier;
this.setDistance(distance);
this.setDamageMultiplier(damageMultiplier);
}
public float getDistance() { return distance; }
public void setDistance(float distance) { this.distance = distance; }
public float getDamageMultiplier() { return damageMultiplier; }
public void setDamageMultiplier(float damageMultiplier) { this.damageMultiplier = damageMultiplier; }
}
@@ -21,10 +21,20 @@ import net.minecraft.entity.EntityLivingBase;
@Cancelable
public class LivingHealEvent extends LivingEvent
{
public float amount;
private float amount;
public LivingHealEvent(EntityLivingBase entity, float amount)
{
super(entity);
this.setAmount(amount);
}
public float getAmount()
{
return amount;
}
public void setAmount(float amount)
{
this.amount = amount;
}
}
@@ -6,18 +6,28 @@ import net.minecraft.entity.EntityLiving;
@HasResult
public class LivingPackSizeEvent extends LivingEvent
{
/**
* This event is fired when the spawning system determines the
* maximum amount of the selected entity that can spawn at the same
* time.
*
* If you set the result to 'ALLOW', it means that you want to return
* the value of maxPackSize as the maximum pack size for current entity.
*/
public int maxPackSize;
private int maxPackSize;
public LivingPackSizeEvent(EntityLiving entity)
{
super(entity);
}
/**
* This event is fired when the spawning system determines the
* maximum amount of the selected entity that can spawn at the same
* time.
*
* If you set the result to 'ALLOW', it means that you want to return
* the value of maxPackSize as the maximum pack size for current entity.
*/
public int getMaxPackSize()
{
return maxPackSize;
}
public void setMaxPackSize(int maxPackSize)
{
this.maxPackSize = maxPackSize;
}
}
@@ -21,11 +21,15 @@ import net.minecraft.entity.EntityLivingBase;
public class LivingSetAttackTargetEvent extends LivingEvent
{
public final EntityLivingBase target;
private final EntityLivingBase target;
public LivingSetAttackTargetEvent(EntityLivingBase entity, EntityLivingBase target)
{
super(entity);
this.target = target;
}
public EntityLivingBase getTarget()
{
return target;
}
}
@@ -19,10 +19,10 @@ import net.minecraft.world.World;
**/
public class LivingSpawnEvent extends LivingEvent
{
public final World world;
public final float x;
public final float y;
public final float z;
private final World world;
private final float x;
private final float y;
private final float z;
public LivingSpawnEvent(EntityLiving entity, World world, float x, float y, float z)
{
@@ -33,6 +33,10 @@ public class LivingSpawnEvent extends LivingEvent
this.z = z;
}
public World getWorld() { return world; }
public float getX() { return x; }
public float getY() { return y; }
public float getZ() { return z; }
/**
* Fires before mob spawn events.
*
@@ -1,6 +1,5 @@
package net.minecraftforge.event.entity.living;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.world.World;
@@ -22,7 +21,7 @@ public class ZombieEvent extends EntityEvent {
public EntityZombie getSummoner()
{
return (EntityZombie) entity;
return (EntityZombie) getEntity();
}
/**
@@ -50,17 +49,14 @@ public class ZombieEvent extends EntityEvent {
**/
@HasResult
public static class SummonAidEvent extends ZombieEvent {
/**
* Populate this field to have a custom zombie instead of a normal zombie summoned
*/
public EntityZombie customSummonedAid;
private EntityZombie customSummonedAid;
public final World world;
public final int x;
public final int y;
public final int z;
public final EntityLivingBase attacker;
public final double summonChance;
private final World world;
private final int x;
private final int y;
private final int z;
private final EntityLivingBase attacker;
private final double summonChance;
public SummonAidEvent(EntityZombie entity, World world, int x, int y, int z, EntityLivingBase attacker, double summonChance)
{
@@ -72,6 +68,17 @@ public class ZombieEvent extends EntityEvent {
this.attacker = attacker;
this.summonChance = summonChance;
}
/**
* Populate this field to have a custom zombie instead of a normal zombie summoned
*/
public EntityZombie getCustomSummonedAid() { return customSummonedAid; }
public void setCustomSummonedAid(EntityZombie customSummonedAid) { this.customSummonedAid = customSummonedAid; }
public World getWorld() { return world; }
public int getX() { return x; }
public int getY() { return y; }
public int getZ() { return z; }
public EntityLivingBase getAttacker() { return attacker; }
public double getSummonChance() { return summonChance; }
}
}
@@ -18,11 +18,16 @@ import net.minecraft.entity.item.EntityMinecart;
**/
public class MinecartCollisionEvent extends MinecartEvent
{
public final Entity collider;
private final Entity collider;
public MinecartCollisionEvent(EntityMinecart minecart, Entity collider)
{
super(minecart);
this.collider = collider;
}
public Entity getCollider()
{
return collider;
}
}
@@ -14,11 +14,16 @@ import net.minecraftforge.event.entity.EntityEvent;
**/
public class MinecartEvent extends EntityEvent
{
public final EntityMinecart minecart;
private final EntityMinecart minecart;
public MinecartEvent(EntityMinecart minecart)
{
super(minecart);
this.minecart = minecart;
}
public EntityMinecart getMinecart()
{
return minecart;
}
}
@@ -18,11 +18,16 @@ import net.minecraft.util.math.BlockPos;
**/
public class MinecartUpdateEvent extends MinecartEvent
{
public final BlockPos pos;
private final BlockPos pos;
public MinecartUpdateEvent(EntityMinecart minecart, BlockPos pos)
{
super(minecart);
this.pos = pos;
}
public BlockPos getPos()
{
return pos;
}
}
@@ -10,10 +10,15 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
@Cancelable
public class AchievementEvent extends PlayerEvent {
public final Achievement achievement;
private final Achievement achievement;
public AchievementEvent(EntityPlayer player, Achievement achievement)
{
super(player);
this.achievement = achievement;
}
public Achievement getAchievement()
{
return achievement;
}
}
@@ -5,18 +5,11 @@ import net.minecraft.item.ItemStack;
public class AnvilRepairEvent extends PlayerEvent
{
/**
* Fired when the player removes a "repaired" item from the Anvil's Output slot.
*
* breakChance specifies as a percentage the chance that the anvil will be "damaged" when used.
*
* ItemStacks are the inputs/output from the anvil. They cannot be edited.
*/
public final ItemStack left; // The left side of the input
public final ItemStack right; // The right side of the input
public final ItemStack output; // Set this to set the output stack
public float breakChance; // Anvil's chance to break (reduced by 1 durability) when this is complete. Default is 12% (0.12f)
private final ItemStack left; // The left side of the input
private final ItemStack right; // The right side of the input
private final ItemStack output; // Set this to set the output stack
private float breakChance; // Anvil's chance to break (reduced by 1 durability) when this is complete. Default is 12% (0.12f)
public AnvilRepairEvent(EntityPlayer player, ItemStack output, ItemStack left, ItemStack right)
{
@@ -24,6 +17,19 @@ public class AnvilRepairEvent extends PlayerEvent
this.output = output;
this.left = left;
this.right = right;
this.breakChance = 0.12f;
this.setBreakChance(0.12f);
}
/**
* Fired when the player removes a "repaired" item from the Anvil's Output slot.
*
* breakChance specifies as a percentage the chance that the anvil will be "damaged" when used.
*
* ItemStacks are the inputs/output from the anvil. They cannot be edited.
*/
public ItemStack getLeft() { return left; }
public ItemStack getRight() { return right; }
public ItemStack getOutput() { return output; }
public float getBreakChance() { return breakChance; }
public void setBreakChance(float breakChance) { this.breakChance = breakChance; }
}
@@ -21,10 +21,15 @@ import net.minecraft.entity.player.EntityPlayer;
@Cancelable
public class AttackEntityEvent extends PlayerEvent
{
public final Entity target;
private final Entity target;
public AttackEntityEvent(EntityPlayer player, Entity target)
{
super(player);
this.target = target;
}
public Entity getTarget()
{
return target;
}
}
@@ -7,23 +7,23 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
* 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
* and use up a bonemeal from the stack but do no further processing.
*
* setResult(ALLOW) is the same as the old setHandled()
*/
@Cancelable
@Event.HasResult
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
* and use up a bonemeal from the stack but do no further processing.
*
* setResult(ALLOW) is the same as the old setHandled()
*/
public final World world;
public final BlockPos pos;
public final IBlockState block;
private final World world;
private final BlockPos pos;
private final IBlockState block;
public BonemealEvent(EntityPlayer player, World world, BlockPos pos, IBlockState block)
{
@@ -32,4 +32,19 @@ public class BonemealEvent extends PlayerEvent
this.pos = pos;
this.block = block;
}
public World getWorld()
{
return world;
}
public BlockPos getPos()
{
return pos;
}
public IBlockState getBlock()
{
return block;
}
}
@@ -5,25 +5,30 @@ import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
/**
* This event is called when a player collides with a EntityItem on the ground.
* The event can be canceled, and no further processing will be done.
*
* You can set the result of this event to ALLOW which will trigger the
* processing of achievements, FML's event, play the sound, and kill the
* entity if all the items are picked up.
*
* setResult(ALLOW) is the same as the old setHandled()
*/
@Cancelable
@Event.HasResult
public class EntityItemPickupEvent extends PlayerEvent
{
/**
* This event is called when a player collides with a EntityItem on the ground.
* The event can be canceled, and no further processing will be done.
*
* You can set the result of this event to ALLOW which will trigger the
* processing of achievements, FML's event, play the sound, and kill the
* entity if all the items are picked up.
*
* setResult(ALLOW) is the same as the old setHandled()
*/
public final EntityItem item;
private final EntityItem item;
public EntityItemPickupEvent(EntityPlayer player, EntityItem item)
{
super(player);
this.item = item;
}
public EntityItem getItem()
{
return item;
}
}
@@ -7,19 +7,19 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
/**
* This event is fired when a player attempts to use a Empty bucket, it
* can be canceled to completely prevent any further processing.
*
* If you set the result to 'ALLOW', it means that you have processed
* the event and wants the basic functionality of adding the new
* ItemStack to your inventory and reducing the stack size to process.
* setResult(ALLOW) is the same as the old setHandled();
*/
@Cancelable
@Event.HasResult
public class FillBucketEvent extends PlayerEvent
{
/**
* This event is fired when a player attempts to use a Empty bucket, it
* can be canceled to completely prevent any further processing.
*
* If you set the result to 'ALLOW', it means that you have processed
* the event and wants the basic functionality of adding the new
* ItemStack to your inventory and reducing the stack size to process.
* setResult(ALLOW) is the same as the old setHandled();
*/
private final ItemStack current;
private final World world;
@@ -6,18 +6,9 @@ import net.minecraft.item.ItemStack;
public class ItemTooltipEvent extends PlayerEvent
{
/**
* Whether the advanced information on item tooltips is being shown, toggled by F3+H.
*/
public final boolean showAdvancedItemTooltips;
/**
* The {@link ItemStack} with the tooltip.
*/
public final ItemStack itemStack;
/**
* The {@link ItemStack} tooltip.
*/
public final List<String> toolTip;
private final boolean showAdvancedItemTooltips;
private final ItemStack itemStack;
private final List<String> toolTip;
/**
* This event is fired in {@link ItemStack#getTooltip(EntityPlayer, boolean)}, which in turn is called from it's respective GUIContainer.
@@ -29,4 +20,28 @@ public class ItemTooltipEvent extends PlayerEvent
this.toolTip = toolTip;
this.showAdvancedItemTooltips = showAdvancedItemTooltips;
}
/**
* Whether the advanced information on item tooltips is being shown, toggled by F3+H.
*/
public boolean isShowAdvancedItemTooltips()
{
return showAdvancedItemTooltips;
}
/**
* The {@link ItemStack} with the tooltip.
*/
public ItemStack getItemStack()
{
return itemStack;
}
/**
* The {@link ItemStack} tooltip.
*/
public List<String> getToolTip()
{
return toolTip;
}
}
@@ -18,7 +18,7 @@ import net.minecraftforge.event.entity.living.LivingDropsEvent;
@Cancelable
public class PlayerDropsEvent extends LivingDropsEvent
{
public final EntityPlayer entityPlayer;
private final EntityPlayer entityPlayer;
/**
* Creates a new event containing all the items that will drop into the
@@ -36,4 +36,9 @@ public class PlayerDropsEvent extends LivingDropsEvent
this.entityPlayer = entity;
}
public EntityPlayer getEntityPlayer()
{
return entityPlayer;
}
}
@@ -18,13 +18,18 @@ import net.minecraftforge.event.entity.living.LivingEvent;
**/
public class PlayerEvent extends LivingEvent
{
public final EntityPlayer entityPlayer;
private final EntityPlayer entityPlayer;
public PlayerEvent(EntityPlayer player)
{
super(player);
entityPlayer = player;
}
public EntityPlayer getEntityPlayer()
{
return entityPlayer;
}
/**
* 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
@@ -80,19 +85,25 @@ public class PlayerEvent extends LivingEvent
@Cancelable
public static class BreakSpeed extends PlayerEvent
{
public final IBlockState state;
public final float originalSpeed;
public float newSpeed = 0.0f;
public final BlockPos pos; // Y position of -1 notes unknown location
private final IBlockState state;
private final float originalSpeed;
private float newSpeed = 0.0f;
private final BlockPos pos; // Y position of -1 notes unknown location
public BreakSpeed(EntityPlayer player, IBlockState state, float original, BlockPos pos)
{
super(player);
this.state = state;
this.originalSpeed = original;
this.newSpeed = original;
this.setNewSpeed(original);
this.pos = pos;
}
public IBlockState getState() { return state; }
public float getOriginalSpeed() { return originalSpeed; }
public float getNewSpeed() { return newSpeed; }
public void setNewSpeed(float newSpeed) { this.newSpeed = newSpeed; }
public BlockPos getPos() { return pos; }
}
/**
@@ -113,13 +124,28 @@ public class PlayerEvent extends LivingEvent
**/
public static class NameFormat extends PlayerEvent
{
public final String username;
public String displayname;
private final String username;
private String displayname;
public NameFormat(EntityPlayer player, String username) {
super(player);
this.username = username;
this.displayname = username;
this.setDisplayname(username);
}
public String getUsername()
{
return username;
}
public String getDisplayname()
{
return displayname;
}
public void setDisplayname(String displayname)
{
this.displayname = displayname;
}
}
@@ -129,15 +155,8 @@ public class PlayerEvent extends LivingEvent
*/
public static class Clone extends PlayerEvent
{
/**
* The old EntityPlayer that this new entity is a clone of.
*/
public final EntityPlayer original;
/**
* True if this event was fired because the player died.
* False if it was fired because the entity switched dimensions.
*/
public final boolean wasDeath;
private final EntityPlayer original;
private final boolean wasDeath;
public Clone(EntityPlayer _new, EntityPlayer oldPlayer, boolean wasDeath)
{
@@ -145,6 +164,23 @@ public class PlayerEvent extends LivingEvent
this.original = oldPlayer;
this.wasDeath = wasDeath;
}
/**
* The old EntityPlayer that this new entity is a clone of.
*/
public EntityPlayer getOriginal()
{
return original;
}
/**
* True if this event was fired because the player died.
* False if it was fired because the entity switched dimensions.
*/
public boolean isWasDeath()
{
return wasDeath;
}
}
/**
@@ -153,10 +189,7 @@ public class PlayerEvent extends LivingEvent
*/
public static class StartTracking extends PlayerEvent {
/**
* The Entity now being tracked.
*/
public final Entity target;
private final Entity target;
public StartTracking(EntityPlayer player, Entity target)
{
@@ -164,6 +197,13 @@ public class PlayerEvent extends LivingEvent
this.target = target;
}
/**
* The Entity now being tracked.
*/
public Entity getTarget()
{
return target;
}
}
/**
@@ -172,10 +212,7 @@ public class PlayerEvent extends LivingEvent
*/
public static class StopTracking extends PlayerEvent {
/**
* The Entity no longer being tracked.
*/
public final Entity target;
private final Entity target;
public StopTracking(EntityPlayer player, Entity target)
{
@@ -183,6 +220,13 @@ public class PlayerEvent extends LivingEvent
this.target = target;
}
/**
* The Entity no longer being tracked.
*/
public Entity getTarget()
{
return target;
}
}
/**
@@ -192,16 +236,8 @@ public class PlayerEvent extends LivingEvent
* containing additional mod related player data.
*/
public static class LoadFromFile extends PlayerEvent {
/**
* The directory where player data is being stored. Use this
* to locate your mod additional file.
*/
public final File playerDirectory;
/**
* The UUID is the standard for player related file storage.
* It is broken out here for convenience for quick file generation.
*/
public final String playerUUID;
private final File playerDirectory;
private final String playerUUID;
public LoadFromFile(EntityPlayer player, File originDirectory, String playerUUID)
{
@@ -218,7 +254,25 @@ public class PlayerEvent extends LivingEvent
public File getPlayerFile(String suffix)
{
if ("dat".equals(suffix)) throw new IllegalArgumentException("The suffix 'dat' is reserved");
return new File(this.playerDirectory, this.playerUUID+"."+suffix);
return new File(this.getPlayerDirectory(), this.getPlayerUUID() +"."+suffix);
}
/**
* The directory where player data is being stored. Use this
* to locate your mod additional file.
*/
public File getPlayerDirectory()
{
return playerDirectory;
}
/**
* The UUID is the standard for player related file storage.
* It is broken out here for convenience for quick file generation.
*/
public String getPlayerUUID()
{
return playerUUID;
}
}
/**
@@ -235,16 +289,8 @@ public class PlayerEvent extends LivingEvent
* corrupt the world state.
*/
public static class SaveToFile extends PlayerEvent {
/**
* The directory where player data is being stored. Use this
* to locate your mod additional file.
*/
public final File playerDirectory;
/**
* The UUID is the standard for player related file storage.
* It is broken out here for convenience for quick file generation.
*/
public final String playerUUID;
private final File playerDirectory;
private final String playerUUID;
public SaveToFile(EntityPlayer player, File originDirectory, String playerUUID)
{
@@ -261,7 +307,25 @@ public class PlayerEvent extends LivingEvent
public File getPlayerFile(String suffix)
{
if ("dat".equals(suffix)) throw new IllegalArgumentException("The suffix 'dat' is reserved");
return new File(this.playerDirectory, this.playerUUID+"."+suffix);
return new File(this.getPlayerDirectory(), this.getPlayerUUID() +"."+suffix);
}
/**
* The directory where player data is being stored. Use this
* to locate your mod additional file.
*/
public File getPlayerDirectory()
{
return playerDirectory;
}
/**
* The UUID is the standard for player related file storage.
* It is broken out here for convenience for quick file generation.
*/
public String getPlayerUUID()
{
return playerUUID;
}
}
}
@@ -42,14 +42,14 @@ public class PlayerInteractEvent extends PlayerEvent
LEFT_CLICK_BLOCK
}
public final Action action;
public final World world;
public final BlockPos pos;
public final EnumFacing face; // Can be null if unknown
public final Vec3d localPos; // Can be null if unknown
private final Action action;
private final World world;
private final BlockPos pos;
private final EnumFacing face; // Can be null if unknown
private final Vec3d localPos; // Can be null if unknown
public Result useBlock = DEFAULT;
public Result useItem = DEFAULT;
private Result useBlock = DEFAULT;
private Result useItem = DEFAULT;
@Deprecated
public PlayerInteractEvent(EntityPlayer player, Action action, BlockPos pos, EnumFacing face, World world)
@@ -63,7 +63,7 @@ public class PlayerInteractEvent extends PlayerEvent
this.action = action;
this.pos = pos;
this.face = face;
if (face == null) useBlock = DENY;
if (face == null) setUseBlock(DENY);
this.world = world;
this.localPos = localPos;
}
@@ -72,7 +72,17 @@ public class PlayerInteractEvent extends PlayerEvent
public void setCanceled(boolean cancel)
{
super.setCanceled(cancel);
useBlock = (cancel ? DENY : useBlock == DENY ? DEFAULT : useBlock);
useItem = (cancel ? DENY : useItem == DENY ? DEFAULT : useItem);
setUseBlock((cancel ? DENY : getUseBlock() == DENY ? DEFAULT : getUseBlock()));
setUseItem((cancel ? DENY : getUseItem() == DENY ? DEFAULT : getUseItem()));
}
public Action getAction() { return action; }
public World getWorld() { return world; }
public BlockPos getPos() { return pos; }
public EnumFacing getFace() { return face; }
public Vec3d getLocalPos() { return localPos; }
public Result getUseBlock() { return useBlock; }
public void setUseBlock(Result useBlock) { this.useBlock = useBlock; }
public Result getUseItem() { return useItem; }
public void setUseItem(Result useItem) { this.useItem = useItem; }
}
@@ -4,26 +4,30 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
/**
* 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 behavior
*
*/
@HasResult
public class PlayerOpenContainerEvent extends PlayerEvent
{
public final boolean canInteractWith;
/**
* 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 behavior
*
*/
private final boolean canInteractWith;
public PlayerOpenContainerEvent(EntityPlayer player, Container openContainer)
{
super(player);
this.canInteractWith = openContainer.canInteractWith(player);
}
public boolean isCanInteractWith()
{
return canInteractWith;
}
}
@@ -11,11 +11,16 @@ import net.minecraft.entity.player.EntityPlayer;
@Cancelable
public class PlayerPickupXpEvent extends PlayerEvent
{
public final EntityXPOrb orb;
private final EntityXPOrb orb;
public PlayerPickupXpEvent(EntityPlayer player, EntityXPOrb orb)
{
super(player);
this.orb = orb;
}
public EntityXPOrb getOrb()
{
return orb;
}
}
@@ -7,12 +7,8 @@ import net.minecraft.util.math.BlockPos;
@Cancelable
public class PlayerSetSpawnEvent extends PlayerEvent
{
/**
* This event is called before a player's spawn point is changed.
* The event can be canceled, and no further processing will be done.
*/
public final boolean forced;
public final BlockPos newSpawn;
private final boolean forced;
private final BlockPos newSpawn;
public PlayerSetSpawnEvent(EntityPlayer player, BlockPos newSpawn, boolean forced) {
super(player);
@@ -20,4 +16,17 @@ public class PlayerSetSpawnEvent extends PlayerEvent
this.forced = forced;
}
/**
* This event is called before a player's spawn point is changed.
* The event can be canceled, and no further processing will be done.
*/
public boolean isForced()
{
return forced;
}
public BlockPos getNewSpawn()
{
return newSpawn;
}
}
@@ -20,8 +20,8 @@ import net.minecraft.util.math.BlockPos;
**/
public class PlayerSleepInBedEvent extends PlayerEvent
{
public EnumStatus result = null;
public final BlockPos pos;
private EnumStatus result = null;
private final BlockPos pos;
public PlayerSleepInBedEvent(EntityPlayer player, BlockPos pos)
{
@@ -29,4 +29,18 @@ public class PlayerSleepInBedEvent extends PlayerEvent
this.pos = pos;
}
public EnumStatus getResultStatus()
{
return result;
}
public void setResult(EnumStatus result)
{
this.result = result;
}
public BlockPos getPos()
{
return pos;
}
}
@@ -17,7 +17,7 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
public class SleepingLocationCheckEvent extends PlayerEvent
{
public final BlockPos sleepingLocation;
private final BlockPos sleepingLocation;
public SleepingLocationCheckEvent(EntityPlayer player, BlockPos sleepingLocation)
{
@@ -25,4 +25,8 @@ public class SleepingLocationCheckEvent extends PlayerEvent
this.sleepingLocation = sleepingLocation;
}
public BlockPos getSleepingLocation()
{
return sleepingLocation;
}
}
@@ -7,23 +7,23 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
/**
* 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
* and damage the hoe.
*
* setResult(ALLOW) is the same as the old setHandled();
*/
@Cancelable
@Event.HasResult
public class UseHoeEvent extends PlayerEvent
{
/**
* 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
* and damage the hoe.
*
* setResult(ALLOW) is the same as the old setHandled();
*/
public final ItemStack current;
public final World world;
public final BlockPos pos;
private final ItemStack current;
private final World world;
private final BlockPos pos;
public UseHoeEvent(EntityPlayer player, ItemStack current, World world, BlockPos pos)
{
@@ -32,4 +32,19 @@ public class UseHoeEvent extends PlayerEvent
this.world = world;
this.pos = pos;
}
public ItemStack getCurrent()
{
return current;
}
public World getWorld()
{
return world;
}
public BlockPos getPos()
{
return pos;
}
}
@@ -1,7 +1,6 @@
package net.minecraftforge.event.terraingen;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.block.state.IBlockState;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
@@ -15,13 +14,18 @@ import net.minecraft.world.biome.BiomeGenBase;
**/
public class BiomeEvent extends Event
{
public final BiomeGenBase biome;
private final BiomeGenBase biome;
public BiomeEvent(BiomeGenBase biome)
{
this.biome = biome;
}
public BiomeGenBase getBiome()
{
return biome;
}
/**
* CreateDecorator is fired when a BiomeDecorator is created.<br>
* This event is fired whenever a BiomeDecorator is created in
@@ -38,14 +42,29 @@ public class BiomeEvent extends Event
**/
public static class CreateDecorator extends BiomeEvent
{
public final BiomeDecorator originalBiomeDecorator;
public BiomeDecorator newBiomeDecorator;
private final BiomeDecorator originalBiomeDecorator;
private BiomeDecorator newBiomeDecorator;
public CreateDecorator(BiomeGenBase biome, BiomeDecorator original)
{
super(biome);
originalBiomeDecorator = original;
newBiomeDecorator = original;
setNewBiomeDecorator(original);
}
public BiomeDecorator getOriginalBiomeDecorator()
{
return originalBiomeDecorator;
}
public BiomeDecorator getNewBiomeDecorator()
{
return newBiomeDecorator;
}
public void setNewBiomeDecorator(BiomeDecorator newBiomeDecorator)
{
this.newBiomeDecorator = newBiomeDecorator;
}
}
@@ -58,14 +77,29 @@ public class BiomeEvent extends Event
**/
public static class BiomeColor extends BiomeEvent
{
public final int originalColor;
public int newColor;
private final int originalColor;
private int newColor;
public BiomeColor(BiomeGenBase biome, int original)
{
super(biome);
originalColor = original;
newColor = original;
setNewColor(original);
}
public int getOriginalColor()
{
return originalColor;
}
public int getNewColor()
{
return newColor;
}
public void setNewColor(int newColor)
{
this.newColor = newColor;
}
}
@@ -78,14 +112,29 @@ public class BiomeEvent extends Event
@HasResult
public static class GetVillageBlockID extends BiomeEvent
{
public final IBlockState original;
public IBlockState replacement;
private final IBlockState original;
private IBlockState replacement;
public GetVillageBlockID(BiomeGenBase biome, IBlockState original)
{
super(biome);
this.original = original;
}
public IBlockState getOriginal()
{
return original;
}
public IBlockState getReplacement()
{
return replacement;
}
public void setReplacement(IBlockState replacement)
{
this.replacement = replacement;
}
}
/**
@@ -14,7 +14,12 @@ public class ChunkGeneratorEvent extends Event
this.gen = gen;
}
public IChunkGenerator getGenerator() { return this.gen; }
public IChunkGenerator getGenerator() { return this.getGen(); }
public IChunkGenerator getGen()
{
return gen;
}
/**
* This event is fired when a chunks blocks are replaced by a biomes top and
@@ -25,10 +30,10 @@ public class ChunkGeneratorEvent extends Event
@HasResult
public static class ReplaceBiomeBlocks extends ChunkGeneratorEvent
{
public final int x;
public final int z;
public final ChunkPrimer primer;
public final World world; // CAN BE NULL
private final int x;
private final int z;
private final ChunkPrimer primer;
private final World world; // CAN BE NULL
public ReplaceBiomeBlocks(IChunkGenerator chunkProvider, int x, int z, ChunkPrimer primer, World world)
{
@@ -39,6 +44,10 @@ public class ChunkGeneratorEvent extends Event
this.world = world;
}
public int getX() { return x; }
public int getZ() { return z; }
public ChunkPrimer getPrimer() { return primer; }
public World getWorld() { return world; }
}
/**
@@ -49,18 +58,18 @@ public class ChunkGeneratorEvent extends Event
@HasResult
public static class InitNoiseField extends ChunkGeneratorEvent
{
public double[] noisefield;
public final int posX;
public final int posY;
public final int posZ;
public final int sizeX;
public final int sizeY;
public final int sizeZ;
private double[] noisefield;
private final int posX;
private final int posY;
private final int posZ;
private final int sizeX;
private final int sizeY;
private final int sizeZ;
public InitNoiseField(IChunkGenerator chunkProvider, double[] noisefield, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ)
{
super(chunkProvider);
this.noisefield = noisefield;
this.setNoisefield(noisefield);
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
@@ -69,5 +78,13 @@ public class ChunkGeneratorEvent extends Event
this.sizeZ = sizeZ;
}
public double[] getNoisefield() { return noisefield; }
public void setNoisefield(double[] noisefield) { this.noisefield = noisefield; }
public int getPosX() { return posX; }
public int getPosY() { return posY; }
public int getPosZ() { return posZ; }
public int getSizeX() { return sizeX; }
public int getSizeY() { return sizeY; }
public int getSizeZ() { return sizeZ; }
}
}
@@ -23,9 +23,9 @@ import net.minecraft.world.World;
**/
public class DecorateBiomeEvent extends Event
{
public final World world;
public final Random rand;
public final BlockPos pos;
private final World world;
private final Random rand;
private final BlockPos pos;
public DecorateBiomeEvent(World world, Random rand, BlockPos pos)
{
@@ -34,6 +34,21 @@ public class DecorateBiomeEvent extends Event
this.pos = pos;
}
public World getWorld()
{
return world;
}
public Random getRand()
{
return rand;
}
public BlockPos getPos()
{
return pos;
}
/**
* This event is fired before a chunk is decorated with a biome feature.
*/
@@ -64,11 +79,16 @@ public class DecorateBiomeEvent extends Event
@HasResult
public static class Decorate extends DecorateBiomeEvent
{
public EventType getType()
{
return type;
}
/** Use CUSTOM to filter custom event types
*/
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;
private final EventType type;
public Decorate(World world, Random rand, BlockPos pos, EventType type)
{
@@ -41,6 +41,6 @@ public class DeferredBiomeDecorator extends BiomeDecorator {
BiomeEvent.CreateDecorator event = new BiomeEvent.CreateDecorator(biome, wrapped);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
biome.theBiomeDecorator = event.newBiomeDecorator;
biome.theBiomeDecorator = event.getNewBiomeDecorator();
}
}
@@ -9,14 +9,18 @@ public class InitMapGenEvent extends Event
*/
public static enum EventType { CAVE, MINESHAFT, NETHER_BRIDGE, NETHER_CAVE, RAVINE, SCATTERED_FEATURE, STRONGHOLD, VILLAGE, OCEAN_MONUMENT, CUSTOM }
public final EventType type;
public final MapGenBase originalGen;
public MapGenBase newGen;
private final EventType type;
private final MapGenBase originalGen;
private MapGenBase newGen;
InitMapGenEvent(EventType type, MapGenBase original)
{
this.type = type;
this.originalGen = original;
this.newGen = original;
this.setNewGen(original);
}
public EventType getType() { return type; }
public MapGenBase getOriginalGen() { return originalGen; }
public MapGenBase getNewGen() { return newGen; }
public void setNewGen(MapGenBase newGen) { this.newGen = newGen; }
}
@@ -20,9 +20,9 @@ import net.minecraft.world.gen.feature.WorldGenerator;
**/
public class OreGenEvent extends Event
{
public final World world;
public final Random rand;
public final BlockPos pos;
private final World world;
private final Random rand;
private final BlockPos pos;
public OreGenEvent(World world, Random rand, BlockPos pos)
{
@@ -31,6 +31,21 @@ public class OreGenEvent extends Event
this.pos = pos;
}
public World getWorld()
{
return world;
}
public Random getRand()
{
return rand;
}
public BlockPos getPos()
{
return pos;
}
/**
* OreGenEvent.Pre is fired just before a chunk is populated with ores.<br>
* This event is fired just before ore generation in
@@ -89,8 +104,8 @@ public class OreGenEvent extends Event
{
public static enum EventType { COAL, DIAMOND, DIRT, GOLD, GRAVEL, IRON, LAPIS, REDSTONE, QUARTZ, DIORITE, GRANITE, ANDESITE, EMERALD, SILVERFISH, CUSTOM }
public final EventType type;
public final WorldGenerator generator;
private final EventType type;
private final WorldGenerator generator;
public GenerateMinable(World world, Random rand, WorldGenerator generator, BlockPos pos, EventType type)
{
@@ -98,5 +113,15 @@ public class OreGenEvent extends Event
this.generator = generator;
this.type = type;
}
public EventType getType()
{
return type;
}
public WorldGenerator getGenerator()
{
return generator;
}
}
}
@@ -23,11 +23,11 @@ import net.minecraftforge.fml.common.eventhandler.Event;
**/
public class PopulateChunkEvent extends ChunkGeneratorEvent
{
public final World world;
public final Random rand;
public final int chunkX;
public final int chunkZ;
public final boolean hasVillageGenerated;
private final World world;
private final Random rand;
private final int chunkX;
private final int chunkZ;
private final boolean hasVillageGenerated;
public PopulateChunkEvent(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated)
{
@@ -39,6 +39,11 @@ public class PopulateChunkEvent extends ChunkGeneratorEvent
this.hasVillageGenerated = hasVillageGenerated;
}
public World getWorld() { return world; }
public Random getRand() { return rand; }
public int getChunkX() { return chunkX; }
public int getChunkZ() { return chunkZ; }
public boolean isHasVillageGenerated() { return 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
@@ -100,11 +105,16 @@ public class PopulateChunkEvent extends ChunkGeneratorEvent
@HasResult
public static class Populate extends PopulateChunkEvent
{
public EventType getType()
{
return type;
}
/** Use CUSTOM to filter custom event types
*/
public static enum EventType { DUNGEON, FIRE, GLOWSTONE, ICE, LAKE, LAVA, NETHER_LAVA, NETHER_LAVA2, ANIMALS, CUSTOM }
public final EventType type;
private final EventType type;
public Populate(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, EventType type)
{
@@ -24,8 +24,8 @@ import net.minecraftforge.event.world.WorldEvent;
@HasResult
public class SaplingGrowTreeEvent extends WorldEvent
{
public final BlockPos pos;
public final Random rand;
private final BlockPos pos;
private final Random rand;
public SaplingGrowTreeEvent(World world, Random rand, BlockPos pos)
{
@@ -33,4 +33,14 @@ public class SaplingGrowTreeEvent extends WorldEvent
this.rand = rand;
this.pos = pos;
}
public BlockPos getPos()
{
return pos;
}
public Random getRand()
{
return rand;
}
}
@@ -26,7 +26,7 @@ public abstract class TerrainGen
{
InitMapGenEvent event = new InitMapGenEvent(type, original);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.newGen;
return event.getNewGen();
}
public static boolean populate(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, Populate.EventType type)
@@ -15,13 +15,18 @@ import net.minecraft.world.WorldType;
**/
public class WorldTypeEvent extends Event
{
public final WorldType worldType;
private final WorldType worldType;
public WorldTypeEvent(WorldType worldType)
{
this.worldType = worldType;
}
public WorldType getWorldType()
{
return worldType;
}
/**
* BiomeSize is fired when vanilla Minecraft attempts to generate biomes.<br>
* This event is fired during biome generation in
@@ -39,14 +44,29 @@ public class WorldTypeEvent extends Event
**/
public static class BiomeSize extends WorldTypeEvent
{
public final int originalSize;
public int newSize;
private final int originalSize;
private int newSize;
public BiomeSize(WorldType worldType, int original)
{
super(worldType);
originalSize = original;
newSize = original;
setNewSize(original);
}
public int getOriginalSize()
{
return originalSize;
}
public int getNewSize()
{
return newSize;
}
public void setNewSize(int newSize)
{
this.newSize = newSize;
}
}
@@ -68,16 +88,36 @@ public class WorldTypeEvent extends Event
**/
public static class InitBiomeGens extends WorldTypeEvent
{
public final long seed;
public final GenLayer[] originalBiomeGens;
public GenLayer[] newBiomeGens;
private final long seed;
private final GenLayer[] originalBiomeGens;
private GenLayer[] newBiomeGens;
public InitBiomeGens(WorldType worldType, long seed, GenLayer[] original)
{
super(worldType);
this.seed = seed;
originalBiomeGens = original;
newBiomeGens = original.clone();
setNewBiomeGens(original.clone());
}
public long getSeed()
{
return seed;
}
public GenLayer[] getOriginalBiomeGens()
{
return originalBiomeGens;
}
public GenLayer[] getNewBiomeGens()
{
return newBiomeGens;
}
public void setNewBiomeGens(GenLayer[] newBiomeGens)
{
this.newBiomeGens = newBiomeGens;
}
}
}
@@ -22,9 +22,9 @@ public class BlockEvent extends Event
{
private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockEvent", "false"));
public final World world;
public final BlockPos pos;
public final IBlockState state;
private final World world;
private final BlockPos pos;
private final IBlockState state;
public BlockEvent(World world, BlockPos pos, IBlockState state)
{
this.pos = pos;
@@ -32,6 +32,21 @@ public class BlockEvent extends Event
this.state = state;
}
public World getWorld()
{
return world;
}
public BlockPos getPos()
{
return pos;
}
public IBlockState getState()
{
return 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.
@@ -45,21 +60,28 @@ public class BlockEvent extends Event
*/
public static class HarvestDropsEvent extends BlockEvent
{
public final int fortuneLevel;
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
private final int fortuneLevel;
private final List<ItemStack> drops;
private final boolean isSilkTouching;
private float dropChance; // Change to e.g. 1.0f, if you manipulate the list and want to guarantee it always drops
private final EntityPlayer harvester; // May be null for non-player harvesting such as explosions or machines
public HarvestDropsEvent(World world, BlockPos pos, IBlockState state, int fortuneLevel, float dropChance, List<ItemStack> drops, EntityPlayer harvester, boolean isSilkTouching)
{
super(world, pos, state);
this.fortuneLevel = fortuneLevel;
this.dropChance = dropChance;
this.setDropChance(dropChance);
this.drops = drops;
this.isSilkTouching = isSilkTouching;
this.harvester = harvester;
}
public int getFortuneLevel() { return fortuneLevel; }
public List<ItemStack> getDrops() { return drops; }
public boolean isSilkTouching() { return isSilkTouching; }
public float getDropChance() { return dropChance; }
public void setDropChance(float dropChance) { this.dropChance = dropChance; }
public EntityPlayer getHarvester() { return harvester; }
}
/**
@@ -124,11 +146,11 @@ public class BlockEvent extends Event
@Cancelable
public static class PlaceEvent extends BlockEvent
{
public final EntityPlayer player;
public final ItemStack itemInHand;
public final BlockSnapshot blockSnapshot;
public final IBlockState placedBlock;
public final IBlockState placedAgainst;
private final EntityPlayer player;
private final ItemStack itemInHand;
private final BlockSnapshot blockSnapshot;
private final IBlockState placedBlock;
private final IBlockState placedAgainst;
public PlaceEvent(BlockSnapshot blockSnapshot, IBlockState placedAgainst, EntityPlayer player)
{
@@ -140,9 +162,15 @@ public class BlockEvent extends Event
this.placedAgainst = placedAgainst;
if (DEBUG)
{
System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ]\n", placedBlock, placedAgainst, itemInHand, player);
System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ]\n", getPlacedBlock(), placedAgainst, getItemInHand(), player);
}
}
public EntityPlayer getPlayer() { return player; }
public ItemStack getItemInHand() { return itemInHand; }
public BlockSnapshot getBlockSnapshot() { return blockSnapshot; }
public IBlockState getPlacedBlock() { return placedBlock; }
public IBlockState getPlacedAgainst() { return placedAgainst; }
}
/**
@@ -163,7 +191,7 @@ public class BlockEvent extends Event
this.blockSnapshots = ImmutableList.copyOf(blockSnapshots);
if (DEBUG)
{
System.out.printf("Created MultiPlaceEvent - [PlacedAgainst: %s ][ItemInHand: %s ][Player: %s ]\n", placedAgainst, this.itemInHand, player);
System.out.printf("Created MultiPlaceEvent - [PlacedAgainst: %s ][ItemInHand: %s ][Player: %s ]\n", placedAgainst, this.getItemInHand(), player);
}
}
@@ -16,15 +16,25 @@ import net.minecraft.entity.player.EntityPlayerMP;
**/
public class ChunkWatchEvent extends Event
{
public final ChunkCoordIntPair chunk;
public final EntityPlayerMP player;
private final ChunkCoordIntPair chunk;
private final EntityPlayerMP player;
public ChunkWatchEvent(ChunkCoordIntPair chunk, EntityPlayerMP player)
{
this.chunk = chunk;
this.player = player;
}
public ChunkCoordIntPair getChunk()
{
return chunk;
}
public EntityPlayerMP getPlayer()
{
return player;
}
/**
* ChunkWatchEvent.Watch is fired when an EntityPlayer begins watching a chunk.<br>
* This event is fired when a chunk is added to the watched chunks of an EntityPlayer in
@@ -21,8 +21,8 @@ import net.minecraft.world.World;
*/
public class ExplosionEvent extends Event
{
public final World world;
public final Explosion explosion;
private final World world;
private final Explosion explosion;
public ExplosionEvent(World world, Explosion explosion)
{
@@ -30,6 +30,16 @@ public class ExplosionEvent extends Event
this.explosion = explosion;
}
public World getWorld()
{
return world;
}
public Explosion getExplosion()
{
return explosion;
}
/** ExplosionEvent.Start is fired before the explosion actually occurs. Canceling this event will stop the explosion.<br>
* <br>
* This event is {@link Cancelable}.<br>
@@ -64,7 +74,7 @@ public class ExplosionEvent extends Event
/** return the list of blocks affected by the explosion. */
public List<BlockPos> getAffectedBlocks()
{
return explosion.getAffectedBlockPositions();
return getExplosion().getAffectedBlockPositions();
}
/** return the list of entities affected by the explosion. */
@@ -67,12 +67,22 @@ public class NoteBlockEvent extends BlockEvent
@Cancelable
public static class Play extends NoteBlockEvent
{
public Instrument instrument;
private Instrument instrument;
public Play(World world, BlockPos pos, IBlockState state, int note, int instrument)
{
super(world, pos, state, note);
this.instrument = Instrument.fromId(instrument);
this.setInstrument(Instrument.fromId(instrument));
}
public Instrument getInstrument()
{
return instrument;
}
public void setInstrument(Instrument instrument)
{
this.instrument = instrument;
}
}
@@ -83,8 +93,8 @@ public class NoteBlockEvent extends BlockEvent
@Cancelable
public static class Change extends NoteBlockEvent
{
public final Note oldNote;
public final Octave oldOctave;
private final Note oldNote;
private final Octave oldOctave;
public Change(World world, BlockPos pos, IBlockState state, int oldNote, int newNote)
{
@@ -92,6 +102,16 @@ public class NoteBlockEvent extends BlockEvent
this.oldNote = Note.fromId(oldNote);
this.oldOctave = Octave.fromId(oldNote);
}
public Note getOldNote()
{
return oldNote;
}
public Octave getOldOctave()
{
return oldOctave;
}
}
/**
@@ -22,13 +22,18 @@ import net.minecraftforge.fml.common.eventhandler.Event;
**/
public class WorldEvent extends Event
{
public final World world;
private final World world;
public WorldEvent(World world)
{
this.world = world;
}
public World getWorld()
{
return world;
}
/**
* WorldEvent.Load is fired when Minecraft loads a world.<br>
* This event is fired when a world is loaded in
@@ -96,9 +101,9 @@ public class WorldEvent extends Event
@Cancelable
public static class PotentialSpawns extends WorldEvent
{
public final EnumCreatureType type;
public final BlockPos pos;
public final List<SpawnListEntry> list;
private final EnumCreatureType type;
private final BlockPos pos;
private final List<SpawnListEntry> list;
public PotentialSpawns(World world, EnumCreatureType type, BlockPos pos, List<SpawnListEntry> oldList)
{
@@ -114,6 +119,21 @@ public class WorldEvent extends Event
this.list = new ArrayList<SpawnListEntry>();
}
}
public EnumCreatureType getType()
{
return type;
}
public BlockPos getPos()
{
return pos;
}
public List<SpawnListEntry> getList()
{
return list;
}
}
/**
@@ -123,11 +143,16 @@ public class WorldEvent extends Event
@Cancelable
public static class CreateSpawnPosition extends WorldEvent
{
public final WorldSettings settings;
private final WorldSettings settings;
public CreateSpawnPosition(World world, WorldSettings settings)
{
super(world);
this.settings = settings;
}
public WorldSettings getSettings()
{
return settings;
}
}
}