Update to 1.17

Update to Official classnames
Patchwork
Make the game compile and run
Merge in the new HUD overlay API
Merge in the new render properties API
PEEL
Use Gradle 7.2 snapshot to fix eclipse integration bug in 7.1, Would use 7.0 but FG needs 7.1 for some reason.
New FML installer
Update to 1.17.1

Co-authored-by: LexManos <[email protected]>
Co-authored-by: SizableShrimp <[email protected]>
Co-authored-by: cpw <[email protected]>
Co-authored-by: Curle <[email protected]>
Co-authored-by: Unnoen <[email protected]>
Co-authored-by: covers1624 <[email protected]>
Co-authored-by: DaemonUmbra <[email protected]>
Co-authored-by: gigaherz <[email protected]>
Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
authored and Curle committed 2021-07-22 19:57:02 +01:00
1 parent 064ae6961b
commit be5446b91c
1990 files changed
+35661 -37544

No files matched your search

@@ -20,11 +20,10 @@
package net.minecraftforge.event;
import com.google.common.collect.ImmutableList;
import net.minecraft.profiler.IProfiler;
import net.minecraft.resources.DataPackRegistries;
import net.minecraft.resources.IFutureReloadListener;
import net.minecraft.resources.IResourceManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.server.ServerResources;
import net.minecraft.server.packs.resources.PreparableReloadListener;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.ModLoader;
@@ -33,7 +32,7 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import net.minecraft.resources.IFutureReloadListener.IStage;
import net.minecraft.server.packs.resources.PreparableReloadListener.PreparationBarrier;
/**
* The main ResourceManager is recreated on each reload, through {@link DataPackRegistries}'s creation.
@@ -43,10 +42,10 @@ import net.minecraft.resources.IFutureReloadListener.IStage;
*/
public class AddReloadListenerEvent extends Event
{
private final List<IFutureReloadListener> listeners = new ArrayList<>();
private final DataPackRegistries dataPackRegistries;
private final List<PreparableReloadListener> listeners = new ArrayList<>();
private final ServerResources dataPackRegistries;
public AddReloadListenerEvent(DataPackRegistries dataPackRegistries)
public AddReloadListenerEvent(ServerResources dataPackRegistries)
{
this.dataPackRegistries = dataPackRegistries;
}
@@ -54,29 +53,29 @@ public class AddReloadListenerEvent extends Event
/**
* @param listener the listener to add to the ResourceManager on reload
*/
public void addListener(IFutureReloadListener listener)
public void addListener(PreparableReloadListener listener)
{
listeners.add(new WrappedStateAwareListener(listener));
}
public List<IFutureReloadListener> getListeners()
public List<PreparableReloadListener> getListeners()
{
return ImmutableList.copyOf(listeners);
}
public DataPackRegistries getDataPackRegistries()
public ServerResources getDataPackRegistries()
{
return dataPackRegistries;
}
private static class WrappedStateAwareListener implements IFutureReloadListener {
private final IFutureReloadListener wrapped;
private static class WrappedStateAwareListener implements PreparableReloadListener {
private final PreparableReloadListener wrapped;
private WrappedStateAwareListener(final IFutureReloadListener wrapped) {
private WrappedStateAwareListener(final PreparableReloadListener wrapped) {
this.wrapped = wrapped;
}
@Override
public CompletableFuture<Void> reload(final IStage stage, final IResourceManager resourceManager, final IProfiler preparationsProfiler, final IProfiler reloadProfiler, final Executor backgroundExecutor, final Executor gameExecutor) {
public CompletableFuture<Void> reload(final PreparationBarrier stage, final ResourceManager resourceManager, final ProfilerFiller preparationsProfiler, final ProfilerFiller reloadProfiler, final Executor backgroundExecutor, final Executor gameExecutor) {
if (ModLoader.isLoadingStateValid())
return wrapped.reload(stage, resourceManager, preparationsProfiler, reloadProfiler, backgroundExecutor, gameExecutor);
else
@@ -19,9 +19,8 @@
package net.minecraftforge.event;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.RepairContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
@@ -45,16 +44,9 @@ public class AnvilUpdateEvent extends Event
private ItemStack output;
private int cost;
private int materialCost;
@Nullable // TODO: Remove 1.17 - Nullable only in the instance that a mod uses the deprecated ctor.
private final PlayerEntity player;
private final Player player;
@Deprecated //TODO: Remove 1.17 - Use Player-contextual constructor below.
public AnvilUpdateEvent(ItemStack left, ItemStack right, String name, int cost)
{
this(left, right, name, cost, null);
}
public AnvilUpdateEvent(ItemStack left, ItemStack right, String name, int cost, PlayerEntity player)
public AnvilUpdateEvent(ItemStack left, ItemStack right, String name, int cost, Player player)
{
this.left = left;
this.right = right;
@@ -157,11 +149,9 @@ public class AnvilUpdateEvent extends Event
}
/**
* Nullable in the case someone is using the deprecated constructor.
* @return The player using this anvil container.
*/
@Nullable // TODO: Remove 1.17
public PlayerEntity getPlayer()
public Player getPlayer()
{
return this.player;
}
@@ -24,7 +24,7 @@ import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.eventbus.api.GenericEvent;
@@ -20,9 +20,7 @@
package net.minecraftforge.event;
import com.mojang.brigadier.ParseResults;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.commands.CommandSourceStack;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
@@ -43,16 +41,16 @@ import net.minecraftforge.eventbus.api.Event;
@Cancelable
public class CommandEvent extends Event
{
private ParseResults<CommandSource> parse;
private ParseResults<CommandSourceStack> parse;
private Throwable exception;
public CommandEvent(ParseResults<CommandSource> parse)
public CommandEvent(ParseResults<CommandSourceStack> parse)
{
this.parse = parse;
}
public ParseResults<CommandSource> getParseResults() { return parse; }
public void setParseResults(ParseResults<CommandSource> parse) { this.parse = parse; }
public ParseResults<CommandSourceStack> getParseResults() { return parse; }
public void setParseResults(ParseResults<CommandSourceStack> parse) { this.parse = parse; }
public Throwable getException() { return exception; }
public void setException(Throwable exception) { this.exception = exception; }
}
@@ -20,10 +20,7 @@
package net.minecraftforge.event;
import net.minecraft.world.Difficulty;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
* DifficultyChangeEvent is fired when difficulty is changing. <br>
@@ -26,67 +26,64 @@ import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.block.PortalSize;
import net.minecraft.block.BlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.entity.Entity;
import net.minecraft.entity.Pose;
import net.minecraft.entity.EntitySize;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.effect.LightningBoltEntity;
import net.minecraft.entity.item.EnderPearlEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.monster.ZombieEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerEntity.SleepResult;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.entity.projectile.DamagingProjectileEntity;
import net.minecraft.entity.projectile.FireworkRocketEntity;
import net.minecraft.entity.projectile.FishingBobberEntity;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTableManager;
import net.minecraft.resources.IFutureReloadListener;
import net.minecraft.resources.DataPackRegistries;
import net.minecraft.world.spawner.AbstractSpawner;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.Explosion;
import net.minecraft.world.GameRules;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.biome.MobSpawnInfo;
import net.minecraft.world.storage.IServerWorldInfo;
import net.minecraft.world.storage.PlayerData;
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
import net.minecraft.world.level.portal.PortalShape;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.LightningBolt;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.monster.Zombie;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.Player.BedSleepingProblem;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.server.packs.resources.PreparableReloadListener;
import net.minecraft.server.ServerResources;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.InteractionResult;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.core.NonNullList;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.phys.HitResult;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.Level;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.biome.MobSpawnSettings;
import net.minecraft.world.level.storage.ServerLevelData;
import net.minecraft.world.level.storage.PlayerDataStorage;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ClientChatEvent;
@@ -104,11 +101,11 @@ import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.EntityMobGriefingEvent;
import net.minecraftforge.event.entity.EntityMountEvent;
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
import net.minecraftforge.event.entity.EntityTeleportEvent;
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
import net.minecraftforge.event.entity.ProjectileImpactEvent;
import net.minecraftforge.event.entity.item.ItemExpireEvent;
import net.minecraftforge.event.entity.living.AnimalTameEvent;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import net.minecraftforge.event.entity.living.LivingConversionEvent;
import net.minecraftforge.event.entity.living.LivingDestroyBlockEvent;
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
@@ -117,7 +114,6 @@ import net.minecraftforge.event.entity.living.LivingHealEvent;
import net.minecraftforge.event.entity.living.LivingPackSizeEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent.AllowDespawn;
import net.minecraftforge.event.entity.living.EntityTeleportEvent;
import net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent;
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
import net.minecraftforge.event.entity.player.ArrowNockEvent;
@@ -168,32 +164,32 @@ public class ForgeEventFactory
return MinecraftForge.EVENT_BUS.post(event);
}
public static NeighborNotifyEvent onNeighborNotify(World world, BlockPos pos, BlockState state, EnumSet<Direction> notifiedSides, boolean forceRedstoneUpdate)
public static NeighborNotifyEvent onNeighborNotify(Level world, BlockPos pos, BlockState state, EnumSet<Direction> notifiedSides, boolean forceRedstoneUpdate)
{
NeighborNotifyEvent event = new NeighborNotifyEvent(world, pos, state, notifiedSides, forceRedstoneUpdate);
MinecraftForge.EVENT_BUS.post(event);
return event;
}
public static boolean doPlayerHarvestCheck(PlayerEntity player, BlockState state, boolean success)
public static boolean doPlayerHarvestCheck(Player player, BlockState state, boolean success)
{
PlayerEvent.HarvestCheck event = new PlayerEvent.HarvestCheck(player, state, success);
MinecraftForge.EVENT_BUS.post(event);
return event.canHarvest();
}
public static float getBreakSpeed(PlayerEntity player, BlockState state, float original, BlockPos pos)
public static float getBreakSpeed(Player player, BlockState state, float original, BlockPos pos)
{
PlayerEvent.BreakSpeed event = new PlayerEvent.BreakSpeed(player, state, original, pos);
return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getNewSpeed());
}
public static void onPlayerDestroyItem(PlayerEntity player, @Nonnull ItemStack stack, @Nullable Hand hand)
public static void onPlayerDestroyItem(Player player, @Nonnull ItemStack stack, @Nullable InteractionHand hand)
{
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack, hand));
}
public static Result canEntitySpawn(MobEntity entity, IWorld world, double x, double y, double z, AbstractSpawner spawner, SpawnReason spawnReason)
public static Result canEntitySpawn(Mob entity, LevelAccessor world, double x, double y, double z, BaseSpawner spawner, MobSpawnType spawnReason)
{
if (entity == null)
return Result.DEFAULT;
@@ -202,41 +198,35 @@ public class ForgeEventFactory
return event.getResult();
}
public static boolean canEntitySpawnSpawner(MobEntity entity, World world, float x, float y, float z, AbstractSpawner spawner)
public static boolean canEntitySpawnSpawner(Mob entity, Level world, float x, float y, float z, BaseSpawner spawner)
{
Result result = canEntitySpawn(entity, world, x, y, z, spawner, SpawnReason.SPAWNER);
Result result = canEntitySpawn(entity, world, x, y, z, spawner, MobSpawnType.SPAWNER);
if (result == Result.DEFAULT)
return entity.checkSpawnRules(world, SpawnReason.SPAWNER) && entity.checkSpawnObstruction(world); // vanilla logic (inverted)
return entity.checkSpawnRules(world, MobSpawnType.SPAWNER) && entity.checkSpawnObstruction(world); // vanilla logic (inverted)
else
return result == Result.ALLOW;
}
public static boolean doSpecialSpawn(MobEntity entity, World world, float x, float y, float z, AbstractSpawner spawner, SpawnReason spawnReason)
public static boolean doSpecialSpawn(Mob entity, Level world, float x, float y, float z, BaseSpawner spawner, MobSpawnType spawnReason)
{
return MinecraftForge.EVENT_BUS.post(new LivingSpawnEvent.SpecialSpawn(entity, world, x, y, z, spawner, spawnReason));
}
public static Result canEntityDespawn(MobEntity entity)
public static Result canEntityDespawn(Mob entity)
{
AllowDespawn event = new AllowDespawn(entity);
MinecraftForge.EVENT_BUS.post(event);
return event.getResult();
}
@Deprecated // use version with IRecipeType
public static int getItemBurnTime(@Nonnull ItemStack itemStack, int burnTime)
{
return getItemBurnTime(itemStack, burnTime, null);
}
public static int getItemBurnTime(@Nonnull ItemStack itemStack, int burnTime, @Nullable IRecipeType<?> recipeType)
public static int getItemBurnTime(@Nonnull ItemStack itemStack, int burnTime, @Nullable RecipeType<?> recipeType)
{
FurnaceFuelBurnTimeEvent event = new FurnaceFuelBurnTimeEvent(itemStack, burnTime, recipeType);
MinecraftForge.EVENT_BUS.post(event);
return event.getBurnTime();
}
public static int getExperienceDrop(LivingEntity entity, PlayerEntity attackingPlayer, int originalExperience)
public static int getExperienceDrop(LivingEntity entity, Player attackingPlayer, int originalExperience)
{
LivingExperienceDropEvent event = new LivingExperienceDropEvent(entity, attackingPlayer, originalExperience);
if (MinecraftForge.EVENT_BUS.post(event))
@@ -246,58 +236,49 @@ public class ForgeEventFactory
return event.getDroppedExperience();
}
@Nullable
public static List<MobSpawnInfo.Spawners> getPotentialSpawns(IWorld world, EntityClassification type, BlockPos pos, List<MobSpawnInfo.Spawners> oldList)
{
WorldEvent.PotentialSpawns event = new WorldEvent.PotentialSpawns(world, type, pos, oldList);
if (MinecraftForge.EVENT_BUS.post(event))
return Collections.emptyList();
return event.getList();
}
public static int getMaxSpawnPackSize(MobEntity entity)
public static int getMaxSpawnPackSize(Mob entity)
{
LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity);
MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent);
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.getMaxPackSize() : entity.getMaxSpawnClusterSize();
}
public static ITextComponent getPlayerDisplayName(PlayerEntity player, ITextComponent username)
public static Component getPlayerDisplayName(Player player, Component username)
{
PlayerEvent.NameFormat event = new PlayerEvent.NameFormat(player, username);
MinecraftForge.EVENT_BUS.post(event);
return event.getDisplayname();
}
public static ITextComponent getPlayerTabListDisplayName(PlayerEntity player)
public static Component getPlayerTabListDisplayName(Player player)
{
PlayerEvent.TabListNameFormat event = new PlayerEvent.TabListNameFormat(player);
MinecraftForge.EVENT_BUS.post(event);
return event.getDisplayName();
}
public static BlockState fireFluidPlaceBlockEvent(IWorld world, BlockPos pos, BlockPos liquidPos, BlockState state)
public static BlockState fireFluidPlaceBlockEvent(LevelAccessor world, BlockPos pos, BlockPos liquidPos, BlockState state)
{
BlockEvent.FluidPlaceBlockEvent event = new BlockEvent.FluidPlaceBlockEvent(world, pos, liquidPos, state);
MinecraftForge.EVENT_BUS.post(event);
return event.getNewState();
}
public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, @Nullable PlayerEntity entityPlayer, List<ITextComponent> list, ITooltipFlag flags)
public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags)
{
ItemTooltipEvent event = new ItemTooltipEvent(itemStack, entityPlayer, list, flags);
MinecraftForge.EVENT_BUS.post(event);
return event;
}
public static SummonAidEvent fireZombieSummonAid(ZombieEntity zombie, World world, int x, int y, int z, LivingEntity attacker, double summonChance)
public static SummonAidEvent fireZombieSummonAid(Zombie zombie, Level world, int x, int y, int z, LivingEntity attacker, double summonChance)
{
SummonAidEvent summonEvent = new SummonAidEvent(zombie, world, x, y, z, attacker, summonChance);
MinecraftForge.EVENT_BUS.post(summonEvent);
return summonEvent;
}
public static boolean onEntityStruckByLightning(Entity entity, LightningBoltEntity bolt)
public static boolean onEntityStruckByLightning(Entity entity, LightningBolt bolt)
{
return MinecraftForge.EVENT_BUS.post(new EntityStruckByLightningEvent(entity, bolt));
}
@@ -326,33 +307,33 @@ public class ForgeEventFactory
return event.getResultStack();
}
public static void onStartEntityTracking(Entity entity, PlayerEntity player)
public static void onStartEntityTracking(Entity entity, Player player)
{
MinecraftForge.EVENT_BUS.post(new PlayerEvent.StartTracking(player, entity));
}
public static void onStopEntityTracking(Entity entity, PlayerEntity player)
public static void onStopEntityTracking(Entity entity, Player player)
{
MinecraftForge.EVENT_BUS.post(new PlayerEvent.StopTracking(player, entity));
}
public static void firePlayerLoadingEvent(PlayerEntity player, File playerDirectory, String uuidString)
public static void firePlayerLoadingEvent(Player player, File playerDirectory, String uuidString)
{
MinecraftForge.EVENT_BUS.post(new PlayerEvent.LoadFromFile(player, playerDirectory, uuidString));
}
public static void firePlayerSavingEvent(PlayerEntity player, File playerDirectory, String uuidString)
public static void firePlayerSavingEvent(Player player, File playerDirectory, String uuidString)
{
MinecraftForge.EVENT_BUS.post(new PlayerEvent.SaveToFile(player, playerDirectory, uuidString));
}
public static void firePlayerLoadingEvent(PlayerEntity player, PlayerData playerFileData, String uuidString)
public static void firePlayerLoadingEvent(Player player, PlayerDataStorage playerFileData, String uuidString)
{
MinecraftForge.EVENT_BUS.post(new PlayerEvent.LoadFromFile(player, playerFileData.getPlayerDataFolder(), uuidString));
}
@Nullable
public static ITextComponent onClientChat(ChatType type, ITextComponent message, @Nullable UUID senderUUID)
public static Component onClientChat(ChatType type, Component message, @Nullable UUID senderUUID)
{
ClientChatReceivedEvent event = new ClientChatReceivedEvent(type, message, senderUUID);
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage();
@@ -367,7 +348,7 @@ public class ForgeEventFactory
//TODO: 1.17 Remove
@Deprecated
public static int onHoeUse(ItemUseContext context)
public static int onHoeUse(UseOnContext context)
{
UseHoeEvent event = new UseHoeEvent(context);
if (MinecraftForge.EVENT_BUS.post(event)) return -1;
@@ -380,13 +361,13 @@ public class ForgeEventFactory
}
@Nullable
public static BlockState onToolUse(BlockState originalState, World world, BlockPos pos, PlayerEntity player, ItemStack stack, ToolType toolType)
public static BlockState onToolUse(BlockState originalState, Level world, BlockPos pos, Player player, ItemStack stack, ToolType toolType)
{
BlockToolInteractEvent event = new BlockToolInteractEvent(world, pos, originalState, player, stack, toolType);
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getFinalState();
}
public static int onApplyBonemeal(@Nonnull PlayerEntity player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull ItemStack stack)
public static int onApplyBonemeal(@Nonnull Player player, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull ItemStack stack)
{
BonemealEvent event = new BonemealEvent(player, world, pos, state, stack);
if (MinecraftForge.EVENT_BUS.post(event)) return -1;
@@ -400,24 +381,24 @@ public class ForgeEventFactory
}
@Nullable
public static ActionResult<ItemStack> onBucketUse(@Nonnull PlayerEntity player, @Nonnull World world, @Nonnull ItemStack stack, @Nullable RayTraceResult target)
public static InteractionResultHolder<ItemStack> onBucketUse(@Nonnull Player player, @Nonnull Level world, @Nonnull ItemStack stack, @Nullable HitResult target)
{
FillBucketEvent event = new FillBucketEvent(player, stack, world, target);
if (MinecraftForge.EVENT_BUS.post(event)) return new ActionResult<ItemStack>(ActionResultType.FAIL, stack);
if (MinecraftForge.EVENT_BUS.post(event)) return new InteractionResultHolder<ItemStack>(InteractionResult.FAIL, stack);
if (event.getResult() == Result.ALLOW)
{
if (player.abilities.instabuild)
return new ActionResult<ItemStack>(ActionResultType.SUCCESS, stack);
if (player.getAbilities().instabuild)
return new InteractionResultHolder<ItemStack>(InteractionResult.SUCCESS, stack);
stack.shrink(1);
if (stack.isEmpty())
return new ActionResult<ItemStack>(ActionResultType.SUCCESS, event.getFilledBucket());
return new InteractionResultHolder<ItemStack>(InteractionResult.SUCCESS, event.getFilledBucket());
if (!player.inventory.add(event.getFilledBucket()))
if (!player.getInventory().add(event.getFilledBucket()))
player.drop(event.getFilledBucket(), false);
return new ActionResult<ItemStack>(ActionResultType.SUCCESS, stack);
return new InteractionResultHolder<ItemStack>(InteractionResult.SUCCESS, stack);
}
return null;
}
@@ -429,7 +410,7 @@ public class ForgeEventFactory
return event.getCanUpdate();
}
public static PlaySoundAtEntityEvent onPlaySoundAtEntity(Entity entity, SoundEvent name, SoundCategory category, float volume, float pitch)
public static PlaySoundAtEntityEvent onPlaySoundAtEntity(Entity entity, SoundEvent name, SoundSource category, float volume, float pitch)
{
PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(entity, name, category, volume, pitch);
MinecraftForge.EVENT_BUS.post(event);
@@ -444,7 +425,7 @@ public class ForgeEventFactory
return event.getExtraLife();
}
public static int onItemPickup(ItemEntity entityItem, PlayerEntity player)
public static int onItemPickup(ItemEntity entityItem, Player player)
{
Event event = new EntityItemPickupEvent(player, entityItem);
if (MinecraftForge.EVENT_BUS.post(event)) return -1;
@@ -464,44 +445,44 @@ public class ForgeEventFactory
return true;
}
public static boolean onAnimalTame(AnimalEntity animal, PlayerEntity tamer)
public static boolean onAnimalTame(Animal animal, Player tamer)
{
return MinecraftForge.EVENT_BUS.post(new AnimalTameEvent(animal, tamer));
}
public static SleepResult onPlayerSleepInBed(PlayerEntity player, Optional<BlockPos> pos)
public static BedSleepingProblem onPlayerSleepInBed(Player player, Optional<BlockPos> pos)
{
PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(player, pos);
MinecraftForge.EVENT_BUS.post(event);
return event.getResultStatus();
}
public static void onPlayerWakeup(PlayerEntity player, boolean wakeImmediately, boolean updateWorldFlag)
public static void onPlayerWakeup(Player player, boolean wakeImmediately, boolean updateWorldFlag)
{
MinecraftForge.EVENT_BUS.post(new PlayerWakeUpEvent(player, wakeImmediately, updateWorldFlag));
}
public static void onPlayerFall(PlayerEntity player, float distance, float multiplier)
public static void onPlayerFall(Player player, float distance, float multiplier)
{
MinecraftForge.EVENT_BUS.post(new PlayerFlyableFallEvent(player, distance, multiplier));
}
public static boolean onPlayerSpawnSet(PlayerEntity player, RegistryKey<World> world, BlockPos pos, boolean forced)
public static boolean onPlayerSpawnSet(Player player, ResourceKey<Level> world, BlockPos pos, boolean forced)
{
return MinecraftForge.EVENT_BUS.post(new PlayerSetSpawnEvent(player, world, pos, forced));
}
public static void onPlayerClone(PlayerEntity player, PlayerEntity oldPlayer, boolean wasDeath)
public static void onPlayerClone(Player player, Player oldPlayer, boolean wasDeath)
{
MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerEvent.Clone(player, oldPlayer, wasDeath));
}
public static boolean onExplosionStart(World world, Explosion explosion)
public static boolean onExplosionStart(Level world, Explosion explosion)
{
return MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Start(world, explosion));
}
public static void onExplosionDetonate(World world, Explosion explosion, List<Entity> list, double diameter)
public static void onExplosionDetonate(Level world, Explosion explosion, List<Entity> list, double diameter)
{
//Filter entities to only those who are effected, to prevent modders from seeing more then will be hurt.
/* Enable this if we get issues with modders looping to much.
@@ -517,7 +498,7 @@ public class ForgeEventFactory
MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Detonate(world, explosion, list));
}
public static boolean onCreateWorldSpawn(World world, IServerWorldInfo settings)
public static boolean onCreateWorldSpawn(Level world, ServerLevelData settings)
{
return MinecraftForge.EVENT_BUS.post(new WorldEvent.CreateSpawnPosition(world, settings));
}
@@ -555,25 +536,25 @@ public class ForgeEventFactory
MinecraftForge.EVENT_BUS.post(new PotionBrewEvent.Post(brewingItemStacks));
}
public static void onPlayerBrewedPotion(PlayerEntity player, ItemStack stack)
public static void onPlayerBrewedPotion(Player player, ItemStack stack)
{
MinecraftForge.EVENT_BUS.post(new PlayerBrewedPotionEvent(player, stack));
}
@OnlyIn(Dist.CLIENT)
public static boolean renderFireOverlay(PlayerEntity player, MatrixStack mat)
public static boolean renderFireOverlay(Player player, PoseStack mat)
{
return renderBlockOverlay(player, mat, OverlayType.FIRE, Blocks.FIRE.defaultBlockState(), player.blockPosition());
}
@OnlyIn(Dist.CLIENT)
public static boolean renderWaterOverlay(PlayerEntity player, MatrixStack mat)
public static boolean renderWaterOverlay(Player player, PoseStack mat)
{
return renderBlockOverlay(player, mat, OverlayType.WATER, Blocks.WATER.defaultBlockState(), player.blockPosition());
}
@OnlyIn(Dist.CLIENT)
public static boolean renderBlockOverlay(PlayerEntity player, MatrixStack mat, OverlayType type, BlockState block, BlockPos pos)
public static boolean renderBlockOverlay(Player player, PoseStack mat, OverlayType type, BlockState block, BlockPos pos)
{
return MinecraftForge.EVENT_BUS.post(new RenderBlockOverlayEvent(player, mat, type, block, pos));
}
@@ -615,7 +596,7 @@ public class ForgeEventFactory
return canContinueSleep == Result.ALLOW;
}
public static boolean fireSleepingTimeCheck(PlayerEntity player, Optional<BlockPos> sleepingLocation)
public static boolean fireSleepingTimeCheck(Player player, Optional<BlockPos> sleepingLocation)
{
SleepingTimeCheckEvent evt = new SleepingTimeCheckEvent(player, sleepingLocation);
MinecraftForge.EVENT_BUS.post(evt);
@@ -627,15 +608,15 @@ public class ForgeEventFactory
return canContinueSleep == Result.ALLOW;
}
public static ActionResult<ItemStack> onArrowNock(ItemStack item, World world, PlayerEntity player, Hand hand, boolean hasAmmo)
public static InteractionResultHolder<ItemStack> onArrowNock(ItemStack item, Level world, Player player, InteractionHand hand, boolean hasAmmo)
{
ArrowNockEvent event = new ArrowNockEvent(player, item, hand, world, hasAmmo);
if (MinecraftForge.EVENT_BUS.post(event))
return new ActionResult<ItemStack>(ActionResultType.FAIL, item);
return new InteractionResultHolder<ItemStack>(InteractionResult.FAIL, item);
return event.getAction();
}
public static int onArrowLoose(ItemStack stack, World world, PlayerEntity player, int charge, boolean hasAmmo)
public static int onArrowLoose(ItemStack stack, Level world, Player player, int charge, boolean hasAmmo)
{
ArrowLooseEvent event = new ArrowLooseEvent(player, stack, world, charge, hasAmmo);
if (MinecraftForge.EVENT_BUS.post(event))
@@ -643,37 +624,12 @@ public class ForgeEventFactory
return event.getCharge();
}
public static boolean onProjectileImpact(Entity entity, RayTraceResult ray)
public static <T extends Projectile> boolean onProjectileImpact(T projectile, HitResult ray)
{
return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent(entity, ray));
return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent<>(projectile, ray));
}
public static boolean onProjectileImpact(AbstractArrowEntity arrow, RayTraceResult ray)
{
return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.Arrow(arrow, ray));
}
public static boolean onProjectileImpact(DamagingProjectileEntity fireball, RayTraceResult ray)
{
return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.Fireball(fireball, ray));
}
public static boolean onProjectileImpact(ThrowableEntity throwable, RayTraceResult ray)
{
return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.Throwable(throwable, ray));
}
public static boolean onProjectileImpact(FireworkRocketEntity fireworkRocket, RayTraceResult ray)
{
return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.FireworkRocket(fireworkRocket, ray));
}
public static boolean onProjectileImpact(FishingBobberEntity fishingBobber, RayTraceResult ray)
{
return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.FishingBobber(fishingBobber, ray));
}
public static LootTable loadLootTable(ResourceLocation name, LootTable table, LootTableManager lootTableManager)
public static LootTable loadLootTable(ResourceLocation name, LootTable table, LootTables lootTableManager)
{
LootTableLoadEvent event = new LootTableLoadEvent(name, table, lootTableManager);
if (MinecraftForge.EVENT_BUS.post(event))
@@ -681,7 +637,7 @@ public class ForgeEventFactory
return event.getTable();
}
public static boolean canCreateFluidSource(IWorldReader world, BlockPos pos, BlockState state, boolean def)
public static boolean canCreateFluidSource(LevelReader world, BlockPos pos, BlockState state, boolean def)
{
CreateFluidSourceEvent evt = new CreateFluidSourceEvent(world, pos, state);
MinecraftForge.EVENT_BUS.post(evt);
@@ -690,13 +646,13 @@ public class ForgeEventFactory
return result == Result.DEFAULT ? def : result == Result.ALLOW;
}
public static Optional<PortalSize> onTrySpawnPortal(IWorld world, BlockPos pos, Optional<PortalSize> size)
public static Optional<PortalShape> onTrySpawnPortal(LevelAccessor world, BlockPos pos, Optional<PortalShape> size)
{
if (!size.isPresent()) return size;
return !MinecraftForge.EVENT_BUS.post(new BlockEvent.PortalSpawnEvent(world, pos, world.getBlockState(pos), size.get())) ? size : Optional.empty();
}
public static int onEnchantmentLevelSet(World world, BlockPos pos, int enchantRow, int power, ItemStack itemStack, int level)
public static int onEnchantmentLevelSet(Level world, BlockPos pos, int enchantRow, int power, ItemStack itemStack, int level)
{
net.minecraftforge.event.enchanting.EnchantmentLevelSetEvent e = new net.minecraftforge.event.enchanting.EnchantmentLevelSetEvent(world, pos, enchantRow, power, itemStack, level);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(e);
@@ -708,7 +664,7 @@ public class ForgeEventFactory
return !MinecraftForge.EVENT_BUS.post(new LivingDestroyBlockEvent(entity, pos, state));
}
public static boolean getMobGriefingEvent(World world, Entity entity)
public static boolean getMobGriefingEvent(Level world, Entity entity)
{
EntityMobGriefingEvent event = new EntityMobGriefingEvent(entity);
MinecraftForge.EVENT_BUS.post(event);
@@ -717,14 +673,14 @@ public class ForgeEventFactory
return result == Result.DEFAULT ? world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) : result == Result.ALLOW;
}
public static boolean saplingGrowTree(IWorld world, Random rand, BlockPos pos)
public static boolean saplingGrowTree(LevelAccessor world, Random rand, BlockPos pos)
{
SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(world, rand, pos);
MinecraftForge.EVENT_BUS.post(event);
return event.getResult() != Result.DENY;
}
public static void fireChunkWatch(boolean watch, ServerPlayerEntity entity, ChunkPos chunkpos, ServerWorld world)
public static void fireChunkWatch(boolean watch, ServerPlayer entity, ChunkPos chunkpos, ServerLevel world)
{
if (watch)
MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.Watch(entity, chunkpos, world));
@@ -732,50 +688,50 @@ public class ForgeEventFactory
MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.UnWatch(entity, chunkpos, world));
}
public static void fireChunkWatch(boolean wasLoaded, boolean load, ServerPlayerEntity entity, ChunkPos chunkpos, ServerWorld world)
public static void fireChunkWatch(boolean wasLoaded, boolean load, ServerPlayer entity, ChunkPos chunkpos, ServerLevel world)
{
if (wasLoaded != load)
fireChunkWatch(load, entity, chunkpos, world);
}
public static boolean onPistonMovePre(World world, BlockPos pos, Direction direction, boolean extending)
public static boolean onPistonMovePre(Level world, BlockPos pos, Direction direction, boolean extending)
{
return MinecraftForge.EVENT_BUS.post(new PistonEvent.Pre(world, pos, direction, extending ? PistonEvent.PistonMoveType.EXTEND : PistonEvent.PistonMoveType.RETRACT));
}
public static boolean onPistonMovePost(World world, BlockPos pos, Direction direction, boolean extending)
public static boolean onPistonMovePost(Level world, BlockPos pos, Direction direction, boolean extending)
{
return MinecraftForge.EVENT_BUS.post(new PistonEvent.Post(world, pos, direction, extending ? PistonEvent.PistonMoveType.EXTEND : PistonEvent.PistonMoveType.RETRACT));
}
public static long onSleepFinished(ServerWorld world, long newTime, long minTime)
public static long onSleepFinished(ServerLevel world, long newTime, long minTime)
{
SleepFinishedTimeEvent event = new SleepFinishedTimeEvent(world, newTime, minTime);
MinecraftForge.EVENT_BUS.post(event);
return event.getNewTime();
}
public static List<IFutureReloadListener> onResourceReload(DataPackRegistries dataPackRegistries)
public static List<PreparableReloadListener> onResourceReload(ServerResources dataPackRegistries)
{
AddReloadListenerEvent event = new AddReloadListenerEvent(dataPackRegistries);
MinecraftForge.EVENT_BUS.post(event);
return event.getListeners();
}
public static void onCommandRegister(CommandDispatcher<CommandSource> dispatcher, Commands.EnvironmentType environment)
public static void onCommandRegister(CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection environment)
{
RegisterCommandsEvent event = new RegisterCommandsEvent(dispatcher, environment);
MinecraftForge.EVENT_BUS.post(event);
}
public static net.minecraftforge.event.entity.EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntitySize size, float eyeHeight)
public static net.minecraftforge.event.entity.EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntityDimensions size, float eyeHeight)
{
EntityEvent.Size evt = new EntityEvent.Size(entity, pose, size, eyeHeight);
MinecraftForge.EVENT_BUS.post(evt);
return evt;
}
public static net.minecraftforge.event.entity.EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntitySize oldSize, EntitySize newSize, float newEyeHeight)
public static net.minecraftforge.event.entity.EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize, float newEyeHeight)
{
EntityEvent.Size evt = new EntityEvent.Size(entity, pose, oldSize, newSize, entity.getEyeHeight(), newEyeHeight);
MinecraftForge.EVENT_BUS.post(evt);
@@ -809,31 +765,17 @@ public class ForgeEventFactory
public static EntityTeleportEvent.EnderEntity onEnderTeleport(LivingEntity entity, double targetX, double targetY, double targetZ)
{
EntityTeleportEvent.EnderEntity event = new EntityTeleportEvent.EnderEntity(entity, targetX, targetY, targetZ);
onOldEnderTeleport(entity, 0, event); //TODO Forge: Remove this line in 1.17
MinecraftForge.EVENT_BUS.post(event);
return event;
}
public static EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayerEntity entity, double targetX, double targetY, double targetZ, EnderPearlEntity pearlEntity, float attackDamage)
public static EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage)
{
EntityTeleportEvent.EnderPearl event = new EntityTeleportEvent.EnderPearl(entity, targetX, targetY, targetZ, pearlEntity, attackDamage);
event.setAttackDamage(onOldEnderTeleport(entity, attackDamage, event)); //TODO Forge: Remove this line in 1.17
MinecraftForge.EVENT_BUS.post(event);
return event;
}
@SuppressWarnings("deprecation") //TODO Forge: Scrap this method/event in 1.17 - it only exists for backwards-compatibility
private static float onOldEnderTeleport(LivingEntity entity, float attackDamage, EntityTeleportEvent event)
{
EnderTeleportEvent enderEvent = new EnderTeleportEvent(entity, event.getTargetX(), event.getTargetY(), event.getTargetZ(), attackDamage);
MinecraftForge.EVENT_BUS.post(enderEvent);
event.setCanceled(enderEvent.isCanceled());
event.setTargetX(enderEvent.getTargetX());
event.setTargetY(enderEvent.getTargetY());
event.setTargetZ(enderEvent.getTargetZ());
return enderEvent.getAttackDamage();
}
public static EntityTeleportEvent.ChorusFruit onChorusFruitTeleport(LivingEntity entity, double targetX, double targetY, double targetZ)
{
EntityTeleportEvent.ChorusFruit event = new EntityTeleportEvent.ChorusFruit(entity, targetX, targetY, targetZ);
@@ -22,10 +22,10 @@ package net.minecraftforge.event;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimaps;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.entity.ai.attributes.Attribute;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
import com.google.common.collect.Multimap;
import javax.annotation.Nullable;
@@ -44,13 +44,13 @@ import java.util.Collection;
public class ItemAttributeModifierEvent extends Event
{
private final ItemStack stack;
private final EquipmentSlotType slotType;
private final EquipmentSlot slotType;
private final Multimap<Attribute, AttributeModifier> originalModifiers;
private Multimap<Attribute, AttributeModifier> unmodifiableModifiers;
@Nullable
private Multimap<Attribute, AttributeModifier> modifiableModifiers;
public ItemAttributeModifierEvent(ItemStack stack, EquipmentSlotType slotType, Multimap<Attribute, AttributeModifier> modifiers)
public ItemAttributeModifierEvent(ItemStack stack, EquipmentSlot slotType, Multimap<Attribute, AttributeModifier> modifiers)
{
this.stack = stack;
this.slotType = slotType;
@@ -131,7 +131,7 @@ public class ItemAttributeModifierEvent extends Event
}
/** Gets the slot containing this stack */
public EquipmentSlotType getSlotType()
public EquipmentSlot getSlotType()
{
return this.slotType;
}
@@ -19,9 +19,9 @@
package net.minecraftforge.event;
import net.minecraft.util.ResourceLocation;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTableManager;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
@@ -39,9 +39,9 @@ public class LootTableLoadEvent extends Event
{
private final ResourceLocation name;
private LootTable table;
private LootTableManager lootTableManager;
private LootTables lootTableManager;
public LootTableLoadEvent(ResourceLocation name, LootTable table, LootTableManager lootTableManager)
public LootTableLoadEvent(ResourceLocation name, LootTable table, LootTables lootTableManager)
{
this.name = name;
this.table = table;
@@ -58,7 +58,7 @@ public class LootTableLoadEvent extends Event
return this.table;
}
public LootTableManager getLootTableManager()
public LootTables getLootTableManager()
{
return this.lootTableManager;
}
@@ -20,12 +20,12 @@
package net.minecraftforge.event;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.command.*;
import net.minecraft.resources.*;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
/**
* Commands are rebuilt whenever {@link DataPackRegistries} is recreated.
* You can use this event to register your commands whenever the {@link net.minecraft.command.Commands} class in constructed.
@@ -34,21 +34,21 @@ import net.minecraftforge.eventbus.api.Event;
*/
public class RegisterCommandsEvent extends Event
{
private final CommandDispatcher<CommandSource> dispatcher;
private final Commands.EnvironmentType environment;
private final CommandDispatcher<CommandSourceStack> dispatcher;
private final Commands.CommandSelection environment;
public RegisterCommandsEvent(CommandDispatcher<CommandSource> dispatcher, Commands.EnvironmentType environment)
public RegisterCommandsEvent(CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection environment)
{
this.dispatcher = dispatcher;
this.environment = environment;
}
public CommandDispatcher<CommandSource> getDispatcher()
public CommandDispatcher<CommandSourceStack> getDispatcher()
{
return dispatcher;
}
public Commands.EnvironmentType getEnvironment()
public Commands.CommandSelection getEnvironment()
{
return environment;
}
@@ -22,11 +22,11 @@ package net.minecraftforge.event;
import java.util.Collection;
import java.util.stream.Collectors;
import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
import net.minecraftforge.fml.event.IModBusEvent;
import org.apache.commons.lang3.Validate;
import com.google.common.collect.ImmutableList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.eventbus.api.GenericEvent;
import net.minecraftforge.registries.IForgeRegistry;
@@ -19,10 +19,8 @@
package net.minecraftforge.event;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.network.chat.Component;
import net.minecraftforge.eventbus.api.Cancelable;
/**
@@ -46,9 +44,9 @@ import net.minecraftforge.eventbus.api.Cancelable;
public class ServerChatEvent extends net.minecraftforge.eventbus.api.Event
{
private final String message, username;
private final ServerPlayerEntity player;
private ITextComponent component;
public ServerChatEvent(ServerPlayerEntity player, String message, ITextComponent component)
private final ServerPlayer player;
private Component component;
public ServerChatEvent(ServerPlayer player, String message, Component component)
{
super();
this.message = message;
@@ -57,17 +55,17 @@ public class ServerChatEvent extends net.minecraftforge.eventbus.api.Event
this.component = component;
}
public void setComponent(ITextComponent e)
public void setComponent(Component e)
{
this.component = e;
}
public ITextComponent getComponent()
public Component getComponent()
{
return this.component;
}
public String getMessage() { return this.message; }
public String getUsername() { return this.username; }
public ServerPlayerEntity getPlayer() { return this.player; }
public ServerPlayer getPlayer() { return this.player; }
}
@@ -19,7 +19,7 @@
package net.minecraftforge.event;
import net.minecraft.tags.ITagCollectionSupplier;
import net.minecraft.tags.TagContainer;
import net.minecraftforge.eventbus.api.Event;
/**
@@ -31,9 +31,9 @@ import net.minecraftforge.eventbus.api.Event;
*/
public class TagsUpdatedEvent extends Event
{
private final ITagCollectionSupplier manager;
private final TagContainer manager;
public TagsUpdatedEvent(ITagCollectionSupplier manager)
public TagsUpdatedEvent(TagContainer manager)
{
this.manager = manager;
}
@@ -41,7 +41,7 @@ public class TagsUpdatedEvent extends Event
/**
* @return The network tag manager that has been updated with newly received tags.
*/
public ITagCollectionSupplier getTagManager()
public TagContainer getTagManager()
{
return manager;
}
@@ -51,7 +51,7 @@ public class TagsUpdatedEvent extends Event
*/
public static class VanillaTagTypes extends TagsUpdatedEvent
{
public VanillaTagTypes(ITagCollectionSupplier manager)
public VanillaTagTypes(TagContainer manager)
{
super(manager);
}
@@ -62,7 +62,7 @@ public class TagsUpdatedEvent extends Event
*/
public static class CustomTagTypes extends TagsUpdatedEvent
{
public CustomTagTypes(ITagCollectionSupplier manager)
public CustomTagTypes(TagContainer manager)
{
super(manager);
}
@@ -19,9 +19,9 @@
package net.minecraftforge.event;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.world.World;
import net.minecraft.world.entity.player.Player;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.Level;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.LogicalSide;
@@ -59,19 +59,19 @@ public class TickEvent extends Event
}
public static class WorldTickEvent extends TickEvent {
public final World world;
public WorldTickEvent(LogicalSide side, Phase phase, World world)
public final Level world;
public WorldTickEvent(LogicalSide side, Phase phase, Level world)
{
super(Type.WORLD, side, phase);
this.world = world;
}
}
public static class PlayerTickEvent extends TickEvent {
public final PlayerEntity player;
public final Player player;
public PlayerTickEvent(Phase phase, PlayerEntity player)
public PlayerTickEvent(Phase phase, Player player)
{
super(Type.PLAYER, player instanceof ServerPlayerEntity ? LogicalSide.SERVER : LogicalSide.CLIENT, phase);
super(Type.PLAYER, player instanceof ServerPlayer ? LogicalSide.SERVER : LogicalSide.CLIENT, phase);
this.player = player;
}
}
@@ -19,8 +19,8 @@
package net.minecraftforge.event.brewing;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.event.entity.player.PlayerEvent;
import javax.annotation.Nonnull;
@@ -32,7 +32,7 @@ public class PlayerBrewedPotionEvent extends PlayerEvent
{
private final ItemStack stack;
public PlayerBrewedPotionEvent(PlayerEntity player, @Nonnull ItemStack stack)
public PlayerBrewedPotionEvent(Player player, @Nonnull ItemStack stack)
{
super(player);
this.stack = stack;
@@ -19,13 +19,10 @@
package net.minecraftforge.event.brewing;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.BrewingStandTileEntity;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.NonNullList;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;
import javax.annotation.Nonnull;
@@ -19,10 +19,9 @@
package net.minecraftforge.event.enchanting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import javax.annotation.Nonnull;
@@ -36,7 +35,7 @@ import javax.annotation.Nonnull;
*/
public class EnchantmentLevelSetEvent extends net.minecraftforge.eventbus.api.Event
{
private final World world;
private final Level world;
private final BlockPos pos;
private final int enchantRow;
private final int power;
@@ -45,7 +44,7 @@ public class EnchantmentLevelSetEvent extends net.minecraftforge.eventbus.api.Ev
private final int originalLevel;
private int level;
public EnchantmentLevelSetEvent(World world, BlockPos pos, int enchantRow, int power, @Nonnull ItemStack itemStack, int level)
public EnchantmentLevelSetEvent(Level world, BlockPos pos, int enchantRow, int power, @Nonnull ItemStack itemStack, int level)
{
this.world = world;
this.pos = pos;
@@ -61,7 +60,7 @@ public class EnchantmentLevelSetEvent extends net.minecraftforge.eventbus.api.Ev
*
* @return the world object
*/
public World getWorld()
public Level getWorld()
{
return world;
}
@@ -21,12 +21,12 @@ package net.minecraftforge.event.entity;
import java.util.Map;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.DefaultAttributes;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
import net.minecraftforge.fml.event.IModBusEvent;
/**
* EntityAttributeCreationEvent.<br>
@@ -37,16 +37,16 @@ import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
**/
public class EntityAttributeCreationEvent extends Event implements IModBusEvent
{
private final Map<EntityType<? extends LivingEntity>, AttributeModifierMap> map;
private final Map<EntityType<? extends LivingEntity>, AttributeSupplier> map;
public EntityAttributeCreationEvent(Map<EntityType<? extends LivingEntity>, AttributeModifierMap> map)
public EntityAttributeCreationEvent(Map<EntityType<? extends LivingEntity>, AttributeSupplier> map)
{
this.map = map;
}
public void put(EntityType<? extends LivingEntity> entity, AttributeModifierMap map)
public void put(EntityType<? extends LivingEntity> entity, AttributeSupplier map)
{
if (GlobalEntityTypeAttributes.hasSupplier(entity))
if (DefaultAttributes.hasSupplier(entity))
throw new IllegalStateException("Duplicate GlobalEntityTypeAttributes entry: " + entity);
this.map.put(entity, map);
}
@@ -20,13 +20,13 @@
package net.minecraftforge.event.entity;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.attributes.Attribute;
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.DefaultAttributes;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
import net.minecraftforge.fml.event.IModBusEvent;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.List;
@@ -42,16 +42,16 @@ import java.util.stream.Collectors;
**/
public class EntityAttributeModificationEvent extends Event implements IModBusEvent
{
private final Map<EntityType<? extends LivingEntity>, AttributeModifierMap.MutableAttribute> entityAttributes;
private final Map<EntityType<? extends LivingEntity>, AttributeSupplier.Builder> entityAttributes;
private final List<EntityType<? extends LivingEntity>> entityTypes;
@SuppressWarnings("unchecked")
public EntityAttributeModificationEvent(Map<EntityType<? extends LivingEntity>, AttributeModifierMap.MutableAttribute> mapIn)
public EntityAttributeModificationEvent(Map<EntityType<? extends LivingEntity>, AttributeSupplier.Builder> mapIn)
{
this.entityAttributes = mapIn;
this.entityTypes = ImmutableList.copyOf(
ForgeRegistries.ENTITIES.getValues().stream()
.filter(GlobalEntityTypeAttributes::hasSupplier)
.filter(DefaultAttributes::hasSupplier)
.map(entityType -> (EntityType<? extends LivingEntity>) entityType)
.collect(Collectors.toList())
);
@@ -59,8 +59,8 @@ public class EntityAttributeModificationEvent extends Event implements IModBusEv
public void add(EntityType<? extends LivingEntity> entityType, Attribute attribute, double value)
{
AttributeModifierMap.MutableAttribute attributes = entityAttributes.computeIfAbsent(entityType,
(type) -> new AttributeModifierMap.MutableAttribute());
AttributeSupplier.Builder attributes = entityAttributes.computeIfAbsent(entityType,
(type) -> new AttributeSupplier.Builder());
attributes.add(attribute, value);
}
@@ -71,7 +71,7 @@ public class EntityAttributeModificationEvent extends Event implements IModBusEv
public boolean has(EntityType<? extends LivingEntity> entityType, Attribute attribute)
{
AttributeModifierMap globalMap = GlobalEntityTypeAttributes.getSupplier(entityType);
AttributeSupplier globalMap = DefaultAttributes.getSupplier(entityType);
return globalMap.hasAttribute(attribute) || (entityAttributes.get(entityType) != null && entityAttributes.get(entityType).hasAttribute(attribute));
}
@@ -19,13 +19,9 @@
package net.minecraftforge.event.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntitySize;
import net.minecraft.entity.Pose;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.Pose;
import net.minecraftforge.eventbus.api.Event;
/**
@@ -100,43 +96,6 @@ public class EntityEvent extends Event
this.canUpdate = canUpdate;
}
}
/**
* EnteringChunk is fired when an Entity enters a chunk. <br>
* This event is fired whenever vanilla Minecraft determines that an entity <br>
* is entering a chunk in {@link Chunk#addEntity(net.minecraft.entity.Entity)} <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult}
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public static class EnteringChunk extends EntityEvent
{
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.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; }
}
/**
* This event is fired whenever the {@link Pose} changes, and in a few other hardcoded scenarios.<br>
@@ -152,17 +111,17 @@ public class EntityEvent extends Event
public static class Size extends EntityEvent
{
private final Pose pose;
private final EntitySize oldSize;
private EntitySize newSize;
private final EntityDimensions oldSize;
private EntityDimensions newSize;
private final float oldEyeHeight;
private float newEyeHeight;
public Size(Entity entity, Pose pose, EntitySize size, float defaultEyeHeight)
public Size(Entity entity, Pose pose, EntityDimensions size, float defaultEyeHeight)
{
this(entity, pose, size, size, defaultEyeHeight, defaultEyeHeight);
}
public Size(Entity entity, Pose pose, EntitySize oldSize, EntitySize newSize, float oldEyeHeight, float newEyeHeight)
public Size(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize, float oldEyeHeight, float newEyeHeight)
{
super(entity);
this.pose = pose;
@@ -174,9 +133,9 @@ public class EntityEvent extends Event
public Pose getPose() { return pose; }
public EntitySize getOldSize() { return oldSize; }
public EntitySize getNewSize() { return newSize; }
public void setNewSize(EntitySize size)
public EntityDimensions getOldSize() { return oldSize; }
public EntityDimensions getNewSize() { return newSize; }
public void setNewSize(EntityDimensions size)
{
setNewSize(size, false);
}
@@ -184,7 +143,7 @@ public class EntityEvent extends Event
/**
* Set the new size of the entity. Set updateEyeHeight to true to also update the eye height according to the new size.
*/
public void setNewSize(EntitySize size, boolean updateEyeHeight)
public void setNewSize(EntityDimensions size, boolean updateEyeHeight)
{
this.newSize = size;
if (updateEyeHeight)
@@ -19,12 +19,8 @@
package net.minecraftforge.event.entity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import java.util.Collection;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
/**
* EntityJoinWorldEvent is fired when an Entity joins the world. <br>
@@ -45,15 +41,15 @@ import java.util.Collection;
public class EntityJoinWorldEvent extends EntityEvent
{
private final World world;
private final Level world;
public EntityJoinWorldEvent(Entity entity, World world)
public EntityJoinWorldEvent(Entity entity, Level world)
{
super(entity);
this.world = world;
}
public World getWorld()
public Level getWorld()
{
return world;
}
@@ -19,12 +19,8 @@
package net.minecraftforge.event.entity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
/**
* EntityLeaveWorldEvent is fired when an Entity leaves the world. <br>
@@ -42,15 +38,15 @@ import net.minecraft.world.World;
public class EntityLeaveWorldEvent extends EntityEvent
{
private final World world;
private final Level world;
public EntityLeaveWorldEvent(Entity entity, World world)
public EntityLeaveWorldEvent(Entity entity, Level world)
{
super(entity);
this.world = world;
}
public World getWorld()
public Level getWorld()
{
return world;
}
@@ -19,8 +19,7 @@
package net.minecraftforge.event.entity;
import net.minecraft.entity.Entity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.Entity;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
@@ -19,11 +19,9 @@
package net.minecraftforge.event.entity;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
* This event gets fired whenever a entity mounts/dismounts another entity.<br>
@@ -45,11 +43,11 @@ public class EntityMountEvent extends EntityEvent
private final Entity entityMounting;
private final Entity entityBeingMounted;
private final World worldObj;
private final Level worldObj;
private final boolean isMounting;
public EntityMountEvent(Entity entityMounting, Entity entityBeingMounted, World entityWorld, boolean isMounting)
public EntityMountEvent(Entity entityMounting, Entity entityBeingMounted, Level entityWorld, boolean isMounting)
{
super(entityMounting);
this.entityMounting = entityMounting;
@@ -78,7 +76,7 @@ public class EntityMountEvent extends EntityEvent
return entityBeingMounted;
}
public World getWorldObj()
public Level getWorldObj()
{
return worldObj;
}
@@ -19,11 +19,8 @@
package net.minecraftforge.event.entity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.LightningBoltEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LightningBolt;
/**
* EntityStruckByLightningEvent is fired when an Entity is about to be struck by lightening.<br>
@@ -42,15 +39,15 @@ import net.minecraft.entity.effect.LightningBoltEntity;
@net.minecraftforge.eventbus.api.Cancelable
public class EntityStruckByLightningEvent extends EntityEvent
{
private final LightningBoltEntity lightning;
private final LightningBolt lightning;
public EntityStruckByLightningEvent(Entity entity, LightningBoltEntity lightning)
public EntityStruckByLightningEvent(Entity entity, LightningBolt lightning)
{
super(entity);
this.lightning = lightning;
}
public LightningBoltEntity getLightning()
public LightningBolt getLightning()
{
return lightning;
}
@@ -17,15 +17,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.entity.living;
package net.minecraftforge.event.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.EnderPearlEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.eventbus.api.Cancelable;
/**
@@ -38,6 +36,7 @@ import net.minecraftforge.eventbus.api.Cancelable;
* <br>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
@Cancelable
public class EntityTeleportEvent extends EntityEvent
{
protected double targetX;
@@ -57,11 +56,11 @@ public class EntityTeleportEvent extends EntityEvent
public void setTargetY(double targetY) { this.targetY = targetY; }
public double getTargetZ() { return targetZ; }
public void setTargetZ(double targetZ) { this.targetZ = targetZ; }
public Vector3d getTarget() { return new Vector3d(this.targetX, this.targetY, this.targetZ); }
public Vec3 getTarget() { return new Vec3(this.targetX, this.targetY, this.targetZ); }
public double getPrevX() { return getEntity().getX(); }
public double getPrevY() { return getEntity().getY(); }
public double getPrevZ() { return getEntity().getZ(); }
public Vector3d getPrev() { return getEntity().position(); }
public Vec3 getPrev() { return getEntity().position(); }
/**
* EntityTeleportEvent.TeleportCommand is fired before a living entity is teleported
@@ -159,11 +158,11 @@ public class EntityTeleportEvent extends EntityEvent
@Cancelable
public static class EnderPearl extends EntityTeleportEvent
{
private final ServerPlayerEntity player;
private final EnderPearlEntity pearlEntity;
private final ServerPlayer player;
private final ThrownEnderpearl pearlEntity;
private float attackDamage;
public EnderPearl(ServerPlayerEntity entity, double targetX, double targetY, double targetZ, EnderPearlEntity pearlEntity, float attackDamage)
public EnderPearl(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage)
{
super(entity, targetX, targetY, targetZ);
this.pearlEntity = pearlEntity;
@@ -171,12 +170,12 @@ public class EntityTeleportEvent extends EntityEvent
this.attackDamage = attackDamage;
}
public EnderPearlEntity getPearlEntity()
public ThrownEnderpearl getPearlEntity()
{
return pearlEntity;
}
public ServerPlayerEntity getPlayer()
public ServerPlayer getPlayer()
{
return player;
}
@@ -19,12 +19,10 @@
package net.minecraftforge.event.entity;
import net.minecraft.entity.Entity;
import net.minecraft.util.RegistryKey;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.Entity;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.Level;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
* EntityTravelToDimensionEvent is fired before an Entity travels to a dimension.<br>
@@ -41,15 +39,15 @@ import net.minecraftforge.eventbus.api.Event.HasResult;
@Cancelable
public class EntityTravelToDimensionEvent extends EntityEvent
{
private final RegistryKey<World> dimension;
private final ResourceKey<Level> dimension;
public EntityTravelToDimensionEvent(Entity entity, RegistryKey<World> dimension)
public EntityTravelToDimensionEvent(Entity entity, ResourceKey<Level> dimension)
{
super(entity);
this.dimension = dimension;
}
public RegistryKey<World> getDimension()
public ResourceKey<Level> getDimension()
{
return dimension;
}
@@ -19,14 +19,9 @@
package net.minecraftforge.event.entity;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.Entity;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.world.entity.Entity;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvent;
/**
* PlaySoundAtEntityEvent is fired a sound is to be played at an Entity<br>
@@ -51,13 +46,13 @@ import net.minecraft.util.SoundEvent;
public class PlaySoundAtEntityEvent extends EntityEvent
{
private SoundEvent name;
private SoundCategory category;
private SoundSource category;
private final float volume;
private final float pitch;
private float newVolume;
private float newPitch;
public PlaySoundAtEntityEvent(Entity entity, SoundEvent name, SoundCategory category, float volume, float pitch)
public PlaySoundAtEntityEvent(Entity entity, SoundEvent name, SoundSource category, float volume, float pitch)
{
super(entity);
this.name = name;
@@ -69,13 +64,13 @@ public class PlaySoundAtEntityEvent extends EntityEvent
}
public SoundEvent getSound() { return this.name; }
public SoundCategory getCategory() { return this.category; }
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(SoundCategory category) { this.category = category; }
public void setCategory(SoundSource category) { this.category = category; }
public void setVolume(float value) { this.newVolume = value; }
public void setPitch(float value) { this.newPitch = value; }
}
@@ -19,131 +19,41 @@
package net.minecraftforge.event.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.entity.projectile.DamagingProjectileEntity;
import net.minecraft.entity.projectile.FireworkRocketEntity;
import net.minecraft.entity.projectile.FishingBobberEntity;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.phys.HitResult;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* This event is fired when a projectile entity impacts something.
* This event is fired via {@link ForgeEventFactory#onProjectileImpact(Entity, RayTraceResult)}
* Subclasses of this event exist for more specific types of projectile.
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
* This event is fired when a projectile entity impacts something.<br>
* This event is fired via {@link ForgeEventFactory#onProjectileImpact(Projectile, HitResult)}
* This event is fired for all vanilla projectiles by Forge,
* custom projectiles should fire this event and check the result in a similar fashion.
* This event is cancelable. When canceled, the impact will not be processed.
* This event is cancelable. When canceled, the impact will not be processed and the projectile will continue flying.
* Killing or other handling of the entity after event cancellation is up to the modder.
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
*/
@Cancelable
public class ProjectileImpactEvent extends EntityEvent
public class ProjectileImpactEvent<T extends Projectile> extends EntityEvent
{
private final RayTraceResult ray;
private final HitResult ray;
private final T projectile;
public ProjectileImpactEvent(Entity entity, RayTraceResult ray)
public ProjectileImpactEvent(T projectile, HitResult ray)
{
super(entity);
super(projectile);
this.ray = ray;
this.projectile = projectile;
}
public RayTraceResult getRayTraceResult()
public HitResult getRayTraceResult()
{
return ray;
}
@Cancelable
public static class Arrow extends ProjectileImpactEvent
public T getProjectile()
{
private final AbstractArrowEntity arrow;
public Arrow(AbstractArrowEntity arrow, RayTraceResult ray)
{
super(arrow, ray);
this.arrow = arrow;
}
public AbstractArrowEntity getArrow()
{
return arrow;
}
}
@Cancelable
public static class Fireball extends ProjectileImpactEvent
{
private final DamagingProjectileEntity fireball;
public Fireball(DamagingProjectileEntity fireball, RayTraceResult ray)
{
super(fireball, ray);
this.fireball = fireball;
}
public DamagingProjectileEntity getFireball()
{
return fireball;
}
}
@Cancelable
public static class Throwable extends ProjectileImpactEvent
{
private final ThrowableEntity throwable;
public Throwable(ThrowableEntity throwable, RayTraceResult ray)
{
super(throwable, ray);
this.throwable = throwable;
}
public ThrowableEntity getThrowable()
{
return throwable;
}
}
/**
* Event is cancellable, causes firework to ignore the current hit and continue on its journey.
*/
@Cancelable
public static class FireworkRocket extends ProjectileImpactEvent
{
private final FireworkRocketEntity fireworkRocket;
public FireworkRocket(FireworkRocketEntity fireworkRocket, RayTraceResult ray)
{
super(fireworkRocket, ray);
this.fireworkRocket = fireworkRocket;
}
public FireworkRocketEntity getFireworkRocket()
{
return fireworkRocket;
}
}
/**
* Event is cancellable, causes bobber to ignore the current hit and continue on its journey.
*/
@Cancelable
public static class FishingBobber extends ProjectileImpactEvent
{
private final FishingBobberEntity fishingBobber;
public FishingBobber(FishingBobberEntity fishingBobber, RayTraceResult ray)
{
super(fishingBobber, ray);
this.fishingBobber = fishingBobber;
}
public FishingBobberEntity getFishingBobber()
{
return fishingBobber;
}
return projectile;
}
}
@@ -19,7 +19,7 @@
package net.minecraftforge.event.entity.item;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraftforge.event.entity.EntityEvent;
/**
@@ -20,7 +20,7 @@
package net.minecraftforge.event.entity.item;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.world.entity.item.ItemEntity;
/**
* Event that is fired when an EntityItem's age has reached its maximum
@@ -20,8 +20,8 @@
package net.minecraftforge.event.entity.item;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
/**
* Event that is fired whenever a player tosses (Q) an item or drag-n-drops a
@@ -33,7 +33,7 @@ import net.minecraft.entity.player.PlayerEntity;
public class ItemTossEvent extends ItemEvent
{
private final PlayerEntity player;
private final Player player;
/**
* Creates a new event for EntityItems tossed by a player.
@@ -41,7 +41,7 @@ public class ItemTossEvent extends ItemEvent
* @param entityItem The EntityItem being tossed.
* @param player The player tossing the item.
*/
public ItemTossEvent(ItemEntity entityItem, PlayerEntity player)
public ItemTossEvent(ItemEntity entityItem, Player player)
{
super(entityItem);
this.player = player;
@@ -50,7 +50,7 @@ public class ItemTossEvent extends ItemEvent
/**
* The player tossing the item.
*/
public PlayerEntity getPlayer()
public Player getPlayer()
{
return player;
}
@@ -19,10 +19,8 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.eventbus.api.Cancelable;
/**
@@ -35,22 +33,22 @@ import net.minecraftforge.eventbus.api.Cancelable;
@Cancelable
public class AnimalTameEvent extends LivingEvent
{
private final AnimalEntity animal;
private final PlayerEntity tamer;
private final Animal animal;
private final Player tamer;
public AnimalTameEvent(AnimalEntity animal, PlayerEntity tamer)
public AnimalTameEvent(Animal animal, Player tamer)
{
super(animal);
this.animal = animal;
this.tamer = tamer;
}
public AnimalEntity getAnimal()
public Animal getAnimal()
{
return animal;
}
public PlayerEntity getTamer()
public Player getTamer()
{
return tamer;
}
@@ -19,11 +19,10 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.AgeableEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.eventbus.api.Cancelable;
import javax.annotation.Nullable;
@@ -49,22 +48,22 @@ import javax.annotation.Nullable;
@Cancelable
public class BabyEntitySpawnEvent extends net.minecraftforge.eventbus.api.Event
{
private final MobEntity parentA;
private final MobEntity parentB;
private final PlayerEntity causedByPlayer;
private AgeableEntity child;
private final Mob parentA;
private final Mob parentB;
private final Player causedByPlayer;
private AgeableMob child;
public BabyEntitySpawnEvent(MobEntity parentA, MobEntity parentB, @Nullable AgeableEntity proposedChild)
public BabyEntitySpawnEvent(Mob parentA, Mob parentB, @Nullable AgeableMob proposedChild)
{
//causedByPlayer calculated here to simplify the patch.
PlayerEntity causedByPlayer = null;
if (parentA instanceof AnimalEntity) {
causedByPlayer = ((AnimalEntity)parentA).getLoveCause();
Player causedByPlayer = null;
if (parentA instanceof Animal) {
causedByPlayer = ((Animal)parentA).getLoveCause();
}
if (causedByPlayer == null && parentB instanceof AnimalEntity)
if (causedByPlayer == null && parentB instanceof Animal)
{
causedByPlayer = ((AnimalEntity)parentB).getLoveCause();
causedByPlayer = ((Animal)parentB).getLoveCause();
}
this.parentA = parentA;
@@ -73,29 +72,29 @@ public class BabyEntitySpawnEvent extends net.minecraftforge.eventbus.api.Event
this.child = proposedChild;
}
public MobEntity getParentA()
public Mob getParentA()
{
return parentA;
}
public MobEntity getParentB()
public Mob getParentB()
{
return parentB;
}
@Nullable
public PlayerEntity getCausedByPlayer()
public Player getCausedByPlayer()
{
return causedByPlayer;
}
@Nullable
public AgeableEntity getChild()
public AgeableMob getChild()
{
return child;
}
public void setChild(AgeableEntity proposedChild)
public void setChild(AgeableMob proposedChild)
{
child = proposedChild;
}
@@ -1,57 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2021.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.entity.living;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.LivingEntity;
/**
* Event for when an Enderman/Shulker teleports or an ender pearl is used. Can be used to either modify the target position, or cancel the teleport outright.
* @author Mithion
* @deprecated Use {@link EntityTeleportEvent.EnderEntity} or {@link EntityTeleportEvent.EnderPearl}.
*/
@Deprecated //TODO Forge: Remove in 1.17
@Cancelable
public class EnderTeleportEvent extends LivingEvent
{
private double targetX;
private double targetY;
private double targetZ;
private float attackDamage;
public EnderTeleportEvent(LivingEntity entity, double targetX, double targetY, double targetZ, float attackDamage)
{
super(entity);
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; }
}
@@ -19,11 +19,9 @@
package net.minecraftforge.event.entity.living;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.util.DamageSource;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity;
/**
* LivingAttackEvent is fired when a living Entity is attacked. <br>
@@ -19,8 +19,8 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.eventbus.api.Cancelable;
import java.util.function.Consumer;
@@ -19,10 +19,9 @@
package net.minecraftforge.event.entity.living;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.util.DamageSource;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity;
/**
* LivingDamageEvent is fired just before damage is applied to entity.<br>
@@ -19,11 +19,9 @@
package net.minecraftforge.event.entity.living;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.util.DamageSource;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity;
/**
* LivingDeathEvent is fired when an Entity dies. <br>
@@ -19,12 +19,9 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.core.BlockPos;
import net.minecraftforge.eventbus.api.Cancelable;
/**
@@ -19,15 +19,11 @@
package net.minecraftforge.event.entity.living;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.util.DamageSource;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.LivingEntity;
/**
* LivingDropsEvent is fired when an Entity's death causes dropped items to appear.<br>
@@ -19,8 +19,8 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.Cancelable;
import javax.annotation.Nonnull;
@@ -19,11 +19,9 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.LivingEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull;
@@ -45,11 +43,11 @@ import javax.annotation.Nonnull;
**/
public class LivingEquipmentChangeEvent extends LivingEvent
{
private final EquipmentSlotType slot;
private final EquipmentSlot slot;
private final ItemStack from;
private final ItemStack to;
public LivingEquipmentChangeEvent(LivingEntity entity, EquipmentSlotType slot, @Nonnull ItemStack from, @Nonnull ItemStack to)
public LivingEquipmentChangeEvent(LivingEntity entity, EquipmentSlot slot, @Nonnull ItemStack from, @Nonnull ItemStack to)
{
super(entity);
this.slot = slot;
@@ -57,7 +55,7 @@ public class LivingEquipmentChangeEvent extends LivingEvent
this.to = to;
}
public EquipmentSlotType getSlot() { return this.slot; }
public EquipmentSlot getSlot() { return this.slot; }
@Nonnull
public ItemStack getFrom() { return this.from; }
@Nonnull
@@ -19,11 +19,9 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.Entity;
import net.minecraft.world.entity.Entity;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.LivingEntity;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.event.entity.EntityEvent;
import javax.annotation.Nullable;
@@ -19,8 +19,8 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.eventbus.api.Cancelable;
/**
@@ -31,12 +31,12 @@ import net.minecraftforge.eventbus.api.Cancelable;
@Cancelable
public class LivingExperienceDropEvent extends LivingEvent
{
private final PlayerEntity attackingPlayer;
private final Player attackingPlayer;
private final int originalExperiencePoints;
private int droppedExperiencePoints;
public LivingExperienceDropEvent(LivingEntity entity, PlayerEntity attackingPlayer, int originalExperience)
public LivingExperienceDropEvent(LivingEntity entity, Player attackingPlayer, int originalExperience)
{
super(entity);
@@ -54,7 +54,7 @@ public class LivingExperienceDropEvent extends LivingEvent
this.droppedExperiencePoints = droppedExperience;
}
public PlayerEntity getAttackingPlayer()
public Player getAttackingPlayer()
{
return attackingPlayer;
}
@@ -19,10 +19,8 @@
package net.minecraftforge.event.entity.living;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.entity.LivingEntity;
/**
* LivingFallEvent is fired when an Entity is set to be falling.<br>
@@ -19,10 +19,8 @@
package net.minecraftforge.event.entity.living;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.entity.LivingEntity;
/**
* LivingHealEvent is fired when an Entity is set to be healed. <br>
@@ -19,11 +19,8 @@
package net.minecraftforge.event.entity.living;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.util.DamageSource;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity;
/**
* LivingHurtEvent is fired when an Entity is set to be hurt. <br>
@@ -19,11 +19,7 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.DamageSource;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.eventbus.api.Cancelable;
/**
@@ -20,14 +20,14 @@
package net.minecraftforge.event.entity.living;
import net.minecraftforge.eventbus.api.Event.HasResult;
import net.minecraft.entity.MobEntity;
import net.minecraft.world.entity.Mob;
@HasResult
public class LivingPackSizeEvent extends LivingEvent
{
private int maxPackSize;
public LivingPackSizeEvent(MobEntity entity)
public LivingPackSizeEvent(Mob entity)
{
super(entity);
}
@@ -19,9 +19,7 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.LivingEntity;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.LivingEntity;
/**
* LivingSetAttackTargetEvent is fired when an Entity sets a target to attack.<br>
@@ -20,14 +20,11 @@
package net.minecraftforge.event.entity.living;
import javax.annotation.Nullable;
import net.minecraft.world.spawner.AbstractSpawner;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.SpawnReason;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
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.eventbus.api.Event.HasResult;
@@ -45,12 +42,12 @@ import net.minecraftforge.eventbus.api.Event.HasResult;
**/
public class LivingSpawnEvent extends LivingEvent
{
private final IWorld world;
private final LevelAccessor world;
private final double x;
private final double y;
private final double z;
public LivingSpawnEvent(MobEntity entity, IWorld world, double x, double y, double z)
public LivingSpawnEvent(Mob entity, LevelAccessor world, double x, double y, double z)
{
super(entity);
this.world = world;
@@ -59,7 +56,7 @@ public class LivingSpawnEvent extends LivingEvent
this.z = z;
}
public IWorld getWorld() { return world; }
public LevelAccessor getWorld() { return world; }
public double getX() { return x; }
public double getY() { return y; }
public double getZ() { return z; }
@@ -76,8 +73,8 @@ public class LivingSpawnEvent extends LivingEvent
public static class CheckSpawn extends LivingSpawnEvent
{
@Nullable
private final AbstractSpawner spawner;
private final SpawnReason spawnReason;
private final BaseSpawner spawner;
private final MobSpawnType spawnReason;
/**
* CheckSpawn is fired when an Entity is about to be spawned.
@@ -89,7 +86,7 @@ public class LivingSpawnEvent extends LivingEvent
* @param spawner position of the MobSpawner
* null if it this spawn is coming from a WorldSpawner
*/
public CheckSpawn(MobEntity entity, IWorld world, double x, double y, double z, @Nullable AbstractSpawner spawner, SpawnReason spawnReason)
public CheckSpawn(Mob entity, LevelAccessor world, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason)
{
super(entity, world, x, y, z);
this.spawner = spawner;
@@ -102,12 +99,12 @@ public class LivingSpawnEvent extends LivingEvent
}
@Nullable
public AbstractSpawner getSpawner()
public BaseSpawner getSpawner()
{
return spawner;
}
public SpawnReason getSpawnReason()
public MobSpawnType getSpawnReason()
{
return spawnReason;
}
@@ -130,13 +127,13 @@ public class LivingSpawnEvent extends LivingEvent
public static class SpecialSpawn extends LivingSpawnEvent
{
@Nullable
private final AbstractSpawner spawner;
private final SpawnReason spawnReason;
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
*/
public SpecialSpawn(MobEntity entity, World world, double x, double y, double z, @Nullable AbstractSpawner spawner, SpawnReason spawnReason)
public SpecialSpawn(Mob entity, Level world, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason)
{
super(entity, world, x, y, z);
this.spawner = spawner;
@@ -144,12 +141,12 @@ public class LivingSpawnEvent extends LivingEvent
}
@Nullable
public AbstractSpawner getSpawner()
public BaseSpawner getSpawner()
{
return spawner;
}
public SpawnReason getSpawnReason()
public MobSpawnType getSpawnReason()
{
return spawnReason;
}
@@ -171,7 +168,7 @@ public class LivingSpawnEvent extends LivingEvent
@HasResult
public static class AllowDespawn extends LivingSpawnEvent
{
public AllowDespawn(MobEntity entity)
public AllowDespawn(Mob entity)
{
super(entity, entity.level, entity.getX(), entity.getY(), entity.getZ());
}
@@ -19,8 +19,8 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.damagesource.DamageSource;
public class LootingLevelEvent extends LivingEvent {
@@ -21,8 +21,8 @@ package net.minecraftforge.event.entity.living;
import java.util.Collection;
import java.util.Collections;
import net.minecraft.entity.LivingEntity;
import net.minecraft.potion.EffectInstance;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.effect.MobEffectInstance;
/**
* Fires after Potion Color Calculation.
@@ -35,10 +35,10 @@ public class PotionColorCalculationEvent extends LivingEvent
{
private int color;
private boolean hideParticle;
private final Collection<EffectInstance> effectList;
private final Collection<MobEffectInstance> effectList;
public PotionColorCalculationEvent(LivingEntity entity, int color, boolean hideParticle,
Collection<EffectInstance> effectList)
Collection<MobEffectInstance> effectList)
{
super(entity);
this.color = color;
@@ -71,7 +71,7 @@ public class PotionColorCalculationEvent extends LivingEvent
*
* @return effects
*/
public Collection<EffectInstance> getEffects()
public Collection<MobEffectInstance> getEffects()
{
return Collections.unmodifiableCollection(effectList);
}
@@ -22,10 +22,9 @@ package net.minecraftforge.event.entity.living;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.entity.LivingEntity;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event.HasResult;
@@ -36,9 +35,9 @@ import net.minecraftforge.eventbus.api.Event.HasResult;
public class PotionEvent extends LivingEvent
{
@Nullable
protected final EffectInstance effect;
protected final MobEffectInstance effect;
public PotionEvent(LivingEntity living, EffectInstance effect)
public PotionEvent(LivingEntity living, MobEffectInstance effect)
{
super(living);
this.effect = effect;
@@ -47,7 +46,7 @@ public class PotionEvent extends LivingEvent
* Retuns the PotionEffect.
*/
@Nullable
public EffectInstance getPotionEffect()
public MobEffectInstance getPotionEffect()
{
return effect;
}
@@ -60,15 +59,15 @@ public class PotionEvent extends LivingEvent
@Cancelable
public static class PotionRemoveEvent extends PotionEvent
{
private final Effect potion;
private final MobEffect potion;
public PotionRemoveEvent(LivingEntity living, Effect potion)
public PotionRemoveEvent(LivingEntity living, MobEffect potion)
{
super(living, living.getEffect(potion));
this.potion = potion;
}
public PotionRemoveEvent(LivingEntity living, EffectInstance effect)
public PotionRemoveEvent(LivingEntity living, MobEffectInstance effect)
{
super(living, effect);
this.potion = effect.getEffect();
@@ -77,7 +76,7 @@ public class PotionEvent extends LivingEvent
/**
* @return the Potion which is tried to remove from the Entity.
*/
public Effect getPotion()
public MobEffect getPotion()
{
return this.potion;
}
@@ -87,7 +86,7 @@ public class PotionEvent extends LivingEvent
*/
@Override
@Nullable
public EffectInstance getPotionEffect()
public MobEffectInstance getPotionEffect()
{
return super.getPotionEffect();
}
@@ -104,7 +103,7 @@ public class PotionEvent extends LivingEvent
@HasResult
public static class PotionApplicableEvent extends PotionEvent
{
public PotionApplicableEvent(LivingEntity living, EffectInstance effect)
public PotionApplicableEvent(LivingEntity living, MobEffectInstance effect)
{
super(living, effect);
}
@@ -114,7 +113,7 @@ public class PotionEvent extends LivingEvent
*/
@Override
@Nonnull
public EffectInstance getPotionEffect()
public MobEffectInstance getPotionEffect()
{
return super.getPotionEffect();
}
@@ -127,9 +126,9 @@ public class PotionEvent extends LivingEvent
*/
public static class PotionAddedEvent extends PotionEvent
{
private final EffectInstance oldEffect;
private final MobEffectInstance oldEffect;
public PotionAddedEvent(LivingEntity living, EffectInstance oldEffect, EffectInstance newEffect)
public PotionAddedEvent(LivingEntity living, MobEffectInstance oldEffect, MobEffectInstance newEffect)
{
super(living, newEffect);
this.oldEffect = oldEffect;
@@ -140,7 +139,7 @@ public class PotionEvent extends LivingEvent
*/
@Override
@Nonnull
public EffectInstance getPotionEffect()
public MobEffectInstance getPotionEffect()
{
return super.getPotionEffect();
}
@@ -149,7 +148,7 @@ public class PotionEvent extends LivingEvent
* @return the old PotionEffect. THis can be null if the entity did not have an effect of this kind before.
*/
@Nullable
public EffectInstance getOldPotionEffect()
public MobEffectInstance getOldPotionEffect()
{
return oldEffect;
}
@@ -162,7 +161,7 @@ public class PotionEvent extends LivingEvent
*/
public static class PotionExpiryEvent extends PotionEvent
{
public PotionExpiryEvent(LivingEntity living, EffectInstance effect)
public PotionExpiryEvent(LivingEntity living, MobEffectInstance effect)
{
super(living, effect);
}
@@ -19,15 +19,10 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.monster.ZombieEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.Zombie;
import net.minecraft.world.level.Level;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;
@@ -40,14 +35,14 @@ import net.minecraftforge.eventbus.api.Event.HasResult;
**/
public class ZombieEvent extends EntityEvent {
public ZombieEvent(ZombieEntity entity)
public ZombieEvent(Zombie entity)
{
super(entity);
}
public ZombieEntity getSummoner()
public Zombie getSummoner()
{
return (ZombieEntity) getEntity();
return (Zombie) getEntity();
}
/**
@@ -75,16 +70,16 @@ public class ZombieEvent extends EntityEvent {
**/
@HasResult
public static class SummonAidEvent extends ZombieEvent {
private ZombieEntity customSummonedAid;
private Zombie customSummonedAid;
private final World world;
private final Level world;
private final int x;
private final int y;
private final int z;
private final LivingEntity attacker;
private final double summonChance;
public SummonAidEvent(ZombieEntity entity, World world, int x, int y, int z, LivingEntity attacker, double summonChance)
public SummonAidEvent(Zombie entity, Level world, int x, int y, int z, LivingEntity attacker, double summonChance)
{
super(entity);
this.world = world;
@@ -98,9 +93,9 @@ public class ZombieEvent extends EntityEvent {
/**
* Populate this field to have a custom zombie instead of a normal zombie summoned
*/
public ZombieEntity getCustomSummonedAid() { return customSummonedAid; }
public void setCustomSummonedAid(ZombieEntity customSummonedAid) { this.customSummonedAid = customSummonedAid; }
public World getWorld() { return world; }
public Zombie getCustomSummonedAid() { return customSummonedAid; }
public void setCustomSummonedAid(Zombie customSummonedAid) { this.customSummonedAid = customSummonedAid; }
public Level getWorld() { return world; }
public int getX() { return x; }
public int getY() { return y; }
public int getZ() { return z; }
@@ -20,8 +20,7 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.advancements.Advancement;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.player.Player;
/**
* This event is fired when a player gets an advancement.
@@ -36,7 +35,7 @@ public class AdvancementEvent extends PlayerEvent
{
private final Advancement advancement;
public AdvancementEvent(PlayerEntity player, Advancement advancement)
public AdvancementEvent(Player player, Advancement advancement)
{
super(player);
this.advancement = advancement;
@@ -19,8 +19,8 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull;
@@ -41,7 +41,7 @@ public class AnvilRepairEvent extends PlayerEvent
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(PlayerEntity player, @Nonnull ItemStack left, @Nonnull ItemStack right, @Nonnull ItemStack output)
public AnvilRepairEvent(Player player, @Nonnull ItemStack left, @Nonnull ItemStack right, @Nonnull ItemStack output)
{
super(player);
this.output = output;
@@ -19,11 +19,10 @@
package net.minecraftforge.event.entity.player;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import javax.annotation.Nonnull;
@@ -46,11 +45,11 @@ import javax.annotation.Nonnull;
public class ArrowLooseEvent extends PlayerEvent
{
private final ItemStack bow;
private final World world;
private final Level world;
private final boolean hasAmmo;
private int charge;
public ArrowLooseEvent(PlayerEntity player, @Nonnull ItemStack bow, World world, int charge, boolean hasAmmo)
public ArrowLooseEvent(Player player, @Nonnull ItemStack bow, Level world, int charge, boolean hasAmmo)
{
super(player);
this.bow = bow;
@@ -61,7 +60,7 @@ public class ArrowLooseEvent extends PlayerEvent
@Nonnull
public ItemStack getBow() { return this.bow; }
public World getWorld() { return this.world; }
public Level getWorld() { return this.world; }
public boolean hasAmmo() { return this.hasAmmo; }
public int getCharge() { return this.charge; }
public void setCharge(int charge) { this.charge = charge; }
@@ -19,12 +19,11 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.level.Level;
import javax.annotation.Nonnull;
@@ -38,12 +37,12 @@ import javax.annotation.Nonnull;
public class ArrowNockEvent extends PlayerEvent
{
private final ItemStack bow;
private final Hand hand;
private final World world;
private final InteractionHand hand;
private final Level world;
private final boolean hasAmmo;
private ActionResult<ItemStack> action;
private InteractionResultHolder<ItemStack> action;
public ArrowNockEvent(PlayerEntity player, @Nonnull ItemStack item, Hand hand, World world, boolean hasAmmo)
public ArrowNockEvent(Player player, @Nonnull ItemStack item, InteractionHand hand, Level world, boolean hasAmmo)
{
super(player);
this.bow = item;
@@ -54,15 +53,15 @@ public class ArrowNockEvent extends PlayerEvent
@Nonnull
public ItemStack getBow() { return this.bow; }
public World getWorld() { return this.world; }
public Hand getHand() { return this.hand; }
public Level getWorld() { return this.world; }
public InteractionHand getHand() { return this.hand; }
public boolean hasAmmo() { return this.hasAmmo; }
public ActionResult<ItemStack> getAction()
public InteractionResultHolder<ItemStack> getAction()
{
return this.action;
}
public void setAction(ActionResult<ItemStack> action)
public void setAction(InteractionResultHolder<ItemStack> action)
{
this.action = action;
}
@@ -19,10 +19,9 @@
package net.minecraftforge.event.entity.player;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
/**
* AttackEntityEvent is fired when a player attacks an Entity.<br>
@@ -42,7 +41,7 @@ import net.minecraft.entity.player.PlayerEntity;
public class AttackEntityEvent extends PlayerEvent
{
private final Entity target;
public AttackEntityEvent(PlayerEntity player, Entity target)
public AttackEntityEvent(Player player, Entity target)
{
super(player);
this.target = target;
@@ -20,11 +20,11 @@
package net.minecraftforge.event.entity.player;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.level.block.state.BlockState;
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;
@@ -42,12 +42,12 @@ import javax.annotation.Nonnull;
public class BonemealEvent extends PlayerEvent
{
private final World world;
private final Level world;
private final BlockPos pos;
private final BlockState block;
private final ItemStack stack;
public BonemealEvent(@Nonnull PlayerEntity player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState block, @Nonnull ItemStack stack)
public BonemealEvent(@Nonnull Player player, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull BlockState block, @Nonnull ItemStack stack)
{
super(player);
this.world = world;
@@ -56,7 +56,7 @@ public class BonemealEvent extends PlayerEvent
this.stack = stack;
}
public World getWorld()
public Level getWorld()
{
return world;
}
@@ -20,10 +20,8 @@
package net.minecraftforge.event.entity.player;
import net.minecraftforge.eventbus.api.Event.HasResult;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
/**
* This event is fired whenever a player attacks an Entity in
@@ -46,7 +44,7 @@ public class CriticalHitEvent extends PlayerEvent
private final Entity target;
private final boolean vanillaCritical;
public CriticalHitEvent(PlayerEntity player, Entity target, float damageModifier, boolean vanillaCritical)
public CriticalHitEvent(Player player, Entity target, float damageModifier, boolean vanillaCritical)
{
super(player);
this.target = target;
@@ -21,8 +21,8 @@ package net.minecraftforge.event.entity.player;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
/**
* This event is called when a player collides with a EntityItem on the ground.
@@ -40,7 +40,7 @@ public class EntityItemPickupEvent extends PlayerEvent
{
private final ItemEntity item;
public EntityItemPickupEvent(PlayerEntity player, ItemEntity item)
public EntityItemPickupEvent(Player player, ItemEntity item)
{
super(player);
this.item = item;
@@ -21,10 +21,10 @@ package net.minecraftforge.event.entity.player;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
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;
@@ -44,13 +44,13 @@ public class FillBucketEvent extends PlayerEvent
{
private final ItemStack current;
private final World world;
private final Level world;
@Nullable
private final RayTraceResult target;
private final HitResult target;
private ItemStack result;
public FillBucketEvent(PlayerEntity player, @Nonnull ItemStack current, World world, @Nullable RayTraceResult target)
public FillBucketEvent(Player player, @Nonnull ItemStack current, Level world, @Nullable HitResult target)
{
super(player);
this.current = current;
@@ -60,9 +60,9 @@ public class FillBucketEvent extends PlayerEvent
@Nonnull
public ItemStack getEmptyBucket() { return this.current; }
public World getWorld(){ return this.world; }
public Level getWorld(){ return this.world; }
@Nullable
public RayTraceResult getTarget() { return this.target; }
public HitResult getTarget() { return this.target; }
@Nonnull
public ItemStack getFilledBucket() { return this.result; }
public void setFilledBucket(@Nonnull ItemStack bucket) { this.result = bucket; }
@@ -20,9 +20,9 @@
package net.minecraftforge.event.entity.player;
import com.google.common.base.Preconditions;
import net.minecraft.entity.projectile.FishingBobberEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.world.entity.projectile.FishingHook;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.NonNullList;
import net.minecraftforge.eventbus.api.Cancelable;
import javax.annotation.Nonnegative;
@@ -39,10 +39,10 @@ import java.util.List;
public class ItemFishedEvent extends PlayerEvent
{
private final NonNullList<ItemStack> stacks = NonNullList.create();
private final FishingBobberEntity hook;
private final FishingHook hook;
private int rodDamage;
public ItemFishedEvent(List<ItemStack> stacks, int rodDamage, FishingBobberEntity hook)
public ItemFishedEvent(List<ItemStack> stacks, int rodDamage, FishingHook hook)
{
super(hook.getPlayerOwner());
this.stacks.addAll(stacks);
@@ -83,7 +83,7 @@ public class ItemFishedEvent extends PlayerEvent
/**
* Use this to stuff related to the hook itself, like the position of the bobber.
*/
public FishingBobberEntity getHookEntity()
public FishingHook getHookEntity()
{
return hook;
}
@@ -21,27 +21,26 @@ package net.minecraftforge.event.entity.player;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
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;
public class ItemTooltipEvent extends PlayerEvent
{
private final ITooltipFlag flags;
private final TooltipFlag flags;
@Nonnull
private final ItemStack itemStack;
private final List<ITextComponent> toolTip;
private final List<Component> toolTip;
/**
* This event is fired in {@link ItemStack#getTooltip(EntityPlayer, ITooltipFlag)}, which in turn is called from it's respective GUIContainer.
* Tooltips are also gathered with a null entityPlayer during startup by {@link Minecraft#populateSearchTreeManager()}.
*/
public ItemTooltipEvent(@Nonnull ItemStack itemStack, @Nullable PlayerEntity entityPlayer, List<ITextComponent> list, ITooltipFlag flags)
public ItemTooltipEvent(@Nonnull ItemStack itemStack, @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags)
{
super(entityPlayer);
this.itemStack = itemStack;
@@ -52,7 +51,7 @@ public class ItemTooltipEvent extends PlayerEvent
/**
* Use to determine if the advanced information on item tooltips is being shown, toggled by F3+H.
*/
public ITooltipFlag getFlags()
public TooltipFlag getFlags()
{
return flags;
}
@@ -69,7 +68,7 @@ public class ItemTooltipEvent extends PlayerEvent
/**
* The {@link ItemStack} tooltip.
*/
public List<ITextComponent> getToolTip()
public List<Component> getToolTip()
{
return toolTip;
}
@@ -79,7 +78,7 @@ public class ItemTooltipEvent extends PlayerEvent
*/
@Override
@Nullable
public PlayerEntity getPlayer()
public Player getPlayer()
{
return super.getPlayer();
}
@@ -19,13 +19,13 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.Container;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
public class PlayerContainerEvent extends PlayerEvent
{
private final Container container;
public PlayerContainerEvent(PlayerEntity player, Container container)
private final AbstractContainerMenu container;
public PlayerContainerEvent(Player player, AbstractContainerMenu container)
{
super(player);
this.container = container;
@@ -33,20 +33,20 @@ public class PlayerContainerEvent extends PlayerEvent
public static class Open extends PlayerContainerEvent
{
public Open(PlayerEntity player, Container container)
public Open(Player player, AbstractContainerMenu container)
{
super(player, container);
}
}
public static class Close extends PlayerContainerEvent
{
public Close(PlayerEntity player, Container container)
public Close(Player player, AbstractContainerMenu container)
{
super(player, container);
}
}
public Container getContainer()
public AbstractContainerMenu getContainer()
{
return container;
}
@@ -19,21 +19,9 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.client.multiplayer.PlayerController;
import net.minecraft.entity.Entity;
import net.minecraft.server.management.PlayerInteractionManager;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.Direction;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.InteractionHand;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -67,8 +55,8 @@ public class PlayerDestroyItemEvent extends PlayerEvent
@Nonnull
private final ItemStack original;
@Nullable
private final Hand hand; // May be null if this player destroys the item by any use besides holding it.
public PlayerDestroyItemEvent(PlayerEntity player, @Nonnull ItemStack original, @Nullable Hand hand)
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)
{
super(player);
this.original = original;
@@ -78,6 +66,6 @@ public class PlayerDestroyItemEvent extends PlayerEvent
@Nonnull
public ItemStack getOriginal() { return this.original; }
@Nullable
public Hand getHand() { return this.hand; }
public InteractionHand getHand() { return this.hand; }
}
@@ -21,23 +21,19 @@ package net.minecraftforge.event.entity.player;
import java.io.File;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.RegistryKey;
import net.minecraft.world.GameType;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.Entity;
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 net.minecraftforge.eventbus.api.Event;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -51,8 +47,8 @@ import javax.annotation.Nullable;
**/
public class PlayerEvent extends LivingEvent
{
private final PlayerEntity entityPlayer;
public PlayerEvent(PlayerEntity player)
private final Player entityPlayer;
public PlayerEvent(Player player)
{
super(player);
entityPlayer = player;
@@ -61,7 +57,7 @@ public class PlayerEvent extends LivingEvent
/**
* @return Player
*/
public PlayerEntity getPlayer() { return entityPlayer; }
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
@@ -83,7 +79,7 @@ public class PlayerEvent extends LivingEvent
private final BlockState state;
private boolean success;
public HarvestCheck(PlayerEntity player, BlockState state, boolean success)
public HarvestCheck(Player player, BlockState state, boolean success)
{
super(player);
this.state = state;
@@ -122,7 +118,7 @@ public class PlayerEvent extends LivingEvent
private float newSpeed = 0.0f;
private final BlockPos pos; // Y position of -1 notes unknown location
public BreakSpeed(PlayerEntity player, BlockState state, float original, BlockPos pos)
public BreakSpeed(Player player, BlockState state, float original, BlockPos pos)
{
super(player);
this.state = state;
@@ -156,27 +152,27 @@ public class PlayerEvent extends LivingEvent
**/
public static class NameFormat extends PlayerEvent
{
private final ITextComponent username;
private ITextComponent displayname;
private final Component username;
private Component displayname;
public NameFormat(PlayerEntity player, ITextComponent username)
public NameFormat(Player player, Component username)
{
super(player);
this.username = username;
this.setDisplayname(username);
}
public ITextComponent getUsername()
public Component getUsername()
{
return username;
}
public ITextComponent getDisplayname()
public Component getDisplayname()
{
return displayname;
}
public void setDisplayname(ITextComponent displayname)
public void setDisplayname(Component displayname)
{
this.displayname = displayname;
}
@@ -200,20 +196,20 @@ public class PlayerEvent extends LivingEvent
public static class TabListNameFormat extends PlayerEvent
{
@Nullable
private ITextComponent displayName;
private Component displayName;
public TabListNameFormat(PlayerEntity player)
public TabListNameFormat(Player player)
{
super(player);
}
@Nullable
public ITextComponent getDisplayName()
public Component getDisplayName()
{
return displayName;
}
public void setDisplayName(@Nullable ITextComponent displayName)
public void setDisplayName(@Nullable Component displayName)
{
this.displayName = displayName;
}
@@ -225,10 +221,10 @@ public class PlayerEvent extends LivingEvent
*/
public static class Clone extends PlayerEvent
{
private final PlayerEntity original;
private final Player original;
private final boolean wasDeath;
public Clone(PlayerEntity _new, PlayerEntity oldPlayer, boolean wasDeath)
public Clone(Player _new, Player oldPlayer, boolean wasDeath)
{
super(_new);
this.original = oldPlayer;
@@ -238,7 +234,7 @@ public class PlayerEvent extends LivingEvent
/**
* The old EntityPlayer that this new entity is a clone of.
*/
public PlayerEntity getOriginal()
public Player getOriginal()
{
return original;
}
@@ -261,7 +257,7 @@ public class PlayerEvent extends LivingEvent
private final Entity target;
public StartTracking(PlayerEntity player, Entity target)
public StartTracking(Player player, Entity target)
{
super(player);
this.target = target;
@@ -284,7 +280,7 @@ public class PlayerEvent extends LivingEvent
private final Entity target;
public StopTracking(PlayerEntity player, Entity target)
public StopTracking(Player player, Entity target)
{
super(player);
this.target = target;
@@ -309,7 +305,7 @@ public class PlayerEvent extends LivingEvent
private final File playerDirectory;
private final String playerUUID;
public LoadFromFile(PlayerEntity player, File originDirectory, String playerUUID)
public LoadFromFile(Player player, File originDirectory, String playerUUID)
{
super(player);
this.playerDirectory = originDirectory;
@@ -362,7 +358,7 @@ public class PlayerEvent extends LivingEvent
private final File playerDirectory;
private final String playerUUID;
public SaveToFile(PlayerEntity player, File originDirectory, String playerUUID)
public SaveToFile(Player player, File originDirectory, String playerUUID)
{
super(player);
this.playerDirectory = originDirectory;
@@ -399,40 +395,6 @@ public class PlayerEvent extends LivingEvent
}
}
/**
* TODO 1.17 remove, unused
* Fired when the world checks if a player is near enough to be attacked by an entity.
* The resulting visibility modifier is multiplied by the one calculated by Minecraft (based on sneaking and more) and used to calculate the radius a player has to be in (targetDistance*modifier).
* This can also be used to increase the visibility of a player, if it was decreased by Minecraft or other mods. But the resulting value cannot be higher than the standard target distance.
*/
@Deprecated
public static class Visibility extends PlayerEvent
{
private double visibilityModifier = 1D;
public Visibility(PlayerEntity player)
{
super(player);
}
/**
* @param mod Is multiplied with the current modifier
*/
public void modifyVisibility(double mod)
{
visibilityModifier *= mod;
}
/**
* @return The current modifier
*/
public double getVisibilityModifier()
{
return visibilityModifier;
}
}
public static class ItemPickupEvent extends PlayerEvent {
/**
* Original EntityItem with current remaining stack size
@@ -442,7 +404,7 @@ public class PlayerEvent extends LivingEvent
* Clone item stack, containing the item and amount picked up
*/
private final ItemStack stack;
public ItemPickupEvent(PlayerEntity player, ItemEntity entPickedUp, ItemStack stack)
public ItemPickupEvent(Player player, ItemEntity entPickedUp, ItemStack stack)
{
super(player);
this.originalEntity = entPickedUp;
@@ -461,8 +423,8 @@ public class PlayerEvent extends LivingEvent
public static class ItemCraftedEvent extends PlayerEvent {
@Nonnull
private final ItemStack crafting;
private final IInventory craftMatrix;
public ItemCraftedEvent(PlayerEntity player, @Nonnull ItemStack crafting, IInventory craftMatrix)
private final Container craftMatrix;
public ItemCraftedEvent(Player player, @Nonnull ItemStack crafting, Container craftMatrix)
{
super(player);
this.crafting = crafting;
@@ -475,7 +437,7 @@ public class PlayerEvent extends LivingEvent
return this.crafting;
}
public IInventory getInventory()
public Container getInventory()
{
return this.craftMatrix;
}
@@ -484,7 +446,7 @@ public class PlayerEvent extends LivingEvent
public static class ItemSmeltedEvent extends PlayerEvent {
@Nonnull
private final ItemStack smelting;
public ItemSmeltedEvent(PlayerEntity player, @Nonnull ItemStack crafting)
public ItemSmeltedEvent(Player player, @Nonnull ItemStack crafting)
{
super(player);
this.smelting = crafting;
@@ -498,14 +460,14 @@ public class PlayerEvent extends LivingEvent
}
public static class PlayerLoggedInEvent extends PlayerEvent {
public PlayerLoggedInEvent(PlayerEntity player)
public PlayerLoggedInEvent(Player player)
{
super(player);
}
}
public static class PlayerLoggedOutEvent extends PlayerEvent {
public PlayerLoggedOutEvent(PlayerEntity player)
public PlayerLoggedOutEvent(Player player)
{
super(player);
}
@@ -514,7 +476,7 @@ public class PlayerEvent extends LivingEvent
public static class PlayerRespawnEvent extends PlayerEvent {
private final boolean endConquered;
public PlayerRespawnEvent(PlayerEntity player, boolean endConquered)
public PlayerRespawnEvent(Player player, boolean endConquered)
{
super(player);
this.endConquered = endConquered;
@@ -533,21 +495,21 @@ public class PlayerEvent extends LivingEvent
}
public static class PlayerChangedDimensionEvent extends PlayerEvent {
private final RegistryKey<World> fromDim;
private final RegistryKey<World> toDim;
public PlayerChangedDimensionEvent(PlayerEntity player, RegistryKey<World> fromDim, RegistryKey<World> toDim)
private final ResourceKey<Level> fromDim;
private final ResourceKey<Level> toDim;
public PlayerChangedDimensionEvent(Player player, ResourceKey<Level> fromDim, ResourceKey<Level> toDim)
{
super(player);
this.fromDim = fromDim;
this.toDim = toDim;
}
public RegistryKey<World> getFrom()
public ResourceKey<Level> getFrom()
{
return this.fromDim;
}
public RegistryKey<World> getTo()
public ResourceKey<Level> getTo()
{
return this.toDim;
}
@@ -563,7 +525,7 @@ public class PlayerEvent extends LivingEvent
private final GameType currentGameMode;
private GameType newGameMode;
public PlayerChangeGameModeEvent(PlayerEntity player, GameType currentGameMode, GameType newGameMode)
public PlayerChangeGameModeEvent(Player player, GameType currentGameMode, GameType newGameMode)
{
super(player);
this.currentGameMode = currentGameMode;
@@ -19,7 +19,7 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.entity.player.Player;
/**
* Occurs when a player falls, but is able to fly. Doesn't need to be cancelable, this is mainly for notification purposes.
@@ -31,7 +31,7 @@ public class PlayerFlyableFallEvent extends PlayerEvent
private float distance;
private float multiplier;
public PlayerFlyableFallEvent(PlayerEntity player, float distance, float multiplier)
public PlayerFlyableFallEvent(Player player, float distance, float multiplier)
{
super(player);
this.distance = distance;
@@ -20,19 +20,16 @@
package net.minecraftforge.event.entity.player;
import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.InteractionResult;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.level.Level;
import net.minecraftforge.eventbus.api.Cancelable;
import javax.annotation.Nonnull;
@@ -50,13 +47,13 @@ import net.minecraftforge.fml.LogicalSide;
**/
public class PlayerInteractEvent extends PlayerEvent
{
private final Hand hand;
private final InteractionHand hand;
private final BlockPos pos;
@Nullable
private final Direction face;
private ActionResultType cancellationResult = ActionResultType.PASS;
private InteractionResult cancellationResult = InteractionResult.PASS;
private PlayerInteractEvent(PlayerEntity player, Hand hand, BlockPos pos, @Nullable Direction face)
private PlayerInteractEvent(Player player, InteractionHand hand, BlockPos pos, @Nullable Direction face)
{
super(Preconditions.checkNotNull(player, "Null player in PlayerInteractEvent!"));
this.hand = Preconditions.checkNotNull(hand, "Null hand in PlayerInteractEvent!");
@@ -76,10 +73,10 @@ public class PlayerInteractEvent extends PlayerEvent
@Cancelable
public static class EntityInteractSpecific extends PlayerInteractEvent
{
private final Vector3d localPos;
private final Vec3 localPos;
private final Entity target;
public EntityInteractSpecific(PlayerEntity player, Hand hand, Entity target, Vector3d localPos)
public EntityInteractSpecific(Player player, InteractionHand hand, Entity target, Vec3 localPos)
{
super(player, hand, target.blockPosition(), null);
this.localPos = localPos;
@@ -92,7 +89,7 @@ public class PlayerInteractEvent extends PlayerEvent
* [-width / 2, width / 2] while Y values will be in the range [0, height]
* @return The local position
*/
public Vector3d getLocalPos()
public Vec3 getLocalPos()
{
return localPos;
}
@@ -119,7 +116,7 @@ public class PlayerInteractEvent extends PlayerEvent
{
private final Entity target;
public EntityInteract(PlayerEntity player, Hand hand, Entity target)
public EntityInteract(Player player, InteractionHand hand, Entity target)
{
super(player, hand, target.blockPosition(), null);
this.target = target;
@@ -149,14 +146,9 @@ public class PlayerInteractEvent extends PlayerEvent
{
private Result useBlock = DEFAULT;
private Result useItem = DEFAULT;
private BlockRayTraceResult hitVec;
private BlockHitResult hitVec;
@Deprecated //Use RayTraceResult version. TODO: Remove 1.17
public RightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, Direction face) {
super(player, hand, pos, face);
}
public RightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, BlockRayTraceResult hitVec) {
public RightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult hitVec) {
super(player, hand, pos, hitVec.getDirection());
this.hitVec = hitVec;
}
@@ -180,7 +172,7 @@ public class PlayerInteractEvent extends PlayerEvent
/**
* @return The ray trace result targeting the block.
*/
public BlockRayTraceResult getHitVec()
public BlockHitResult getHitVec()
{
return hitVec;
}
@@ -228,7 +220,7 @@ public class PlayerInteractEvent extends PlayerEvent
@Cancelable
public static class RightClickItem extends PlayerInteractEvent
{
public RightClickItem(PlayerEntity player, Hand hand)
public RightClickItem(Player player, InteractionHand hand)
{
super(player, hand, player.blockPosition(), null);
}
@@ -241,7 +233,7 @@ public class PlayerInteractEvent extends PlayerEvent
*/
public static class RightClickEmpty extends PlayerInteractEvent
{
public RightClickEmpty(PlayerEntity player, Hand hand)
public RightClickEmpty(Player player, InteractionHand hand)
{
super(player, hand, player.blockPosition(), null);
}
@@ -265,9 +257,9 @@ public class PlayerInteractEvent extends PlayerEvent
private Result useBlock = DEFAULT;
private Result useItem = DEFAULT;
public LeftClickBlock(PlayerEntity player, BlockPos pos, Direction face)
public LeftClickBlock(Player player, BlockPos pos, Direction face)
{
super(player, Hand.MAIN_HAND, pos, face);
super(player, InteractionHand.MAIN_HAND, pos, face);
}
/**
@@ -315,9 +307,9 @@ public class PlayerInteractEvent extends PlayerEvent
*/
public static class LeftClickEmpty extends PlayerInteractEvent
{
public LeftClickEmpty(PlayerEntity player)
public LeftClickEmpty(Player player)
{
super(player, Hand.MAIN_HAND, player.blockPosition(), null);
super(player, InteractionHand.MAIN_HAND, player.blockPosition(), null);
}
}
@@ -325,7 +317,7 @@ public class PlayerInteractEvent extends PlayerEvent
* @return The hand involved in this interaction. Will never be null.
*/
@Nonnull
public Hand getHand()
public InteractionHand getHand()
{
return hand;
}
@@ -364,7 +356,7 @@ public class PlayerInteractEvent extends PlayerEvent
/**
* @return Convenience method to get the world of this interaction.
*/
public World getWorld()
public Level getWorld()
{
return getPlayer().getCommandSenderWorld();
}
@@ -382,7 +374,7 @@ public class PlayerInteractEvent extends PlayerEvent
* method of the event. By default, this is {@link EnumActionResult#PASS}, meaning cancelled events will cause
* the client to keep trying more interactions until something works.
*/
public ActionResultType getCancellationResult()
public InteractionResult getCancellationResult()
{
return cancellationResult;
}
@@ -392,7 +384,7 @@ public class PlayerInteractEvent extends PlayerEvent
* method of the event.
* Note that this only has an effect on {@link RightClickBlock}, {@link RightClickItem}, {@link EntityInteract}, and {@link EntityInteractSpecific}.
*/
public void setCancellationResult(ActionResultType result)
public void setCancellationResult(InteractionResult result)
{
this.cancellationResult = result;
}
@@ -19,10 +19,10 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.util.RegistryKey;
import net.minecraft.world.World;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.resources.ResourceKey;
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;
@@ -34,12 +34,12 @@ import javax.annotation.Nullable;
@Cancelable
public class PlayerSetSpawnEvent extends PlayerEvent
{
private final RegistryKey<World> spawnWorld;
private final ResourceKey<Level> spawnWorld;
private final boolean forced;
@Nullable
private final BlockPos newSpawn;
public PlayerSetSpawnEvent(PlayerEntity player, RegistryKey<World> spawnWorld, @Nullable BlockPos newSpawn, boolean forced)
public PlayerSetSpawnEvent(Player player, ResourceKey<Level> spawnWorld, @Nullable BlockPos newSpawn, boolean forced)
{
super(player);
this.spawnWorld = spawnWorld;
@@ -61,7 +61,7 @@ public class PlayerSetSpawnEvent extends PlayerEvent
return newSpawn;
}
public RegistryKey<World> getSpawnWorld()
public ResourceKey<Level> getSpawnWorld()
{
return spawnWorld;
}
@@ -19,10 +19,9 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerEntity.SleepResult;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.Player.BedSleepingProblem;
import net.minecraft.core.BlockPos;
import java.util.Optional;
@@ -40,21 +39,21 @@ import java.util.Optional;
**/
public class PlayerSleepInBedEvent extends PlayerEvent
{
private SleepResult result = null;
private BedSleepingProblem result = null;
private final Optional<BlockPos> pos;
public PlayerSleepInBedEvent(PlayerEntity player, Optional<BlockPos> pos)
public PlayerSleepInBedEvent(Player player, Optional<BlockPos> pos)
{
super(player);
this.pos = pos;
}
public SleepResult getResultStatus()
public BedSleepingProblem getResultStatus()
{
return result;
}
public void setResult(SleepResult result)
public void setResult(BedSleepingProblem result)
{
this.result = result;
}
@@ -19,7 +19,7 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.entity.player.Player;
/**
* This event is fired when the player is waking up.<br/>
@@ -32,7 +32,7 @@ public class PlayerWakeUpEvent extends PlayerEvent
private final boolean updateWorld;
public PlayerWakeUpEvent(PlayerEntity player, boolean wakeImmediately, boolean updateWorld)
public PlayerWakeUpEvent(Player player, boolean wakeImmediately, boolean updateWorld)
{
super(player);
this.wakeImmediately = wakeImmediately;
@@ -19,9 +19,8 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.entity.item.ExperienceOrbEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.ExperienceOrb;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.eventbus.api.Cancelable;
/**
@@ -34,7 +33,7 @@ import net.minecraftforge.eventbus.api.Cancelable;
public class PlayerXpEvent extends PlayerEvent
{
public PlayerXpEvent(PlayerEntity player)
public PlayerXpEvent(Player player)
{
super(player);
}
@@ -47,15 +46,15 @@ public class PlayerXpEvent extends PlayerEvent
public static class PickupXp extends PlayerXpEvent
{
private final ExperienceOrbEntity orb;
private final ExperienceOrb orb;
public PickupXp(PlayerEntity player, ExperienceOrbEntity orb)
public PickupXp(Player player, ExperienceOrb orb)
{
super(player);
this.orb = orb;
}
public ExperienceOrbEntity getOrb()
public ExperienceOrb getOrb()
{
return orb;
}
@@ -72,7 +71,7 @@ public class PlayerXpEvent extends PlayerEvent
private int amount;
public XpChange(PlayerEntity player, int amount)
public XpChange(Player player, int amount)
{
super(player);
this.amount = amount;
@@ -100,7 +99,7 @@ public class PlayerXpEvent extends PlayerEvent
private int levels;
public LevelChange(PlayerEntity player, int levels)
public LevelChange(Player player, int levels)
{
super(player);
this.levels = levels;
@@ -19,10 +19,8 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.core.BlockPos;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.eventbus.api.Event.HasResult;
@@ -19,9 +19,8 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.entity.player.Player;
import net.minecraft.core.BlockPos;
import net.minecraftforge.eventbus.api.Event.HasResult;
import java.util.Optional;
@@ -40,7 +39,7 @@ public class SleepingTimeCheckEvent extends PlayerEvent
{
private final Optional<BlockPos> sleepingLocation;
public SleepingTimeCheckEvent(PlayerEntity player, Optional<BlockPos> sleepingLocation)
public SleepingTimeCheckEvent(Player player, Optional<BlockPos> sleepingLocation)
{
super(player);
this.sleepingLocation = sleepingLocation;
@@ -19,7 +19,7 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.item.ItemUseContext;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event.HasResult;
@@ -41,16 +41,16 @@ import javax.annotation.Nonnull;
@Deprecated
public class UseHoeEvent extends PlayerEvent
{
private final ItemUseContext context;;
private final UseOnContext context;;
public UseHoeEvent(ItemUseContext context)
public UseHoeEvent(UseOnContext context)
{
super(context.getPlayer());
this.context = context;
}
@Nonnull
public ItemUseContext getContext()
public UseOnContext getContext()
{
return context;
}
@@ -22,9 +22,9 @@ package net.minecraftforge.event.furnace;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.eventbus.api.Cancelable;
@@ -49,16 +49,10 @@ public class FurnaceFuelBurnTimeEvent extends Event
@Nonnull
private final ItemStack itemStack;
@Nullable
private final IRecipeType<?> recipeType;
private final RecipeType<?> recipeType;
private int burnTime;
@Deprecated // use version with IRecipeType
public FurnaceFuelBurnTimeEvent(@Nonnull ItemStack itemStack, int burnTime)
{
this(itemStack, burnTime, null);
}
public FurnaceFuelBurnTimeEvent(@Nonnull ItemStack itemStack, int burnTime, @Nullable IRecipeType<?> recipeType)
public FurnaceFuelBurnTimeEvent(@Nonnull ItemStack itemStack, int burnTime, @Nullable RecipeType<?> recipeType)
{
this.itemStack = itemStack;
this.burnTime = burnTime;
@@ -79,7 +73,7 @@ public class FurnaceFuelBurnTimeEvent extends Event
* Get the recipe type for which to obtain the burn time, if known.
*/
@Nullable
public IRecipeType<?> getRecipeType()
public RecipeType<?> getRecipeType()
{
return recipeType;
}
@@ -19,11 +19,10 @@
package net.minecraftforge.event.village;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.village.VillageSiege;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.entity.ai.village.VillageSiege;
import net.minecraft.world.level.Level;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
@@ -41,11 +40,11 @@ import net.minecraftforge.eventbus.api.Event;
public class VillageSiegeEvent extends Event
{
private final VillageSiege siege;
private final World world;
private final PlayerEntity player;
private final Vector3d attemptedSpawnPos;
private final Level world;
private final Player player;
private final Vec3 attemptedSpawnPos;
public VillageSiegeEvent(VillageSiege siege, World world, PlayerEntity player, Vector3d attemptedSpawnPos)
public VillageSiegeEvent(VillageSiege siege, Level world, Player player, Vec3 attemptedSpawnPos)
{
this.siege = siege;
this.world = world;
@@ -58,17 +57,17 @@ public class VillageSiegeEvent extends Event
return siege;
}
public World getWorld()
public Level getWorld()
{
return world;
}
public PlayerEntity getPlayer()
public Player getPlayer()
{
return player;
}
public Vector3d getAttemptedSpawnPos()
public Vec3 getAttemptedSpawnPos()
{
return attemptedSpawnPos;
}
@@ -22,13 +22,10 @@ package net.minecraftforge.event.village;
import java.util.List;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.entity.merchant.villager.VillagerData;
import net.minecraft.entity.merchant.villager.VillagerProfession;
import net.minecraft.entity.merchant.villager.VillagerTrades.ITrade;
import net.minecraftforge.common.BasicTrade;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.entity.npc.VillagerTrades.ItemListing;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent;
/**
* VillagerTradesEvent is fired during the {@link FMLServerAboutToStartEvent}. It is used to gather the trade lists for each profession.
@@ -43,16 +40,16 @@ import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
public class VillagerTradesEvent extends Event
{
protected Int2ObjectMap<List<ITrade>> trades;
protected Int2ObjectMap<List<ItemListing>> trades;
protected VillagerProfession type;
public VillagerTradesEvent(Int2ObjectMap<List<ITrade>> trades, VillagerProfession type)
public VillagerTradesEvent(Int2ObjectMap<List<ItemListing>> trades, VillagerProfession type)
{
this.trades = trades;
this.type = type;
}
public Int2ObjectMap<List<ITrade>> getTrades()
public Int2ObjectMap<List<ItemListing>> getTrades()
{
return trades;
}
@@ -21,11 +21,9 @@ package net.minecraftforge.event.village;
import java.util.List;
import net.minecraft.entity.merchant.villager.VillagerTrades.ITrade;
import net.minecraftforge.common.BasicTrade;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.entity.npc.VillagerTrades.ItemListing;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent;
/**
* WandererTradesEvent is fired during the {@link FMLServerAboutToStartEvent}. It is used to gather the trade lists for the wandering merchant.
@@ -36,21 +34,21 @@ import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
public class WandererTradesEvent extends Event
{
protected List<ITrade> generic;
protected List<ITrade> rare;
protected List<ItemListing> generic;
protected List<ItemListing> rare;
public WandererTradesEvent(List<ITrade> generic, List<ITrade> rare)
public WandererTradesEvent(List<ItemListing> generic, List<ItemListing> rare)
{
this.generic = generic;
this.rare = rare;
}
public List<ITrade> getGenericTrades()
public List<ItemListing> getGenericTrades()
{
return generic;
}
public List<ITrade> getRareTrades()
public List<ItemListing> getRareTrades()
{
return rare;
}
@@ -19,13 +19,12 @@
package net.minecraftforge.event.world;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeAmbience;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
import net.minecraftforge.common.world.BiomeGenerationSettingsBuilder;
import net.minecraftforge.common.world.MobSpawnInfoBuilder;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.EventPriority;
import javax.annotation.Nullable;
@@ -46,15 +45,15 @@ import javax.annotation.Nullable;
public class BiomeLoadingEvent extends Event
{
private final ResourceLocation name;
private Biome.Climate climate;
private Biome.Category category;
private Biome.ClimateSettings climate;
private Biome.BiomeCategory category;
private float depth;
private float scale;
private BiomeAmbience effects;
private BiomeSpecialEffects effects;
private final BiomeGenerationSettingsBuilder gen;
private final MobSpawnInfoBuilder spawns;
public BiomeLoadingEvent(@Nullable final ResourceLocation name, final Biome.Climate climate, final Biome.Category category, final float depth, final float scale, final BiomeAmbience effects, final BiomeGenerationSettingsBuilder gen, final MobSpawnInfoBuilder spawns)
public BiomeLoadingEvent(@Nullable final ResourceLocation name, final Biome.ClimateSettings climate, final Biome.BiomeCategory category, final float depth, final float scale, final BiomeSpecialEffects effects, final BiomeGenerationSettingsBuilder gen, final MobSpawnInfoBuilder spawns)
{
this.name = name;
this.climate = climate;
@@ -77,22 +76,22 @@ public class BiomeLoadingEvent extends Event
return name;
}
public Biome.Climate getClimate()
public Biome.ClimateSettings getClimate()
{
return climate;
}
public void setClimate(final Biome.Climate value)
public void setClimate(final Biome.ClimateSettings value)
{
this.climate = value;
}
public Biome.Category getCategory()
public Biome.BiomeCategory getCategory()
{
return category;
}
public void setCategory(final Biome.Category value)
public void setCategory(final Biome.BiomeCategory value)
{
this.category = value;
}
@@ -117,12 +116,12 @@ public class BiomeLoadingEvent extends Event
this.scale = value;
}
public BiomeAmbience getEffects()
public BiomeSpecialEffects getEffects()
{
return effects;
}
public void setEffects(final BiomeAmbience value)
public void setEffects(final BiomeSpecialEffects value)
{
this.effects = value;
}
@@ -22,20 +22,18 @@ package net.minecraftforge.event.world;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.NetherPortalBlock;
import net.minecraft.block.PortalSize;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.Direction;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraft.world.level.portal.PortalShape;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.common.util.BlockSnapshot;
@@ -53,17 +51,17 @@ public class BlockEvent extends Event
{
private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockEvent", "false"));
private final IWorld world;
private final LevelAccessor world;
private final BlockPos pos;
private final BlockState state;
public BlockEvent(IWorld world, BlockPos pos, BlockState state)
public BlockEvent(LevelAccessor world, BlockPos pos, BlockState state)
{
this.pos = pos;
this.world = world;
this.state = state;
}
public IWorld getWorld()
public LevelAccessor getWorld()
{
return world;
}
@@ -86,10 +84,10 @@ public class BlockEvent extends Event
public static class BreakEvent extends BlockEvent
{
/** Reference to the Player who broke the block. If no player is available, use a EntityFakePlayer */
private final PlayerEntity player;
private final Player player;
private int exp;
public BreakEvent(World world, BlockPos pos, BlockState state, PlayerEntity player)
public BreakEvent(Level world, BlockPos pos, BlockState state, Player player)
{
super(world, pos, state);
this.player = player;
@@ -106,7 +104,7 @@ public class BlockEvent extends Event
}
}
public PlayerEntity getPlayer()
public Player getPlayer()
{
return player;
}
@@ -147,10 +145,10 @@ public class BlockEvent extends Event
public EntityPlaceEvent(@Nonnull BlockSnapshot blockSnapshot, @Nonnull BlockState placedAgainst, @Nullable Entity entity)
{
super(blockSnapshot.getWorld(), blockSnapshot.getPos(), !(entity instanceof PlayerEntity) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock());
super(blockSnapshot.getWorld(), blockSnapshot.getPos(), !(entity instanceof Player) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock());
this.entity = entity;
this.blockSnapshot = blockSnapshot;
this.placedBlock = !(entity instanceof PlayerEntity) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock();
this.placedBlock = !(entity instanceof Player) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock();
this.placedAgainst = placedAgainst;
if (DEBUG)
@@ -210,7 +208,7 @@ public class BlockEvent extends Event
private final EnumSet<Direction> notifiedSides;
private final boolean forceRedstoneUpdate;
public NeighborNotifyEvent(World world, BlockPos pos, BlockState state, EnumSet<Direction> notifiedSides, boolean forceRedstoneUpdate)
public NeighborNotifyEvent(Level world, BlockPos pos, BlockState state, EnumSet<Direction> notifiedSides, boolean forceRedstoneUpdate)
{
super(world, pos, state);
this.notifiedSides = notifiedSides;
@@ -246,18 +244,18 @@ public class BlockEvent extends Event
@HasResult
public static class CreateFluidSourceEvent extends Event
{
private final IWorldReader world;
private final LevelReader world;
private final BlockPos pos;
private final BlockState state;
public CreateFluidSourceEvent(IWorldReader world, BlockPos pos, BlockState state)
public CreateFluidSourceEvent(LevelReader world, BlockPos pos, BlockState state)
{
this.world = world;
this.pos = pos;
this.state = state;
}
public IWorldReader getWorld()
public LevelReader getWorld()
{
return world;
}
@@ -288,7 +286,7 @@ public class BlockEvent extends Event
private BlockState newState;
private BlockState origState;
public FluidPlaceBlockEvent(IWorld world, BlockPos pos, BlockPos liquidPos, BlockState state)
public FluidPlaceBlockEvent(LevelAccessor world, BlockPos pos, BlockPos liquidPos, BlockState state)
{
super(world, pos, state);
this.liquidPos = liquidPos;
@@ -332,7 +330,7 @@ public class BlockEvent extends Event
*/
public static class CropGrowEvent extends BlockEvent
{
public CropGrowEvent(World world, BlockPos pos, BlockState state)
public CropGrowEvent(Level world, BlockPos pos, BlockState state)
{
super(world, pos, state);
}
@@ -351,7 +349,7 @@ public class BlockEvent extends Event
@HasResult
public static class Pre extends CropGrowEvent
{
public Pre(World world, BlockPos pos, BlockState state)
public Pre(Level world, BlockPos pos, BlockState state)
{
super(world, pos, state);
}
@@ -369,7 +367,7 @@ public class BlockEvent extends Event
public static class Post extends CropGrowEvent
{
private final BlockState originalState;
public Post(World world, BlockPos pos, BlockState original, BlockState state)
public Post(Level world, BlockPos pos, BlockState original, BlockState state)
{
super(world, pos, state);
originalState = original;
@@ -393,7 +391,7 @@ public class BlockEvent extends Event
private final Entity entity;
private final float fallDistance;
public FarmlandTrampleEvent(World world, BlockPos pos, BlockState state, float fallDistance, Entity entity)
public FarmlandTrampleEvent(Level world, BlockPos pos, BlockState state, float fallDistance, Entity entity)
{
super(world, pos, state);
this.entity = entity;
@@ -418,15 +416,15 @@ public class BlockEvent extends Event
@Cancelable
public static class PortalSpawnEvent extends BlockEvent
{
private final PortalSize size;
private final PortalShape size;
public PortalSpawnEvent(IWorld world, BlockPos pos, BlockState state, PortalSize size)
public PortalSpawnEvent(LevelAccessor world, BlockPos pos, BlockState state, PortalShape size)
{
super(world, pos, state);
this.size = size;
}
public PortalSize getPortalSize()
public PortalShape getPortalSize()
{
return size;
}
@@ -434,7 +432,9 @@ public class BlockEvent extends Event
/**
* Fired when when this block is right clicked by a tool to change its state.
* For example: Used to determine if an axe can strip, a shovel can path, or a hoe can till.
* For example: Used to determine if an axe can strip or a shovel can path.
* For hoes, see {@link net.minecraft.world.item.HoeItem#TILLABLES} and
* {@link net.minecraftforge.event.entity.player.UseHoeEvent}.
*
* This event is {@link Cancelable}. If canceled, this will prevent the tool
* from changing the block's state.
@@ -443,12 +443,12 @@ public class BlockEvent extends Event
public static class BlockToolInteractEvent extends BlockEvent
{
private final PlayerEntity player;
private final Player player;
private final ItemStack stack;
private final ToolType toolType;
private BlockState state;
public BlockToolInteractEvent(IWorld world, BlockPos pos, BlockState originalState, PlayerEntity player, ItemStack stack, ToolType toolType)
public BlockToolInteractEvent(LevelAccessor world, BlockPos pos, BlockState originalState, Player player, ItemStack stack, ToolType toolType)
{
super(world, pos, originalState);
this.player = player;
@@ -458,7 +458,7 @@ public class BlockEvent extends Event
}
/**Gets the player using the tool.*/
public PlayerEntity getPlayer()
public Player getPlayer()
{
return player;
}
@@ -19,15 +19,10 @@
package net.minecraftforge.event.world;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.IChunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.ChunkAccess;
/**
* ChunkDataEvent is fired when an event involving chunk data occurs.<br>
@@ -40,21 +35,21 @@ import net.minecraftforge.eventbus.api.Event;
**/
public class ChunkDataEvent extends ChunkEvent
{
private final CompoundNBT data;
private final CompoundTag data;
public ChunkDataEvent(IChunk chunk, CompoundNBT data)
public ChunkDataEvent(ChunkAccess chunk, CompoundTag data)
{
super(chunk);
this.data = data;
}
public ChunkDataEvent(IChunk chunk, IWorld world, CompoundNBT data)
public ChunkDataEvent(ChunkAccess chunk, LevelAccessor world, CompoundTag data)
{
super(chunk, world);
this.data = data;
}
public CompoundNBT getData()
public CompoundTag getData()
{
return data;
}
@@ -72,15 +67,15 @@ public class ChunkDataEvent extends ChunkEvent
**/
public static class Load extends ChunkDataEvent
{
private ChunkStatus.Type status;
private ChunkStatus.ChunkType status;
public Load(IChunk chunk, CompoundNBT data, ChunkStatus.Type status)
public Load(ChunkAccess chunk, CompoundTag data, ChunkStatus.ChunkType status)
{
super(chunk, data);
this.status = status;
}
public ChunkStatus.Type getStatus()
public ChunkStatus.ChunkType getStatus()
{
return this.status;
}
@@ -99,7 +94,7 @@ public class ChunkDataEvent extends ChunkEvent
**/
public static class Save extends ChunkDataEvent
{
public Save(IChunk chunk, IWorld world, CompoundNBT data)
public Save(ChunkAccess chunk, LevelAccessor world, CompoundTag data)
{
super(chunk, world, data);
}
@@ -19,9 +19,8 @@
package net.minecraftforge.event.world;
import net.minecraft.world.IWorld;
import net.minecraft.world.chunk.IChunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.chunk.ChunkAccess;
/**
* ChunkEvent is fired when an event involving a chunk occurs.<br>
@@ -34,21 +33,21 @@ import net.minecraftforge.common.MinecraftForge;
**/
public class ChunkEvent extends WorldEvent
{
private final IChunk chunk;
private final ChunkAccess chunk;
public ChunkEvent(IChunk chunk)
public ChunkEvent(ChunkAccess chunk)
{
super(chunk.getWorldForge());
this.chunk = chunk;
}
public ChunkEvent(IChunk chunk, IWorld world)
public ChunkEvent(ChunkAccess chunk, LevelAccessor world)
{
super(world);
this.chunk = chunk;
}
public IChunk getChunk()
public ChunkAccess getChunk()
{
return chunk;
}
@@ -68,7 +67,7 @@ public class ChunkEvent extends WorldEvent
**/
public static class Load extends ChunkEvent
{
public Load(IChunk chunk)
public Load(ChunkAccess chunk)
{
super(chunk);
}
@@ -87,7 +86,7 @@ public class ChunkEvent extends WorldEvent
**/
public static class Unload extends ChunkEvent
{
public Unload(IChunk chunk)
public Unload(ChunkAccess chunk)
{
super(chunk);
}
@@ -19,9 +19,9 @@
package net.minecraftforge.event.world;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraftforge.eventbus.api.Event;
/**
@@ -40,18 +40,18 @@ import net.minecraftforge.eventbus.api.Event;
**/
public class ChunkWatchEvent extends Event
{
private final ServerWorld world;
private final ServerPlayerEntity player;
private final ServerLevel world;
private final ServerPlayer player;
private final ChunkPos pos;
public ChunkWatchEvent(ServerPlayerEntity player, ChunkPos pos, ServerWorld world)
public ChunkWatchEvent(ServerPlayer player, ChunkPos pos, ServerLevel world)
{
this.player = player;
this.pos = pos;
this.world = world;
}
public ServerPlayerEntity getPlayer()
public ServerPlayer getPlayer()
{
return this.player;
}
@@ -61,7 +61,7 @@ public class ChunkWatchEvent extends Event
return this.pos;
}
public ServerWorld getWorld()
public ServerLevel getWorld()
{
return this.world;
}
@@ -79,7 +79,7 @@ public class ChunkWatchEvent extends Event
**/
public static class Watch extends ChunkWatchEvent
{
public Watch(ServerPlayerEntity player, ChunkPos pos, ServerWorld world) {super(player, pos, world);}
public Watch(ServerPlayer player, ChunkPos pos, ServerLevel world) {super(player, pos, world);}
}
/**
@@ -95,6 +95,6 @@ public class ChunkWatchEvent extends Event
**/
public static class UnWatch extends ChunkWatchEvent
{
public UnWatch(ServerPlayerEntity player, ChunkPos pos, ServerWorld world) {super(player, pos, world);}
public UnWatch(ServerPlayer player, ChunkPos pos, ServerLevel world) {super(player, pos, world);}
}
}
@@ -21,13 +21,12 @@ package net.minecraftforge.event.world;
import java.util.List;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraft.world.entity.Entity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
/** ExplosionEvent triggers when an explosion happens in the world.<br>
* <br>
@@ -41,16 +40,16 @@ import net.minecraft.world.World;
*/
public class ExplosionEvent extends Event
{
private final World world;
private final Level world;
private final Explosion explosion;
public ExplosionEvent(World world, Explosion explosion)
public ExplosionEvent(Level world, Explosion explosion)
{
this.world = world;
this.explosion = explosion;
}
public World getWorld()
public Level getWorld()
{
return world;
}
@@ -69,7 +68,7 @@ public class ExplosionEvent extends Event
@Cancelable
public static class Start extends ExplosionEvent
{
public Start(World world, Explosion explosion)
public Start(Level world, Explosion explosion)
{
super(world, explosion);
}
@@ -85,7 +84,7 @@ public class ExplosionEvent extends Event
{
private final List<Entity> entityList;
public Detonate(World world, Explosion explosion, List<Entity> entityList)
public Detonate(Level world, Explosion explosion, List<Entity> entityList)
{
super(world, explosion);
this.entityList = entityList;
@@ -19,10 +19,10 @@
package net.minecraftforge.event.world;
import net.minecraft.block.BlockState;
import net.minecraft.state.properties.NoteBlockInstrument;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraftforge.eventbus.api.Cancelable;
import com.google.common.base.Preconditions;
@@ -35,7 +35,7 @@ public class NoteBlockEvent extends BlockEvent
{
private int noteId;
protected NoteBlockEvent(World world, BlockPos pos, BlockState state, int note)
protected NoteBlockEvent(Level world, BlockPos pos, BlockState state, int note)
{
super(world, pos, state);
this.noteId = note;
@@ -89,7 +89,7 @@ public class NoteBlockEvent extends BlockEvent
{
private NoteBlockInstrument instrument;
public Play(World world, BlockPos pos, BlockState state, int note, NoteBlockInstrument instrument)
public Play(Level world, BlockPos pos, BlockState state, int note, NoteBlockInstrument instrument)
{
super(world, pos, state, note);
this.instrument = instrument;
@@ -116,7 +116,7 @@ public class NoteBlockEvent extends BlockEvent
private final Note oldNote;
private final Octave oldOctave;
public Change(World world, BlockPos pos, BlockState state, int oldNote, int newNote)
public Change(Level world, BlockPos pos, BlockState state, int oldNote, int newNote)
{
super(world, pos, state, newNote);
this.oldNote = Note.fromId(oldNote);
@@ -21,10 +21,10 @@ package net.minecraftforge.event.world;
import javax.annotation.Nullable;
import net.minecraft.block.PistonBlockStructureHelper;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.level.block.piston.PistonStructureResolver;
import net.minecraft.core.Direction;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraftforge.eventbus.api.Cancelable;
/**
@@ -42,7 +42,7 @@ public abstract class PistonEvent extends BlockEvent
* @param direction - The direction of the piston
* @param direction - The move direction of the piston
*/
public PistonEvent(World world, BlockPos pos, Direction direction, PistonMoveType moveType)
public PistonEvent(Level world, BlockPos pos, Direction direction, PistonMoveType moveType)
{
super(world, pos, world.getBlockState(pos));
this.direction = direction;
@@ -77,10 +77,10 @@ public abstract class PistonEvent extends BlockEvent
* @return A piston structure helper for this movement. Returns null if the world stored is not a {@link World}
*/
@Nullable
public PistonBlockStructureHelper getStructureHelper()
public PistonStructureResolver getStructureHelper()
{
if(this.getWorld() instanceof World) {
return new PistonBlockStructureHelper((World) this.getWorld(), this.getPos(), this.getDirection(), this.getPistonMoveType().isExtend);
if(this.getWorld() instanceof Level) {
return new PistonStructureResolver((Level) this.getWorld(), this.getPos(), this.getDirection(), this.getPistonMoveType().isExtend);
} else {
return null;
}
@@ -92,7 +92,7 @@ public abstract class PistonEvent extends BlockEvent
public static class Post extends PistonEvent
{
public Post(World world, BlockPos pos, Direction direction, PistonMoveType moveType)
public Post(Level world, BlockPos pos, Direction direction, PistonMoveType moveType)
{
super(world, pos, direction, moveType);
}
@@ -106,7 +106,7 @@ public abstract class PistonEvent extends BlockEvent
public static class Pre extends PistonEvent
{
public Pre(World world, BlockPos pos, Direction direction, PistonMoveType moveType)
public Pre(Level world, BlockPos pos, Direction direction, PistonMoveType moveType)
{
super(world, pos, direction, moveType);
}
@@ -19,16 +19,6 @@
/*package net.minecraftforge.event.world;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.DimensionManager.SavedEntry;
import net.minecraftforge.eventbus.api.Event;
/**
* Register all of your custom ModDimensons here, fired during server loading when
* dimension data is read from the world file.
@@ -21,10 +21,8 @@ package net.minecraftforge.event.world;
import java.util.Random;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelAccessor;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
@@ -48,7 +46,7 @@ public class SaplingGrowTreeEvent extends WorldEvent
private final BlockPos pos;
private final Random rand;
public SaplingGrowTreeEvent(IWorld world, Random rand, BlockPos pos)
public SaplingGrowTreeEvent(LevelAccessor world, Random rand, BlockPos pos)
{
super(world);
this.rand = rand;
@@ -19,7 +19,7 @@
package net.minecraftforge.event.world;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.server.level.ServerLevel;
/**
* This event is fired when all players are asleep and the time should be set to day.<br>
@@ -31,7 +31,7 @@ public class SleepFinishedTimeEvent extends WorldEvent
private long newTime;
private final long minTime;
public SleepFinishedTimeEvent(ServerWorld worldIn, long newTimeIn, long minTimeIn)
public SleepFinishedTimeEvent(ServerLevel worldIn, long newTimeIn, long minTimeIn)
{
super(worldIn);
this.newTime = newTimeIn;
@@ -24,11 +24,10 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.entity.EntityClassification;
import net.minecraft.world.biome.MobSpawnInfo;
import net.minecraft.world.gen.feature.structure.Structure;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.biome.MobSpawnSettings;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.EventPriority;
/**
* This event fires when a Structure is gathering what mobs/creatures can spawn in it.
@@ -46,24 +45,24 @@ import net.minecraftforge.eventbus.api.EventPriority;
public class StructureSpawnListGatherEvent extends Event
{
private final Structure<?> structure;
private final Map<EntityClassification, List<MobSpawnInfo.Spawners>> entitySpawns = new HashMap<>();
private final Map<EntityClassification, List<MobSpawnInfo.Spawners>> entitySpawnsUnmodifiableLists = new HashMap<>();
private final Map<EntityClassification, List<MobSpawnInfo.Spawners>> entitySpawnsUnmodifiable = Collections.unmodifiableMap(entitySpawnsUnmodifiableLists);
private final StructureFeature<?> structure;
private final Map<MobCategory, List<MobSpawnSettings.SpawnerData>> entitySpawns = new HashMap<>();
private final Map<MobCategory, List<MobSpawnSettings.SpawnerData>> entitySpawnsUnmodifiableLists = new HashMap<>();
private final Map<MobCategory, List<MobSpawnSettings.SpawnerData>> entitySpawnsUnmodifiable = Collections.unmodifiableMap(entitySpawnsUnmodifiableLists);
private boolean insideOnly;
public StructureSpawnListGatherEvent(Structure<?> structure)
public StructureSpawnListGatherEvent(StructureFeature<?> structure)
{
this.structure = structure;
this.insideOnly = this.structure.getDefaultRestrictsSpawnsToInside();
addEntitySpawns(EntityClassification.MONSTER, this.structure.getDefaultSpawnList());
addEntitySpawns(EntityClassification.CREATURE, this.structure.getDefaultCreatureSpawnList());
addEntitySpawns(MobCategory.MONSTER, this.structure.getDefaultSpawnList());
addEntitySpawns(MobCategory.CREATURE, this.structure.getDefaultCreatureSpawnList());
}
/**
* @return Structure to add or remove spawns to/from.
*/
public Structure<?> getStructure()
public StructureFeature<?> getStructure()
{
return structure;
}
@@ -90,7 +89,7 @@ public class StructureSpawnListGatherEvent extends Event
* @param classification Entity Classification
* @return The list of spawns for the given classification.
*/
public List<MobSpawnInfo.Spawners> getEntitySpawns(EntityClassification classification)
public List<MobSpawnSettings.SpawnerData> getEntitySpawns(MobCategory classification)
{
return this.entitySpawnsUnmodifiableLists.getOrDefault(classification, Collections.emptyList());
}
@@ -98,10 +97,10 @@ public class StructureSpawnListGatherEvent extends Event
/**
* Gets the internal spawn list for a given entity classification, or adds one if needed. (This includes adding it to the unmodifiable view)
*/
private List<MobSpawnInfo.Spawners> getOrCreateEntitySpawns(EntityClassification classification)
private List<MobSpawnSettings.SpawnerData> getOrCreateEntitySpawns(MobCategory classification)
{
return this.entitySpawns.computeIfAbsent(classification, c -> {
List<MobSpawnInfo.Spawners> spawners = new ArrayList<>();
List<MobSpawnSettings.SpawnerData> spawners = new ArrayList<>();
//If the classification isn't in entitySpawns yet, also add an unmodifiable view of the list to
// the unmodifiable list spawn map
this.entitySpawnsUnmodifiableLists.put(c, Collections.unmodifiableList(spawners));
@@ -114,7 +113,7 @@ public class StructureSpawnListGatherEvent extends Event
* @param classification Entity Classification
* @param spawner Spawner
*/
public void addEntitySpawn(EntityClassification classification, MobSpawnInfo.Spawners spawner)
public void addEntitySpawn(MobCategory classification, MobSpawnSettings.SpawnerData spawner)
{
getOrCreateEntitySpawns(classification).add(spawner);
}
@@ -124,7 +123,7 @@ public class StructureSpawnListGatherEvent extends Event
* @param classification Entity Classification
* @param spawners Spawners to add
*/
public void addEntitySpawns(EntityClassification classification, List<MobSpawnInfo.Spawners> spawners)
public void addEntitySpawns(MobCategory classification, List<MobSpawnSettings.SpawnerData> spawners)
{
getOrCreateEntitySpawns(classification).addAll(spawners);
}
@@ -134,7 +133,7 @@ public class StructureSpawnListGatherEvent extends Event
* @param classification Entity Classification
* @param spawner Spawner
*/
public void removeEntitySpawn(EntityClassification classification, MobSpawnInfo.Spawners spawner)
public void removeEntitySpawn(MobCategory classification, MobSpawnSettings.SpawnerData spawner)
{
if (this.entitySpawns.containsKey(classification))
this.entitySpawns.get(classification).remove(spawner);
@@ -143,7 +142,7 @@ public class StructureSpawnListGatherEvent extends Event
/**
* Gets an unmodifiable view of the map of spawns based on entity classification that is used to fill in the various spawn lists for the structure.
*/
public Map<EntityClassification, List<MobSpawnInfo.Spawners>> getEntitySpawns()
public Map<MobCategory, List<MobSpawnSettings.SpawnerData>> getEntitySpawns()
{
return entitySpawnsUnmodifiable;
}
@@ -22,18 +22,11 @@ package net.minecraftforge.event.world;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityClassification;
import net.minecraft.profiler.Profiler;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.util.IProgressUpdate;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.biome.MobSpawnInfo;
import net.minecraft.world.storage.IServerWorldInfo;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.biome.MobSpawnSettings;
import net.minecraft.world.level.storage.ServerLevelData;
import net.minecraftforge.eventbus.api.Event;
/**
@@ -47,14 +40,14 @@ import net.minecraftforge.eventbus.api.Event;
**/
public class WorldEvent extends Event
{
private final IWorld world;
private final LevelAccessor world;
public WorldEvent(IWorld world)
public WorldEvent(LevelAccessor world)
{
this.world = world;
}
public IWorld getWorld()
public LevelAccessor getWorld()
{
return world;
}
@@ -76,7 +69,7 @@ public class WorldEvent extends Event
**/
public static class Load extends WorldEvent
{
public Load(IWorld world) { super(world); }
public Load(LevelAccessor world) { super(world); }
}
/**
@@ -95,7 +88,7 @@ public class WorldEvent extends Event
**/
public static class Unload extends WorldEvent
{
public Unload(IWorld world) { super(world); }
public Unload(LevelAccessor world) { super(world); }
}
/**
@@ -112,49 +105,7 @@ public class WorldEvent extends Event
**/
public static class Save extends WorldEvent
{
public Save(IWorld world) { super(world); }
}
/**
* Called by WorldServer to gather a list of all possible entities that can spawn at the specified location.
* If an entry is added to the list, it needs to be a globally unique instance.
* The event is called in {@link WorldServer#getSpawnListEntryForTypeAt(EnumCreatureType, BlockPos)} as well as
* {@link WorldServer#canCreatureTypeSpawnHere(EnumCreatureType, SpawnListEntry, BlockPos)}
* where the latter checks for identity, meaning both events must add the same instance.
* Canceling the event will result in a empty list, meaning no entity will be spawned.
*/
@net.minecraftforge.eventbus.api.Cancelable
public static class PotentialSpawns extends WorldEvent
{
private final EntityClassification type;
private final BlockPos pos;
private final List<MobSpawnInfo.Spawners> list;
public PotentialSpawns(IWorld world, EntityClassification type, BlockPos pos, List<MobSpawnInfo.Spawners> oldList)
{
super(world);
this.pos = pos;
this.type = type;
if (oldList != null)
this.list = new ArrayList<>(oldList);
else
this.list = new ArrayList<>();
}
public EntityClassification getType()
{
return type;
}
public BlockPos getPos()
{
return pos;
}
public List<MobSpawnInfo.Spawners> getList()
{
return list;
}
public Save(LevelAccessor world) { super(world); }
}
/**
@@ -164,14 +115,14 @@ public class WorldEvent extends Event
@net.minecraftforge.eventbus.api.Cancelable
public static class CreateSpawnPosition extends WorldEvent
{
private final IServerWorldInfo settings;
public CreateSpawnPosition(IWorld world, IServerWorldInfo settings)
private final ServerLevelData settings;
public CreateSpawnPosition(LevelAccessor world, ServerLevelData settings)
{
super(world);
this.settings = settings;
}
public IServerWorldInfo getSettings()
public ServerLevelData getSettings()
{
return settings;
}