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,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;
}
}