[1.19.x] Apply general renames, A SRG is provided for modders. (#8840)

See https://gist.github.com/SizableShrimp/882a671ff74256d150776da08c89ef72
This commit is contained in:
SizableShrimp authored and GitHub committed 2022-07-11 18:27:48 -07:00
1 parent 5e8c786406
commit b8b40e1f54
140 files changed
+1138 -1149

No files matched your search

@@ -36,7 +36,7 @@ public class EntityAttributeModificationEvent extends Event implements IModBusEv
{
this.entityAttributes = mapIn;
this.entityTypes = ImmutableList.copyOf(
ForgeRegistries.ENTITIES.getValues().stream()
ForgeRegistries.ENTITY_TYPES.getValues().stream()
.filter(DefaultAttributes::hasSupplier)
.map(entityType -> (EntityType<? extends LivingEntity>) entityType)
.collect(Collectors.toList())
@@ -58,7 +58,7 @@ public class EntityEvent extends Event
* This event is fired on server and client after an Entity has entered a different section. <br>
* Sections are 16x16x16 block grids of the world.<br>
* This event does not fire when a new entity is spawned, only when an entity moves from one section to another one.
* Use {@link EntityJoinWorldEvent} to detect new entities joining the world.
* Use {@link EntityJoinLevelEvent} to detect new entities joining the world.
* <br>
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.<br>
* <br>
@@ -0,0 +1,64 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.fml.LogicalSide;
/**
* This event is fired whenever an {@link Entity} joins a {@link Level}.
* This event is fired whenever an entity is added to a level in {@link Level#addFreshEntity(Entity)}
* and {@code PersistentEntitySectionManager#addNewEntity(Entity, boolean)}.
* <p>
* <strong>Note:</strong> This event may be called before the underlying {@link LevelChunk} is promoted to {@link ChunkStatus#FULL}.
* You will cause chunk loading deadlocks if you do not delay your world interactions.
* <p>
* This event is {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}.
* If the event is canceled, the entity will not be added to the level.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}
* on both logical sides.
**/
@Cancelable
public class EntityJoinLevelEvent extends EntityEvent
{
private final Level level;
private final boolean loadedFromDisk;
public EntityJoinLevelEvent(Entity entity, Level level)
{
this(entity, level, false);
}
public EntityJoinLevelEvent(Entity entity, Level level, boolean loadedFromDisk)
{
super(entity);
this.level = level;
this.loadedFromDisk = loadedFromDisk;
}
/**
* {@return the level that the entity is set to join}
*/
public Level getLevel()
{
return level;
}
/**
* @return {@code true} if the entity was loaded from disk, {@code false} otherwise.
* On the {@linkplain LogicalSide#CLIENT logical client}, this will always return {@code false}.
*/
public boolean loadedFromDisk()
{
return loadedFromDisk;
}
}
@@ -1,65 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* EntityJoinWorldEvent is fired when an Entity joins the world. <br>
* This event is fired whenever an Entity is added to the world in
* {@code Level#loadEntities(Collection)},
* {@code net.minecraft.world.ServerWorld#loadEntities(Collection)}
* {@code World#joinEntityInSurroundings(Entity)}, and
* {@code World#spawnEntity(Entity)}. <br>
* <strong>Note:</strong> This event may be called before the underlying {@link LevelChunk} is promoted to {@link ChunkStatus#FULL}.
* You will cause chunk loading deadlocks if you don't delay your world interactions.<br>
* <br>
* {@link #world} contains the world in which the entity is to join.<br>
* <br>
* This event is {@link Cancelable}.<br>
* If this event is canceled, the Entity is not added to the world.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
@net.minecraftforge.eventbus.api.Cancelable
public class EntityJoinWorldEvent extends EntityEvent
{
private final Level world;
private final boolean loadedFromDisk;
public EntityJoinWorldEvent(Entity entity, Level world)
{
this(entity, world, false);
}
public EntityJoinWorldEvent(Entity entity, Level world, boolean loadedFromDisk)
{
super(entity);
this.world = world;
this.loadedFromDisk = loadedFromDisk;
}
public Level getWorld()
{
return world;
}
/**
* @return {@code true} if the entity was loaded from disk. On client entities, the info isn't available and this will always return {@code false}.
*/
public boolean loadedFromDisk()
{
return loadedFromDisk;
}
}
@@ -0,0 +1,40 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.entity.LevelCallback;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* This event is fired whenever an {@link Entity} leaves a {@link Level}.
* This event is fired whenever an entity is removed from the level in {@link LevelCallback#onTrackingEnd(Object)}.
* <p>
* This event is not {@linkplain Cancelable cancellable} and does not {@linkplain net.minecraftforge.eventbus.api.Event.HasResult have a result}.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}
* on both logical sides.
**/
public class EntityLeaveLevelEvent extends EntityEvent
{
private final Level level;
public EntityLeaveLevelEvent(Entity entity, Level level)
{
super(entity);
this.level = level;
}
/**
* {@return the level the entity is set to leave}
*/
public Level getLevel()
{
return level;
}
}
@@ -1,43 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* EntityLeaveWorldEvent is fired when an Entity leaves the world. <br>
* This event is fired whenever an Entity is removed from the world in
* {@link ClientLevel#removeEntity(int, Entity.RemovalReason)}. <br>
* <br>
* {@link #world} contains the world from which the entity is removed. <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}
*/
public class EntityLeaveWorldEvent extends EntityEvent
{
private final Level world;
public EntityLeaveWorldEvent(Entity entity, Level world)
{
super(entity);
this.world = world;
}
public Level getWorld()
{
return world;
}
}
@@ -30,16 +30,16 @@ public class EntityMountEvent extends EntityEvent
private final Entity entityMounting;
private final Entity entityBeingMounted;
private final Level worldObj;
private final Level level;
private final boolean isMounting;
public EntityMountEvent(Entity entityMounting, Entity entityBeingMounted, Level entityWorld, boolean isMounting)
public EntityMountEvent(Entity entityMounting, Entity entityBeingMounted, Level level, boolean isMounting)
{
super(entityMounting);
this.entityMounting = entityMounting;
this.entityBeingMounted = entityBeingMounted;
this.worldObj = entityWorld;
this.level = level;
this.isMounting = isMounting;
}
@@ -63,8 +63,8 @@ public class EntityMountEvent extends EntityEvent
return entityBeingMounted;
}
public Level getWorldObj()
public Level getLevel()
{
return worldObj;
return level;
}
}
@@ -9,31 +9,32 @@ import net.minecraft.world.entity.item.ItemEntity;
import net.minecraftforge.event.entity.EntityEvent;
/**
* Base class for all EntityItem events. Contains a reference to the
* EntityItem of interest. For most EntityItem events, there's little to no
* Base class for all {@link ItemEntity} events. Contains a reference to the
* ItemEntity of interest. For most ItemEntity events, there's little to no
* additional useful data from the firing method that isn't already contained
* within the EntityItem instance.
* within the ItemEntity instance.
*/
public class ItemEvent extends EntityEvent
{
private final ItemEntity entityItem;
private final ItemEntity itemEntity;
/**
* Creates a new event for an EntityItem.
*
* @param itemEntity The EntityItem for this event
* Creates a new event for an {@link ItemEntity}.
*
* @param itemEntity The ItemEntity for this event
*/
public ItemEvent(ItemEntity itemEntity)
{
super(itemEntity);
this.entityItem = itemEntity;
this.itemEntity = itemEntity;
}
/**
* The relevant EntityItem for this event, already cast for you.
* The relevant {@link ItemEntity} for this event.
*/
public ItemEntity getEntityItem()
@Override
public ItemEntity getEntity()
{
return entityItem;
return itemEntity;
}
}
@@ -15,7 +15,7 @@ import net.minecraftforge.eventbus.api.Event;
import org.jetbrains.annotations.Nullable;
/**
* LivingEvent is fired whenever an event involving Living entities occurs.<br>
* LivingEvent is fired whenever an event involving a {@link LivingEntity} occurs.<br>
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
@@ -23,24 +23,24 @@ import org.jetbrains.annotations.Nullable;
**/
public class LivingEvent extends EntityEvent
{
private final LivingEntity entityLiving;
private final LivingEntity livingEntity;
public LivingEvent(LivingEntity entity)
{
super(entity);
entityLiving = entity;
livingEntity = entity;
}
public LivingEntity getEntityLiving()
@Override
public LivingEntity getEntity()
{
return entityLiving;
return livingEntity;
}
/**
* LivingUpdateEvent is fired when an Entity is updated. <br>
* This event is fired whenever an Entity is updated in
* {@link LivingEntity#tick()}. <br>
* LivingUpdateEvent is fired when a LivingEntity is ticked in {@link LivingEntity#tick()}. <br>
* <br>
* This event is fired via the {@link ForgeHooks#onLivingUpdate(LivingEntity)}.<br>
* This event is fired via the {@link ForgeHooks#onLivingTick(LivingEntity)}.<br>
* <br>
* This event is {@link Cancelable}.<br>
* If this event is canceled, the Entity does not update.<br>
@@ -50,9 +50,9 @@ public class LivingEvent extends EntityEvent
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
@Cancelable
public static class LivingUpdateEvent extends LivingEvent
public static class LivingTickEvent extends LivingEvent
{
public LivingUpdateEvent(LivingEntity e){ super(e); }
public LivingTickEvent(LivingEntity e){ super(e); }
}
/**
@@ -6,56 +6,92 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.LevelAccessor;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.Nullable;
/**
* LivingSpawnEvent is fired for any events associated with Living Entities spawn status. <br>
* If a method utilizes this event as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* {@link #world} contains the world in which this living Entity is being spawned.<br>
* {@link #x} contains the x-coordinate this entity is being spawned at.<br>
* {@link #y} contains the y-coordinate this entity is being spawned at.<br>
* {@link #z} contains the z-coordinate this entity is being spawned at.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
**/
* This event is fired whenever a {@link Mob} should do something spawn-related.
* <p>
* This event is not {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}
* only on the {@linkplain LogicalSide#SERVER logical server}.
*/
public class LivingSpawnEvent extends LivingEvent
{
private final LevelAccessor world;
private final LevelAccessor level;
private final Mob mob;
private final double x;
private final double y;
private final double z;
public LivingSpawnEvent(Mob entity, LevelAccessor world, double x, double y, double z)
public LivingSpawnEvent(Mob mob, LevelAccessor level, double x, double y, double z)
{
super(entity);
this.world = world;
super(mob);
this.mob = mob;
this.level = level;
this.x = x;
this.y = y;
this.z = z;
}
public LevelAccessor getWorld() { return world; }
public double getX() { return x; }
public double getY() { return y; }
public double getZ() { return z; }
/**
* Fires before mob spawn events.
*
* Result is significant:
* DEFAULT: use vanilla spawn rules
* ALLOW: allow the spawn
* DENY: deny the spawn
*
* {@return the mob that is causing a spawn action}
*/
@Override
public Mob getEntity()
{
return this.mob;
}
/**
* {@return the level relating to the mob spawn action}
*/
public LevelAccessor getLevel()
{
return this.level;
}
/**
* {@return the x-coordinate relating to the mob spawn action}
*/
public double getX()
{
return this.x;
}
/**
* {@return the y-coordinate relating to the mob spawn action}
*/
public double getY()
{
return this.y;
}
/**
* {@return the z-coordinate relating to the mob spawn action}
*/
public double getZ()
{
return this.z;
}
/**
* This event is fired before a {@link Mob} spawns.
* <p>
* This event is not {@linkplain Cancelable cancellable}, but does {@linkplain HasResult have a result}.
* {@linkplain Result#DEFAULT DEFAULT} indicates that default spawn rules should be used.
* {@linkplain Result#ALLOW ALLOW} indicates that the mob should spawn regardless of default spawn rules.
* {@linkplain Result#DENY DENY} indicates that the mob should not spawn.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#SERVER logical server}.
*/
@HasResult
public static class CheckSpawn extends LivingSpawnEvent
@@ -64,19 +100,9 @@ public class LivingSpawnEvent extends LivingEvent
private final BaseSpawner spawner;
private final MobSpawnType spawnReason;
/**
* CheckSpawn is fired when an Entity is about to be spawned.
* @param entity the spawning entity
* @param world the world to spawn in
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
* @param spawner position of the MobSpawner
* null if it this spawn is coming from a WorldSpawner
*/
public CheckSpawn(Mob entity, LevelAccessor world, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason)
public CheckSpawn(Mob mob, LevelAccessor level, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason)
{
super(entity, world, x, y, z);
super(mob, level, x, y, z);
this.spawner = spawner;
this.spawnReason = spawnReason;
}
@@ -99,18 +125,14 @@ public class LivingSpawnEvent extends LivingEvent
}
/**
* SpecialSpawn is fired when an Entity is to be spawned.<br>
* This allows you to do special inializers in the new entity.<br>
* <br>
* This event is fired via the {@link ForgeEventFactory#doSpecialSpawn(Mob, LevelAccessor, float, float, float, BaseSpawner, MobSpawnType)}.<br>
* <br>
* This event is {@link Cancelable}.<br>
* If this event is canceled, the Entity is not spawned.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
* This event is fired whenever a {@link Mob} is set to be spawned, to allow for mod-specific initializers.
* <p>
* This event is {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}.
* If the event is canceled, the mob will not spawn.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#SERVER logical server}.
*/
@Cancelable
public static class SpecialSpawn extends LivingSpawnEvent
{
@@ -118,9 +140,9 @@ public class LivingSpawnEvent extends LivingEvent
private final BaseSpawner spawner;
private final MobSpawnType spawnReason;
public SpecialSpawn(Mob entity, LevelAccessor world, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason)
public SpecialSpawn(Mob entity, LevelAccessor level, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason)
{
super(entity, world, x, y, z);
super(entity, level, x, y, z);
this.spawner = spawner;
this.spawnReason = spawnReason;
}
@@ -138,25 +160,27 @@ public class LivingSpawnEvent extends LivingEvent
}
/**
* Fired each tick for despawnable mobs to allow control over despawning.
* {@link Result#DEFAULT} will pass the mob on to vanilla despawn mechanics.
* {@link Result#ALLOW} will force the mob to despawn.
* {@link Result#DENY} will force the mob to remain.
* This is fired every tick for every despawnable entity. Be efficient in your handlers.
*
* Note: this is not fired <em>if</em> the mob is definitely going to otherwise despawn. It is fired to check if
* the mob can be allowed to despawn. See {@link LivingEntity#checkDespawn()}
* This event is fired for a {@link Mob} that can despawn <i>each mob tick</i>.
* This event only fires if a mob can be allowed to despawn and will not
* otherwise fire if a despawn is certain.
* <p>
* This event is not {@linkplain Cancelable cancellable}, but does {@linkplain HasResult have a result}.
* {@link Result#DEFAULT} indicates that default despawn mechanics should be used.
* {@link Result#ALLOW} indicates that the mob should forcefully despawn.
* {@link Result#DENY} indicates that the mob should forcefully stay spawned.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#SERVER logical server}.
*
* @see LivingEntity#checkDespawn()
* @author cpw
*
*/
@HasResult
public static class AllowDespawn extends LivingSpawnEvent
{
public AllowDespawn(Mob entity)
public AllowDespawn(Mob mob)
{
super(entity, entity.level, entity.getX(), entity.getY(), entity.getZ());
super(mob, mob.level, mob.getX(), mob.getY(), mob.getZ());
}
}
}
@@ -0,0 +1,164 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity.living;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* This event is fired when an interaction between a {@link LivingEntity} and {@link MobEffectInstance} happens.
* <p>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
*/
public class MobEffectEvent extends LivingEvent
{
@Nullable
protected final MobEffectInstance effectInstance;
public MobEffectEvent(LivingEntity living, MobEffectInstance effectInstance)
{
super(living);
this.effectInstance = effectInstance;
}
@Nullable
public MobEffectInstance getEffectInstance()
{
return effectInstance;
}
/**
* This Event is fired when a {@link MobEffect} is about to get removed from an Entity.
* This Event is {@link Cancelable}. If canceled, the effect will not be removed.
* This Event does not have a result.
*/
@Cancelable
public static class Remove extends MobEffectEvent
{
private final MobEffect effect;
public Remove(LivingEntity living, MobEffect effect)
{
super(living, living.getEffect(effect));
this.effect = effect;
}
public Remove(LivingEntity living, MobEffectInstance effectInstance)
{
super(living, effectInstance);
this.effect = effectInstance.getEffect();
}
/**
* @return the {@link MobEffectEvent} which is being removed from the entity
*/
public MobEffect getEffect()
{
return this.effect;
}
/**
* @return the {@link MobEffectInstance}. In the remove event, this can be null if the entity does not have a {@link MobEffect} of the right type active.
*/
@Override
@Nullable
public MobEffectInstance getEffectInstance()
{
return super.getEffectInstance();
}
}
/**
* This event is fired to check if a {@link MobEffectInstance} can be applied to an entity.
* This event is not {@link Cancelable}.
* This event {@link HasResult has a result}.
* <p>
* {@link Result#ALLOW ALLOW} will apply this mob effect.
* {@link Result#DENY DENY} will not apply this mob effect.
* {@link Result#DEFAULT DEFAULT} will run vanilla logic to determine if this mob effect is applicable in {@link LivingEntity#canBeAffected}.
*/
@HasResult
public static class Applicable extends MobEffectEvent
{
public Applicable(LivingEntity living, @NotNull MobEffectInstance effectInstance)
{
super(living, effectInstance);
}
@Override
@NotNull
public MobEffectInstance getEffectInstance()
{
return super.getEffectInstance();
}
}
/**
* This event is fired when a new {@link MobEffectInstance} is added to an entity.
* This event is also fired if an entity already has the effect but with a different duration or amplifier.
* This event is not {@link Cancelable}.
* This event does not have a result.
*/
public static class Added extends MobEffectEvent
{
private final MobEffectInstance oldEffectInstance;
private final Entity source;
public Added(LivingEntity living, MobEffectInstance oldEffectInstance, MobEffectInstance newEffectInstance, Entity source)
{
super(living, newEffectInstance);
this.oldEffectInstance = oldEffectInstance;
this.source = source;
}
/**
* @return the added {@link MobEffectInstance}. This is the unmerged MobEffectInstance if the old MobEffectInstance is not null.
*/
@Override
@NotNull
public MobEffectInstance getEffectInstance()
{
return super.getEffectInstance();
}
/**
* @return the old {@link MobEffectInstance}. This can be null if the entity did not have an effect of this kind before.
*/
@Nullable
public MobEffectInstance getOldEffectInstance()
{
return oldEffectInstance;
}
/**
* @return the entity source of the effect, or {@code null} if none exists
*/
@Nullable
public Entity getEffectSource()
{
return source;
}
}
/**
* This event is fired when a {@link MobEffectInstance} expires on an entity.
* This event is not {@link Cancelable}.
* This event does not have a result.
*/
public static class Expired extends MobEffectEvent
{
public Expired(LivingEntity living, MobEffectInstance effectInstance)
{
super(living, effectInstance);
}
}
}
@@ -1,167 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity.living;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* This Event and its subevents gets fired from {@link LivingEntity} on the {@link MinecraftForge#EVENT_BUS}.<br>
*/
public class PotionEvent extends LivingEvent
{
@Nullable
protected final MobEffectInstance effect;
public PotionEvent(LivingEntity living, MobEffectInstance effect)
{
super(living);
this.effect = effect;
}
/**
* Retuns the PotionEffect.
*/
@Nullable
public MobEffectInstance getPotionEffect()
{
return effect;
}
/**
* This Event is fired when a Potion is about to get removed from an Entity.
* This Event is {@link Cancelable}.
* This Event does not have a result.
*/
@Cancelable
public static class PotionRemoveEvent extends PotionEvent
{
private final MobEffect potion;
public PotionRemoveEvent(LivingEntity living, MobEffect potion)
{
super(living, living.getEffect(potion));
this.potion = potion;
}
public PotionRemoveEvent(LivingEntity living, MobEffectInstance effect)
{
super(living, effect);
this.potion = effect.getEffect();
}
/**
* @return the Potion which is tried to remove from the Entity.
*/
public MobEffect getPotion()
{
return this.potion;
}
/**
* @return the PotionEffect. In the remove event this can be null if the Entity does not have a {@link MobEffect} of the right type active.
*/
@Override
@Nullable
public MobEffectInstance getPotionEffect()
{
return super.getPotionEffect();
}
}
/**
* This Event is fired to check if a Potion can get applied to an Entity.
* This Event is not {@link Cancelable}
* This Event has a result {@link HasResult}.
* ALLOW will apply this potion effect.
* DENY will not apply this potion effect.
* DEFAULT will run vanilla logic to determine if this potion isApplicable.
*/
@HasResult
public static class PotionApplicableEvent extends PotionEvent
{
public PotionApplicableEvent(LivingEntity living, MobEffectInstance effect)
{
super(living, effect);
}
/**
* @return the PotionEffect.
*/
@Override
@NotNull
public MobEffectInstance getPotionEffect()
{
return super.getPotionEffect();
}
}
/**
* This Event is fired when a new Potion is added to the Entity. This is also fired if the Entity already has this effect but with different duration/level.
* This Event is not {@link Cancelable}
* This Event does not have a Result.
*/
public static class PotionAddedEvent extends PotionEvent
{
private final MobEffectInstance oldEffect;
private final Entity source;
public PotionAddedEvent(LivingEntity living, MobEffectInstance oldEffect, MobEffectInstance newEffect, Entity source)
{
super(living, newEffect);
this.oldEffect = oldEffect;
this.source = source;
}
/**
* @return the added PotionEffect. This is the umerged PotionEffect if the old PotionEffect is not null.
*/
@Override
@NotNull
public MobEffectInstance getPotionEffect()
{
return super.getPotionEffect();
}
/**
* @return the old PotionEffect. THis can be null if the entity did not have an effect of this kind before.
*/
@Nullable
public MobEffectInstance getOldPotionEffect()
{
return oldEffect;
}
/**
* Returns the entity source of the effect, or {@code null} if none exists.
*
* @return the entity source of the effect, or {@code null}
*/
@Nullable
public Entity getPotionSource()
{
return source;
}
}
/**
* This Event is fired when a Potion effect expires on an Entity.
* This Event is not {@link Cancelable}
* This Event does not have a Result.
*/
public static class PotionExpiryEvent extends PotionEvent
{
public PotionExpiryEvent(LivingEntity living, MobEffectInstance effect)
{
super(living, effect);
}
}
}
@@ -11,64 +11,68 @@ import net.minecraft.world.level.Level;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* ZombieEvent is fired whenever a zombie is spawned for aid.
* If a method utilizes this event as its parameter, the method will
* receive every child event of this class.
*
*
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
**/
public class ZombieEvent extends EntityEvent {
private final Zombie zombie;
public ZombieEvent(Zombie entity)
public ZombieEvent(Zombie zombie)
{
super(entity);
super(zombie);
this.zombie = zombie;
}
public Zombie getSummoner()
@Override
public Zombie getEntity()
{
return (Zombie) getEntity();
return this.zombie;
}
/**
* SummonAidEvent is fired when a Zombie Entity is summoned.
* This event is fired whenever a Zombie Entity is summoned in
* This event is fired whenever a Zombie Entity is summoned in
* {@code Zombie#actuallyHurt(DamageSource, float)}.
*
*
* This event is fired via the {@link ForgeEventFactory#fireZombieSummonAid(Zombie, Level, int, int, int, LivingEntity, double)}.
*
* {@link #customSummonedAid} remains null, but can be populated with a custom EntityZombie which will be spawned.
* {@link #world} contains the world that this summoning is occurring in.
* {@link #x} contains the x-coordinate at which this summoning event is occurring.
* {@link #y} contains the y-coordinate at which this summoning event is occurring.
* {@link #z} contains the z-coordinate at which this summoning event is occurring.
* {@link #attacker} contains the living Entity that attacked and caused this event to fire.
* {@link #summonChance} contains the likelihood that a Zombie would successfully be summoned.
*
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
*
*
* {@link #getCustomSummonedAid()} remains null, but can be populated with a custom EntityZombie which will be spawned.
* {@link #getLevel()} contains the world that this summoning is occurring in.
* {@link #getX()} contains the x-coordinate at which this summoning event is occurring.
* {@link #getY()} contains the y-coordinate at which this summoning event is occurring.
* {@link #getZ()} contains the z-coordinate at which this summoning event is occurring.
* {@link #getAttacker()} contains the living Entity that attacked and caused this event to fire.
* {@link #getSummonChance()} contains the likelihood that a Zombie would successfully be summoned.
*
* This event is not {@link Cancelable}.
*
* This event has a result. {@link HasResult}
* {@link Result#ALLOW} Zombie is summoned.
* {@link Result#DENY} Zombie is not summoned.
*
*
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
@HasResult
public static class SummonAidEvent extends ZombieEvent {
private Zombie customSummonedAid;
private final Level world;
private final Level level;
private final int x;
private final int y;
private final int z;
private final LivingEntity attacker;
private final double summonChance;
public SummonAidEvent(Zombie entity, Level world, int x, int y, int z, LivingEntity attacker, double summonChance)
public SummonAidEvent(Zombie zombie, Level level, int x, int y, int z, LivingEntity attacker, double summonChance)
{
super(entity);
this.world = world;
super(zombie);
this.level = level;
this.x = x;
this.y = y;
this.z = z;
@@ -81,7 +85,7 @@ public class ZombieEvent extends EntityEvent {
*/
public Zombie getCustomSummonedAid() { return customSummonedAid; }
public void setCustomSummonedAid(Zombie customSummonedAid) { this.customSummonedAid = customSummonedAid; }
public Level getWorld() { return world; }
public Level getLevel() { return level; }
public int getX() { return x; }
public int getY() { return y; }
public int getZ() { return z; }
@@ -40,21 +40,21 @@ public class AnvilRepairEvent extends PlayerEvent
* @return the output
*/
@NotNull
public ItemStack getItemResult() { return output; }
public ItemStack getOutput() { return output; }
/**
* Get the first item input into the anvil
* @return the first input slot
*/
@NotNull
public ItemStack getItemInput() { return left; }
public ItemStack getLeft() { return left; }
/**
* Get the second item input into the anvil
* @return the second input slot
*/
@NotNull
public ItemStack getIngredientInput() { return right; }
public ItemStack getRight() { return right; }
public float getBreakChance() { return breakChance; }
public void setBreakChance(float breakChance) { this.breakChance = breakChance; }
@@ -33,22 +33,22 @@ import org.jetbrains.annotations.NotNull;
public class ArrowLooseEvent extends PlayerEvent
{
private final ItemStack bow;
private final Level world;
private final Level level;
private final boolean hasAmmo;
private int charge;
public ArrowLooseEvent(Player player, @NotNull ItemStack bow, Level world, int charge, boolean hasAmmo)
public ArrowLooseEvent(Player player, @NotNull ItemStack bow, Level level, int charge, boolean hasAmmo)
{
super(player);
this.bow = bow;
this.world = world;
this.level = level;
this.charge = charge;
this.hasAmmo = hasAmmo;
}
@NotNull
public ItemStack getBow() { return this.bow; }
public Level getWorld() { return this.world; }
public Level getLevel() { return this.level; }
public boolean hasAmmo() { return this.hasAmmo; }
public int getCharge() { return this.charge; }
public void setCharge(int charge) { this.charge = charge; }
@@ -25,22 +25,22 @@ public class ArrowNockEvent extends PlayerEvent
{
private final ItemStack bow;
private final InteractionHand hand;
private final Level world;
private final Level level;
private final boolean hasAmmo;
private InteractionResultHolder<ItemStack> action;
public ArrowNockEvent(Player player, @NotNull ItemStack item, InteractionHand hand, Level world, boolean hasAmmo)
public ArrowNockEvent(Player player, @NotNull ItemStack item, InteractionHand hand, Level level, boolean hasAmmo)
{
super(player);
this.bow = item;
this.hand = hand;
this.world = world;
this.level = level;
this.hasAmmo = hasAmmo;
}
@NotNull
public ItemStack getBow() { return this.bow; }
public Level getWorld() { return this.world; }
public Level getLevel() { return this.level; }
public InteractionHand getHand() { return this.hand; }
public boolean hasAmmo() { return this.hasAmmo; }
public InteractionResultHolder<ItemStack> getAction()
@@ -27,23 +27,23 @@ import org.jetbrains.annotations.NotNull;
public class BonemealEvent extends PlayerEvent
{
private final Level world;
private final Level level;
private final BlockPos pos;
private final BlockState block;
private final ItemStack stack;
public BonemealEvent(@NotNull Player player, @NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState block, @NotNull ItemStack stack)
public BonemealEvent(@NotNull Player player, @NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState block, @NotNull ItemStack stack)
{
super(player);
this.world = world;
this.level = level;
this.pos = pos;
this.block = block;
this.stack = stack;
}
public Level getWorld()
public Level getLevel()
{
return world;
return level;
}
public BlockPos getPos()
@@ -29,23 +29,23 @@ public class FillBucketEvent extends PlayerEvent
{
private final ItemStack current;
private final Level world;
private final Level level;
@Nullable
private final HitResult target;
private ItemStack result;
public FillBucketEvent(Player player, @NotNull ItemStack current, Level world, @Nullable HitResult target)
public FillBucketEvent(Player player, @NotNull ItemStack current, Level level, @Nullable HitResult target)
{
super(player);
this.current = current;
this.world = world;
this.level = level;
this.target = target;
}
@NotNull
public ItemStack getEmptyBucket() { return this.current; }
public Level getWorld(){ return this.world; }
public Level getLevel(){ return this.level; }
@Nullable
public HitResult getTarget() { return this.target; }
@NotNull
@@ -23,12 +23,12 @@ public class ItemTooltipEvent extends PlayerEvent
private final List<Component> toolTip;
/**
* This event is fired in {@link ItemStack#getTooltipLines(Player, TooltipFlag)}, which in turn is called from it's respective GUIContainer.
* Tooltips are also gathered with a null entityPlayer during startup by {@link Minecraft#createSearchTrees()}.
* This event is fired in {@link ItemStack#getTooltipLines(Player, TooltipFlag)}, which in turn is called from its respective GUIContainer.
* Tooltips are also gathered with a null player during startup by {@link Minecraft#createSearchTrees()}.
*/
public ItemTooltipEvent(@NotNull ItemStack itemStack, @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags)
public ItemTooltipEvent(@NotNull ItemStack itemStack, @Nullable Player player, List<Component> list, TooltipFlag flags)
{
super(entityPlayer);
super(player);
this.itemStack = itemStack;
this.toolTip = list;
this.flags = flags;
@@ -64,8 +64,8 @@ public class ItemTooltipEvent extends PlayerEvent
*/
@Override
@Nullable
public Player getPlayer()
public Player getEntity()
{
return super.getPlayer();
return super.getEntity();
}
}
@@ -5,7 +5,6 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
@@ -33,7 +32,7 @@ import org.jetbrains.annotations.Nullable;
* {@link Player#attack(Entity)},
* {@code Player#hurtCurrentlyUsedShield(float)},
* {@link Player#interactOn(Entity, InteractionHand)},
* {@link ForgeHooks#getContainerItem(ItemStack)},
* {@link ForgeHooks#getCraftingRemainingItem(ItemStack)},
* {@link ServerPlayerGameMode#useItem(ServerPlayer, Level, ItemStack, InteractionHand)} ,
* {@link ServerPlayerGameMode#useItemOn(ServerPlayer, Level, ItemStack, InteractionHand, BlockHitResult)}
* and {@link ServerPlayerGameMode#destroyBlock(BlockPos)}.<br>
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* PlayerEvent is fired whenever an event involving Living entities occurs. <br>
* PlayerEvent is fired whenever an event involving a {@link Player} occurs. <br>
* If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
@@ -35,17 +35,20 @@ import org.jetbrains.annotations.Nullable;
**/
public class PlayerEvent extends LivingEvent
{
private final Player entityPlayer;
private final Player player;
public PlayerEvent(Player player)
{
super(player);
entityPlayer = player;
this.player = player;
}
@Override
public Player getEntity()
{
return player;
}
/**
* @return Player
*/
public Player getPlayer() { 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
@@ -322,7 +322,7 @@ public class PlayerInteractEvent extends PlayerEvent
@NotNull
public ItemStack getItemStack()
{
return getPlayer().getItemInHand(hand);
return getEntity().getItemInHand(hand);
}
/**
@@ -348,11 +348,11 @@ public class PlayerInteractEvent extends PlayerEvent
}
/**
* @return Convenience method to get the world of this interaction.
* @return Convenience method to get the level of this interaction.
*/
public Level getWorld()
public Level getLevel()
{
return getPlayer().getCommandSenderWorld();
return getEntity().level;
}
/**
@@ -360,7 +360,7 @@ public class PlayerInteractEvent extends PlayerEvent
*/
public LogicalSide getSide()
{
return getWorld().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER;
return getLevel().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER;
}
/**
@@ -19,15 +19,15 @@ import org.jetbrains.annotations.Nullable;
@Cancelable
public class PlayerSetSpawnEvent extends PlayerEvent
{
private final ResourceKey<Level> spawnWorld;
private final ResourceKey<Level> spawnLevel;
private final boolean forced;
@Nullable
private final BlockPos newSpawn;
public PlayerSetSpawnEvent(Player player, ResourceKey<Level> spawnWorld, @Nullable BlockPos newSpawn, boolean forced)
public PlayerSetSpawnEvent(Player player, ResourceKey<Level> spawnLevel, @Nullable BlockPos newSpawn, boolean forced)
{
super(player);
this.spawnWorld = spawnWorld;
this.spawnLevel = spawnLevel;
this.newSpawn = newSpawn;
this.forced = forced;
}
@@ -46,8 +46,8 @@ public class PlayerSetSpawnEvent extends PlayerEvent
return newSpawn;
}
public ResourceKey<Level> getSpawnWorld()
public ResourceKey<Level> getSpawnLevel()
{
return spawnWorld;
return spawnLevel;
}
}
@@ -16,13 +16,13 @@ public class PlayerWakeUpEvent extends PlayerEvent
{
private final boolean wakeImmediately;
private final boolean updateWorld;
private final boolean updateLevel;
public PlayerWakeUpEvent(Player player, boolean wakeImmediately, boolean updateWorld)
public PlayerWakeUpEvent(Player player, boolean wakeImmediately, boolean updateLevel)
{
super(player);
this.wakeImmediately = wakeImmediately;
this.updateWorld = updateWorld;
this.updateLevel = updateLevel;
}
/**
@@ -35,5 +35,5 @@ public class PlayerWakeUpEvent extends PlayerEvent
* Indicates if the server should be notified of sleeping changes.
* This will only be false if the server is considered 'up to date' already, because, for example, it initiated the call.
*/
public boolean updateWorld() { return updateWorld; }
public boolean updateLevel() { return updateLevel; }
}