mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 14:34:28 +00:00
Some patch cleanup (#9951)
This commit is contained in:
1 parent
0cad6b14d9
commit
58012bfb17
18 files changed
+233
-113
No files matched your search
@@ -6,6 +6,7 @@
|
||||
package net.minecraftforge.event;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -13,6 +14,11 @@ import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -113,7 +119,6 @@ import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.ToolAction;
|
||||
import net.minecraftforge.common.capabilities.CapabilityDispatcher;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
@@ -138,10 +143,13 @@ import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingBreatheEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingConversionEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDestroyBlockEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDrownEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingExperienceDropEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHealEvent;
|
||||
@@ -154,7 +162,6 @@ import net.minecraftforge.event.entity.living.MobSpawnEvent.AllowDespawn;
|
||||
import net.minecraftforge.event.entity.living.MobSpawnEvent.PositionCheck;
|
||||
import net.minecraftforge.event.entity.living.MobSpawnEvent.SpawnPlacementCheck;
|
||||
import net.minecraftforge.event.entity.living.ShieldBlockEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent.ILivingTargetType;
|
||||
import net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent;
|
||||
import net.minecraftforge.event.entity.player.AdvancementEvent.AdvancementEarnEvent;
|
||||
import net.minecraftforge.event.entity.player.AdvancementEvent.AdvancementProgressEvent;
|
||||
@@ -201,27 +208,37 @@ import net.minecraftforge.event.level.SleepFinishedTimeEvent;
|
||||
import net.minecraftforge.event.network.ChannelRegistrationChangeEvent;
|
||||
import net.minecraftforge.event.network.ConnectionStartEvent;
|
||||
import net.minecraftforge.event.network.GatherLoginConfigurationTasksEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.Event.Result;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class ForgeEventFactory {
|
||||
private static final ModLoader ML = ModLoader.get();
|
||||
|
||||
private ForgeEventFactory() {}
|
||||
|
||||
/**
|
||||
* Post an event to the {@link MinecraftForge#EVENT_BUS}
|
||||
* @return true if the event is {@link Cancelable} and has been canceled
|
||||
*/
|
||||
private static boolean post(Event e) {
|
||||
return MinecraftForge.EVENT_BUS.post(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post an event to the {@link MinecraftForge#EVENT_BUS}, then return the event object
|
||||
* @return the event object passed in and possibly modified by listeners
|
||||
*/
|
||||
private static <E extends Event> E fire(E e) {
|
||||
post(e);
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post an event to the {@link ModLoader#get()} event bus
|
||||
*/
|
||||
private static <T extends Event & IModBusEvent> void postModBus(T e) {
|
||||
ModLoader.get().postEvent(e);
|
||||
ML.postEvent(e);
|
||||
}
|
||||
|
||||
public static boolean onMultiBlockPlace(@Nullable Entity entity, List<BlockSnapshot> blockSnapshots, Direction direction) {
|
||||
@@ -912,6 +929,10 @@ public final class ForgeEventFactory {
|
||||
post(new EntityEvent.EnteringSection(entity, packedOldPos, packedNewPos));
|
||||
}
|
||||
|
||||
public static boolean onLivingTick(LivingEntity entity) {
|
||||
return post(new LivingEvent.LivingTickEvent(entity));
|
||||
}
|
||||
|
||||
public static LivingFallEvent onLivingFall(LivingEntity entity, float distance, float damageMultiplier) {
|
||||
return fire(new LivingFallEvent(entity, distance, damageMultiplier));
|
||||
}
|
||||
@@ -928,6 +949,14 @@ public final class ForgeEventFactory {
|
||||
return fire(new LivingKnockBackEvent(target, strength, ratioX, ratioZ));
|
||||
}
|
||||
|
||||
public static boolean onLivingDeath(LivingEntity entity, DamageSource src) {
|
||||
return post(new LivingDeathEvent(entity, src));
|
||||
}
|
||||
|
||||
public static boolean onLivingDrops(LivingEntity entity, DamageSource source, Collection<ItemEntity> drops, int lootingLevel, boolean recentlyHit) {
|
||||
return post(new LivingDropsEvent(entity, source, drops, lootingLevel, recentlyHit));
|
||||
}
|
||||
|
||||
public static void onLeftClickEmpty(Player player) {
|
||||
post(new PlayerInteractEvent.LeftClickEmpty(player));
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ package net.minecraftforge.event.entity.living;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.world.entity.LivingEntity;
|
||||
* {@link Player#die(DamageSource)}, and
|
||||
* {@link ServerPlayer#die(DamageSource)}. <br>
|
||||
* <br>
|
||||
* This event is fired via the {@link ForgeHooks#onLivingDeath(LivingEntity, DamageSource)}.<br>
|
||||
* This event is fired via the {@link ForgeEventFactory#onLivingDeath(LivingEntity, DamageSource)}.<br>
|
||||
* <br>
|
||||
* {@link #source} contains the DamageSource that caused the entity to die. <br>
|
||||
* <br>
|
||||
|
||||
@@ -10,8 +10,8 @@ import java.util.Collection;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ import net.minecraftforge.eventbus.api.Cancelable;
|
||||
* This event is fired whenever an Entity dies and drops items in
|
||||
* {@link LivingEntity#die(DamageSource)}.<br>
|
||||
* <br>
|
||||
* This event is fired via the {@link ForgeHooks#onLivingDrops(LivingEntity, DamageSource, Collection, int, boolean)} .<br>
|
||||
* This event is fired via the {@link ForgeEventFactory#onLivingDrops(LivingEntity, DamageSource, Collection, int, boolean)} .<br>
|
||||
* <br>
|
||||
* {@link #source} contains the DamageSource that caused the drop to occur.<br>
|
||||
* {@link #drops} contains the ArrayList of EntityItems that will be dropped.<br>
|
||||
|
||||
@@ -8,6 +8,7 @@ package net.minecraftforge.event.entity.living;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
@@ -40,7 +41,7 @@ public class LivingEvent extends EntityEvent
|
||||
/**
|
||||
* LivingUpdateEvent is fired when a LivingEntity is ticked in {@link LivingEntity#tick()}. <br>
|
||||
* <br>
|
||||
* This event is fired via the {@link ForgeHooks#onLivingTick(LivingEntity)}.<br>
|
||||
* This event is fired via the {@link ForgeEventFactory#onLivingTick(LivingEntity)}.<br>
|
||||
* <br>
|
||||
* This event is {@link Cancelable}.<br>
|
||||
* If this event is canceled, the Entity does not update.<br>
|
||||
|
||||
Reference in new issue
Block a user