Forge 1.19

* Bump pack.mcmeta formats
* 1.19 biome modifiers
* Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable
* Add docs and package-info to client extension interfaces package
* Move RenderBlockOverlayEvent hooks to ForgeHooksClient
* Add package-infos to client events package
* Rename SoundLoadEvent to SoundEngineLoadEvent

This reduces confusion from consumers which may think the
name SoundLoadEvent refers to an individual sound being loaded rather
than the sound engine.
* Document and change SoundLoadEvent to fire on mod bus

Previously, it fired on both the mod bus and the Forge bus, which is
confusing for consumers.
* Delete SoundSetupEvent

Looking at its original implementation shows that there isn't an
appropriate place in the new sound code to reinsert the event, and the
place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent.
* Perform some cleanup on client events

 - Removed nullable annotations from ClientPlayerNetworkEvent
 - Renamed #getPartialTicks methods to #getPartialTick, to be consistent
  with vanilla's naming of the partial tick
 - Cleanup documentation to remove line breaks, use the
  spelling 'cancelled' over
  'canceled', and improve docs on existing and
   new methods.
* Remove EntityEvent.CanUpdate

Closes MinecraftForge/MinecraftForge#6394
* Switch to Jetbrains nullability annotations
* New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent
* Remove ForgeWorldPresetScreens
* Remove IForgeRegistryEntry
* Remove use of List<Throwable> in FML's CompletableFutures
* Add docs to mod loading stages, stages, and phases
* Gradle 7.4.2
* Use SLF4J in FMLLoader and other subprojects
* Switch dynamic versions in subprojects to pinned ones
* Switch ForgeRoot and MDK to FG plugin markers
* Configure Forge javadoc task

The task now uses a custom stylesheet with MCForge elements, and
configured to combine the generation from the four FML subprojects
(fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project
into the javadoc output.
* Update docs/md files, for 1.19 update and the move away from IRC to Discord.
* Make "Potentially dangerous alternative prefix" a debug warning, not info.

Co-authored-by: Curle <[email protected]>
Co-authored-by: sciwhiz12 <[email protected]>
Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
committed 2022-06-07 15:31:26 -05:00
1 parent 270e778ac5
commit 4ed9117799
1485 files changed
+14960 -15446

No files matched your search

@@ -54,38 +54,6 @@ public class EntityEvent extends Event
}
}
/**
* CanUpdate is fired when an Entity is being created. <br>
* This event is fired whenever vanilla Minecraft determines that an entity<br>
* cannot update in {@code World#updateEntityWithOptionalForce(net.minecraft.entity.Entity, boolean)} <br>
* <br>
* {@link CanUpdate#canUpdate} contains the boolean value of whether this entity can update.<br>
* If the modder decides that this Entity can be updated, they may change canUpdate to true, <br>
* and the entity with then be updated.<br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public static class CanUpdate extends EntityEvent
{
private boolean canUpdate = false;
public CanUpdate(Entity entity)
{
super(entity);
}
public boolean getCanUpdate()
{
return canUpdate;
}
public void setCanUpdate(boolean canUpdate)
{
this.canUpdate = canUpdate;
}
}
/**
* 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>
@@ -15,7 +15,7 @@ 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)}, {@link ServerLevel#removeEntityComplete(Entity, boolean)}. <br>
* {@link ClientLevel#removeEntity(int, Entity.RemovalReason)}. <br>
* <br>
* {@link #world} contains the world from which the entity is removed. <br>
* <br>
@@ -1,68 +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.player.LocalPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* PlaySoundAtEntityEvent is fired a sound is to be played at an Entity<br>
* This event is fired whenever a sound is set to be played at an Entity such as in
* {@link LocalPlayer#playSound(SoundEvent, float, float)} and
* {@link Level#playSound(Player, double, double, double, SoundEvent, SoundSource, float, float)}.<br>
* <br>
* {@link #name} contains the name of the sound to be played at the Entity.<br>
* {@link #volume} contains the volume at which the sound is to be played originally.<br>
* {@link #pitch} contains the pitch at which the sound is to be played originally.<br>
* {@link #newVolume} contains the volume at which the sound is actually played.<br>
* {@link #newPitch} contains the pitch at which the sound is actually played.<br>
* Changing the {@link #name} field will cause the sound of this name to be played instead of the originally intended sound.<br>
* <br>
* This event is {@link Cancelable}.<br>
* If this event is canceled, the sound is not played.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
@net.minecraftforge.eventbus.api.Cancelable
public class PlaySoundAtEntityEvent extends EntityEvent
{
private SoundEvent name;
private SoundSource category;
private final float volume;
private final float pitch;
private float newVolume;
private float newPitch;
public PlaySoundAtEntityEvent(Entity entity, SoundEvent name, SoundSource category, float volume, float pitch)
{
super(entity);
this.name = name;
this.category = category;
this.volume = volume;
this.pitch = pitch;
this.newVolume = volume;
this.newPitch = pitch;
}
public SoundEvent getSound() { return this.name; }
public SoundSource getCategory() { return this.category; }
public float getDefaultVolume() { return this.volume; }
public float getDefaultPitch() { return this.pitch; }
public float getVolume() { return this.newVolume; }
public float getPitch() { return this.newPitch; }
public void setSound(SoundEvent value) { this.name = value; }
public void setCategory(SoundSource category) { this.category = category; }
public void setVolume(float value) { this.newVolume = value; }
public void setPitch(float value) { this.newPitch = value; }
}
@@ -13,7 +13,7 @@ import net.minecraft.world.entity.animal.Fox;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
/**
* BabyEntitySpawnEvent is fired just before a baby entity is about to be spawned. <br>
@@ -7,6 +7,7 @@ package net.minecraftforge.event.entity.living;
import net.minecraft.world.entity.monster.EnderMan;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.common.extensions.IForgeItem;
import net.minecraftforge.eventbus.api.Cancelable;
/**
@@ -8,22 +8,21 @@ package net.minecraftforge.event.entity.living;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.Cancelable;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
public class LivingEntityUseItemEvent extends LivingEvent
{
private final ItemStack item;
private int duration;
private LivingEntityUseItemEvent(LivingEntity entity, @Nonnull ItemStack item, int duration)
private LivingEntityUseItemEvent(LivingEntity entity, @NotNull ItemStack item, int duration)
{
super(entity);
this.item = item;
this.setDuration(duration);
}
@Nonnull
@NotNull
public ItemStack getItem()
{
return item;
@@ -53,7 +52,7 @@ public class LivingEntityUseItemEvent extends LivingEvent
@Cancelable
public static class Start extends LivingEntityUseItemEvent
{
public Start(LivingEntity entity, @Nonnull ItemStack item, int duration)
public Start(LivingEntity entity, @NotNull ItemStack item, int duration)
{
super(entity, item, duration);
}
@@ -68,7 +67,7 @@ public class LivingEntityUseItemEvent extends LivingEvent
@Cancelable
public static class Tick extends LivingEntityUseItemEvent
{
public Tick(LivingEntity entity, @Nonnull ItemStack item, int duration)
public Tick(LivingEntity entity, @NotNull ItemStack item, int duration)
{
super(entity, item, duration);
}
@@ -89,7 +88,7 @@ public class LivingEntityUseItemEvent extends LivingEvent
@Cancelable
public static class Stop extends LivingEntityUseItemEvent
{
public Stop(LivingEntity entity, @Nonnull ItemStack item, int duration)
public Stop(LivingEntity entity, @NotNull ItemStack item, int duration)
{
super(entity, item, duration);
}
@@ -99,7 +98,7 @@ public class LivingEntityUseItemEvent extends LivingEvent
* Fired after an item has fully finished being used.
* The item has been notified that it was used, and the item/result stacks reflect after that state.
* This means that when this is fired for a Potion, the potion effect has already been applied.
*
*
* {@link LivingEntityUseItemEvent#item} is a copy of the item BEFORE it was used.
*
* If you wish to cancel those effects, you should cancel one of the above events.
@@ -110,19 +109,19 @@ public class LivingEntityUseItemEvent extends LivingEvent
public static class Finish extends LivingEntityUseItemEvent
{
private ItemStack result;
public Finish(LivingEntity entity, @Nonnull ItemStack item, int duration, @Nonnull ItemStack result)
public Finish(LivingEntity entity, @NotNull ItemStack item, int duration, @NotNull ItemStack result)
{
super(entity, item, duration);
this.setResultStack(result);
}
@Nonnull
@NotNull
public ItemStack getResultStack()
{
return result;
}
public void setResultStack(@Nonnull ItemStack result)
public void setResultStack(@NotNull ItemStack result)
{
this.result = result;
}
@@ -10,8 +10,7 @@ import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
/**
* {@link LivingEquipmentChangeEvent} is fired when the Equipment of a Entity changes. <br>
@@ -35,7 +34,7 @@ public class LivingEquipmentChangeEvent extends LivingEvent
private final ItemStack from;
private final ItemStack to;
public LivingEquipmentChangeEvent(LivingEntity entity, EquipmentSlot slot, @Nonnull ItemStack from, @Nonnull ItemStack to)
public LivingEquipmentChangeEvent(LivingEntity entity, EquipmentSlot slot, @NotNull ItemStack from, @NotNull ItemStack to)
{
super(entity);
this.slot = slot;
@@ -44,8 +43,8 @@ public class LivingEquipmentChangeEvent extends LivingEvent
}
public EquipmentSlot getSlot() { return this.slot; }
@Nonnull
@NotNull
public ItemStack getFrom() { return this.from; }
@Nonnull
@NotNull
public ItemStack getTo() { return this.to; }
}
@@ -12,8 +12,7 @@ import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.eventbus.api.Event;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
/**
* LivingEvent is fired whenever an event involving Living entities occurs.<br>
@@ -8,8 +8,7 @@ package net.minecraftforge.event.entity.living;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.eventbus.api.Cancelable;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
/**
* Event for when an entity drops experience on its death, can be used to change
@@ -5,18 +5,16 @@
package net.minecraftforge.event.entity.living;
import javax.annotation.Nullable;
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.LevelAccessor;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.eventbus.api.Event.HasResult;
import net.minecraftforge.eventbus.api.Cancelable;
import org.jetbrains.annotations.Nullable;
/**
* LivingSpawnEvent is fired for any events associated with Living Entities spawn status. <br>
@@ -106,29 +104,20 @@ public class LivingSpawnEvent extends LivingEvent
* <br>
* This event is fired via the {@link ForgeEventFactory#doSpecialSpawn(Mob, LevelAccessor, float, float, float, BaseSpawner, MobSpawnType)}.<br>
* <br>
* This event is {@link net.minecraftforge.eventbus.api.Cancelable}.<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}.
**/
@net.minecraftforge.eventbus.api.Cancelable
@Cancelable
public static class SpecialSpawn extends LivingSpawnEvent
{
@Nullable
private final BaseSpawner spawner;
private final MobSpawnType spawnReason;
/**
* @param spawner the position of a tileentity or approximate position of an entity that initiated the spawn if any
*/
@Deprecated(forRemoval = true, since = "1.18.1")
public SpecialSpawn(Mob entity, Level world, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason)
{
this(entity, (LevelAccessor)world, x, y, z, spawner, spawnReason);
}
public SpecialSpawn(Mob entity, LevelAccessor world, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason)
{
super(entity, world, x, y, z);
@@ -7,9 +7,8 @@ package net.minecraftforge.event.entity.living;
import net.minecraft.world.entity.LivingEntity;
import javax.annotation.Nullable;
import net.minecraft.world.damagesource.DamageSource;
import org.jetbrains.annotations.Nullable;
public class LootingLevelEvent extends LivingEvent {
@@ -11,9 +11,8 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
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>
@@ -22,7 +21,7 @@ public class PotionEvent extends LivingEvent
{
@Nullable
protected final MobEffectInstance effect;
public PotionEvent(LivingEntity living, MobEffectInstance effect)
{
super(living);
@@ -36,7 +35,7 @@ public class PotionEvent extends LivingEvent
{
return effect;
}
/**
* This Event is fired when a Potion is about to get removed from an Entity.
* This Event is {@link Cancelable}.
@@ -46,19 +45,19 @@ public class PotionEvent extends LivingEvent
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();
this.potion = effect.getEffect();
}
/**
* @return the Potion which is tried to remove from the Entity.
*/
@@ -66,7 +65,7 @@ public class PotionEvent extends LivingEvent
{
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.
*/
@@ -77,7 +76,7 @@ public class PotionEvent extends LivingEvent
return super.getPotionEffect();
}
}
/**
* This Event is fired to check if a Potion can get applied to an Entity.
* This Event is not {@link Cancelable}
@@ -93,18 +92,18 @@ public class PotionEvent extends LivingEvent
{
super(living, effect);
}
/**
* @return the PotionEffect.
*/
@Override
@Nonnull
@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}
@@ -121,17 +120,17 @@ public class PotionEvent extends LivingEvent
this.oldEffect = oldEffect;
this.source = source;
}
/**
* @return the added PotionEffect. This is the umerged PotionEffect if the old PotionEffect is not null.
*/
@Override
@Nonnull
@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.
*/
@@ -152,7 +151,7 @@ public class PotionEvent extends LivingEvent
return source;
}
}
/**
* This Event is fired when a Potion effect expires on an Entity.
* This Event is not {@link Cancelable}
@@ -165,4 +164,4 @@ public class PotionEvent extends LivingEvent
super(living, effect);
}
}
}
}
@@ -7,8 +7,7 @@ package net.minecraftforge.event.entity.player;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
/**
* Fired when the player removes a "repaired" item from the Anvil's Output slot.
@@ -19,15 +18,15 @@ import javax.annotation.Nonnull;
*/
public class AnvilRepairEvent extends PlayerEvent
{
@Nonnull
@NotNull
private final ItemStack left; // The left side of the input
@Nonnull
@NotNull
private final ItemStack right; // The right side of the input
@Nonnull
@NotNull
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(Player player, @Nonnull ItemStack left, @Nonnull ItemStack right, @Nonnull ItemStack output)
public AnvilRepairEvent(Player player, @NotNull ItemStack left, @NotNull ItemStack right, @NotNull ItemStack output)
{
super(player);
this.output = output;
@@ -40,21 +39,21 @@ public class AnvilRepairEvent extends PlayerEvent
* Get the output result from the anvil
* @return the output
*/
@Nonnull
@NotNull
public ItemStack getItemResult() { return output; }
/**
* Get the first item input into the anvil
* @return the first input slot
*/
@Nonnull
@NotNull
public ItemStack getItemInput() { return left; }
/**
* Get the second item input into the anvil
* @return the second input slot
*/
@Nonnull
@NotNull
public ItemStack getIngredientInput() { return right; }
public float getBreakChance() { return breakChance; }
@@ -12,8 +12,7 @@ import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
/**
* ArrowLooseEvent is fired when a player stops using a bow.<br>
@@ -38,7 +37,7 @@ public class ArrowLooseEvent extends PlayerEvent
private final boolean hasAmmo;
private int charge;
public ArrowLooseEvent(Player player, @Nonnull ItemStack bow, Level world, int charge, boolean hasAmmo)
public ArrowLooseEvent(Player player, @NotNull ItemStack bow, Level world, int charge, boolean hasAmmo)
{
super(player);
this.bow = bow;
@@ -47,7 +46,7 @@ public class ArrowLooseEvent extends PlayerEvent
this.hasAmmo = hasAmmo;
}
@Nonnull
@NotNull
public ItemStack getBow() { return this.bow; }
public Level getWorld() { return this.world; }
public boolean hasAmmo() { return this.hasAmmo; }
@@ -12,8 +12,7 @@ import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.MinecraftForge;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
/**
* ArrowNockEvent is fired when a player begins using a bow.<br>
@@ -30,7 +29,7 @@ public class ArrowNockEvent extends PlayerEvent
private final boolean hasAmmo;
private InteractionResultHolder<ItemStack> action;
public ArrowNockEvent(Player player, @Nonnull ItemStack item, InteractionHand hand, Level world, boolean hasAmmo)
public ArrowNockEvent(Player player, @NotNull ItemStack item, InteractionHand hand, Level world, boolean hasAmmo)
{
super(player);
this.bow = item;
@@ -39,7 +38,7 @@ public class ArrowNockEvent extends PlayerEvent
this.hasAmmo = hasAmmo;
}
@Nonnull
@NotNull
public ItemStack getBow() { return this.bow; }
public Level getWorld() { return this.world; }
public InteractionHand getHand() { return this.hand; }
@@ -11,8 +11,7 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
/**
* This event is called when a player attempts to use Bonemeal on a block.
@@ -33,7 +32,7 @@ public class BonemealEvent extends PlayerEvent
private final BlockState block;
private final ItemStack stack;
public BonemealEvent(@Nonnull Player player, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull BlockState block, @Nonnull ItemStack stack)
public BonemealEvent(@NotNull Player player, @NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState block, @NotNull ItemStack stack)
{
super(player);
this.world = world;
@@ -57,7 +56,7 @@ public class BonemealEvent extends PlayerEvent
return block;
}
@Nonnull
@NotNull
public ItemStack getStack()
{
return stack;
@@ -11,9 +11,8 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.level.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* This event is fired when a player attempts to use a Empty bucket, it
@@ -36,7 +35,7 @@ public class FillBucketEvent extends PlayerEvent
private ItemStack result;
public FillBucketEvent(Player player, @Nonnull ItemStack current, Level world, @Nullable HitResult target)
public FillBucketEvent(Player player, @NotNull ItemStack current, Level world, @Nullable HitResult target)
{
super(player);
this.current = current;
@@ -44,12 +43,12 @@ public class FillBucketEvent extends PlayerEvent
this.target = target;
}
@Nonnull
@NotNull
public ItemStack getEmptyBucket() { return this.current; }
public Level getWorld(){ return this.world; }
@Nullable
public HitResult getTarget() { return this.target; }
@Nonnull
@NotNull
public ItemStack getFilledBucket() { return this.result; }
public void setFilledBucket(@Nonnull ItemStack bucket) { this.result = bucket; }
public void setFilledBucket(@NotNull ItemStack bucket) { this.result = bucket; }
}
@@ -12,14 +12,13 @@ import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.network.chat.Component;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ItemTooltipEvent extends PlayerEvent
{
private final TooltipFlag flags;
@Nonnull
@NotNull
private final ItemStack itemStack;
private final List<Component> toolTip;
@@ -27,7 +26,7 @@ public class ItemTooltipEvent extends PlayerEvent
* 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()}.
*/
public ItemTooltipEvent(@Nonnull ItemStack itemStack, @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags)
public ItemTooltipEvent(@NotNull ItemStack itemStack, @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags)
{
super(entityPlayer);
this.itemStack = itemStack;
@@ -46,7 +45,7 @@ public class ItemTooltipEvent extends PlayerEvent
/**
* The {@link ItemStack} with the tooltip.
*/
@Nonnull
@NotNull
public ItemStack getItemStack()
{
return itemStack;
@@ -21,16 +21,15 @@ import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.eventbus.api.Cancelable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* PlayerDestroyItemEvent is fired when a player destroys an item.<br>
* This event is fired whenever a player destroys an item in
* {@link MultiPlayerGameMode#destroyBlock(BlockPos)},
* {@link MultiPlayerGameMode#useItem(Player, Level, InteractionHand)},
* {@link MultiPlayerGameMode#useItemOn(LocalPlayer, ClientLevel, InteractionHand, BlockHitResult)} ,
* {@link MultiPlayerGameMode#useItem(Player, InteractionHand)},
* {@link MultiPlayerGameMode#useItemOn(LocalPlayer, InteractionHand, BlockHitResult)} ,
* {@link Player#attack(Entity)},
* {@code Player#hurtCurrentlyUsedShield(float)},
* {@link Player#interactOn(Entity, InteractionHand)},
@@ -51,18 +50,18 @@ import javax.annotation.Nullable;
**/
public class PlayerDestroyItemEvent extends PlayerEvent
{
@Nonnull
@NotNull
private final ItemStack original;
@Nullable
private final InteractionHand hand; // May be null if this player destroys the item by any use besides holding it.
public PlayerDestroyItemEvent(Player player, @Nonnull ItemStack original, @Nullable InteractionHand hand)
public PlayerDestroyItemEvent(Player player, @NotNull ItemStack original, @Nullable InteractionHand hand)
{
super(player);
this.original = original;
this.hand = hand;
}
@Nonnull
@NotNull
public ItemStack getOriginal() { return this.original; }
@Nullable
public InteractionHand getHand() { return this.hand; }
@@ -23,9 +23,8 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraftforge.event.entity.living.LivingEvent;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* PlayerEvent is fired whenever an event involving Living entities occurs. <br>
@@ -144,7 +143,7 @@ public class PlayerEvent extends LivingEvent
private final Component username;
private Component displayname;
public NameFormat(Player player, Component username)
public NameFormat(Player player, Component username)
{
super(player);
this.username = username;
@@ -191,7 +190,7 @@ public class PlayerEvent extends LivingEvent
{
super(player);
}
@Nullable
public Component getDisplayName()
{
@@ -408,17 +407,17 @@ public class PlayerEvent extends LivingEvent
}
public static class ItemCraftedEvent extends PlayerEvent {
@Nonnull
@NotNull
private final ItemStack crafting;
private final Container craftMatrix;
public ItemCraftedEvent(Player player, @Nonnull ItemStack crafting, Container craftMatrix)
public ItemCraftedEvent(Player player, @NotNull ItemStack crafting, Container craftMatrix)
{
super(player);
this.crafting = crafting;
this.craftMatrix = craftMatrix;
}
@Nonnull
@NotNull
public ItemStack getCrafting()
{
return this.crafting;
@@ -431,15 +430,15 @@ public class PlayerEvent extends LivingEvent
}
public static class ItemSmeltedEvent extends PlayerEvent {
@Nonnull
@NotNull
private final ItemStack smelting;
public ItemSmeltedEvent(Player player, @Nonnull ItemStack crafting)
public ItemSmeltedEvent(Player player, @NotNull ItemStack crafting)
{
super(player);
this.smelting = crafting;
}
@Nonnull
@NotNull
public ItemStack getSmelting()
{
return this.smelting;
@@ -25,13 +25,12 @@ import net.minecraft.world.level.Level;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static net.minecraftforge.eventbus.api.Event.Result.DEFAULT;
import static net.minecraftforge.eventbus.api.Event.Result.DENY;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* PlayerInteractEvent is fired when a player interacts in some way.
@@ -134,7 +133,7 @@ public class PlayerInteractEvent extends PlayerEvent
* If result equals {@link InteractionResult#PASS}, we proceed to {@link RightClickItem}. <br>
* <br>
* There are various results to this event, see the getters below. <br>
* Note that handling things differently on the client vs server may cause desynchronizations!
* Note that handling things differently on the client vs server may cause desynchronizations!
*/
@Cancelable
public static class RightClickBlock extends PlayerInteractEvent
@@ -311,7 +310,7 @@ public class PlayerInteractEvent extends PlayerEvent
/**
* @return The hand involved in this interaction. Will never be null.
*/
@Nonnull
@NotNull
public InteractionHand getHand()
{
return hand;
@@ -320,7 +319,7 @@ public class PlayerInteractEvent extends PlayerEvent
/**
* @return The itemstack involved in this interaction, {@code ItemStack.EMPTY} if the hand was empty.
*/
@Nonnull
@NotNull
public ItemStack getItemStack()
{
return getPlayer().getItemInHand(hand);
@@ -333,7 +332,7 @@ public class PlayerInteractEvent extends PlayerEvent
* Will never be null.
* @return The position involved in this interaction.
*/
@Nonnull
@NotNull
public BlockPos getPos()
{
return pos;
@@ -10,8 +10,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.entity.player.Player;
import net.minecraft.core.BlockPos;
import net.minecraftforge.eventbus.api.Cancelable;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
/**
* This event is fired when a player's spawn point is set or reset.<br>
@@ -24,7 +23,7 @@ public class PlayerSetSpawnEvent extends PlayerEvent
private final boolean forced;
@Nullable
private final BlockPos newSpawn;
public PlayerSetSpawnEvent(Player player, ResourceKey<Level> spawnWorld, @Nullable BlockPos newSpawn, boolean forced)
{
super(player);
@@ -1,42 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity.player;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event.HasResult;
import javax.annotation.Nonnull;
/**
* 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
@HasResult
// TODO 1.19: Remove
@Deprecated(forRemoval = true, since = "1.18.2")
public class UseHoeEvent extends PlayerEvent
{
private final UseOnContext context;;
public UseHoeEvent(UseOnContext context)
{
super(context.getPlayer());
this.context = context;
}
@Nonnull
public UseOnContext getContext()
{
return context;
}
}