mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
Minecraft 1.21.5
Co-authored-by: Ven <[email protected]> Co-authored-by: Jonathing <[email protected]>
This commit is contained in:
548 files changed
+5432
-7867
No files matched your search
@@ -337,9 +337,9 @@ public class BlockEvent extends Event {
|
||||
@Cancelable
|
||||
public static class FarmlandTrampleEvent extends BlockEvent {
|
||||
private final Entity entity;
|
||||
private final float fallDistance;
|
||||
private final double fallDistance;
|
||||
|
||||
public FarmlandTrampleEvent(ServerLevel level, BlockPos pos, BlockState state, float fallDistance, Entity entity) {
|
||||
public FarmlandTrampleEvent(ServerLevel level, BlockPos pos, BlockState state, double fallDistance, Entity entity) {
|
||||
super(level, pos, state);
|
||||
this.entity = entity;
|
||||
this.fallDistance = fallDistance;
|
||||
@@ -349,7 +349,7 @@ public class BlockEvent extends Event {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public float getFallDistance() {
|
||||
public double getFallDistance() {
|
||||
return fallDistance;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,42 +10,44 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.ReceivingLevelScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.ProgressListener;
|
||||
import net.minecraft.util.random.WeightedRandomList;
|
||||
import net.minecraft.util.random.Weighted;
|
||||
import net.minecraft.util.random.WeightedList;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.StructureManager;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.storage.ServerLevelData;
|
||||
import net.minecraftforge.common.ForgeInternalHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.UnmodifiableView;
|
||||
|
||||
/**
|
||||
* This event is fired whenever an event involving a {@link LevelAccessor} occurs.
|
||||
* <p>
|
||||
* All children of this event are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}.
|
||||
*/
|
||||
public class LevelEvent extends Event
|
||||
{
|
||||
public class LevelEvent extends Event {
|
||||
private final LevelAccessor level;
|
||||
|
||||
public LevelEvent(LevelAccessor level)
|
||||
{
|
||||
public LevelEvent(LevelAccessor level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the level this event is affecting}
|
||||
*/
|
||||
public LevelAccessor getLevel()
|
||||
{
|
||||
public LevelAccessor getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@@ -59,26 +61,23 @@ public class LevelEvent extends Event
|
||||
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}
|
||||
* on both logical sides.
|
||||
**/
|
||||
public static class Load extends LevelEvent
|
||||
{
|
||||
public static class Load extends LevelEvent {
|
||||
public Load(LevelAccessor level) { super(level); }
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is fired whenever a level unloads.
|
||||
* This event is fired whenever a level unloads in
|
||||
* {@link Minecraft#setLevel(ClientLevel)},
|
||||
* {@link Minecraft#setLevel(ClientLevel, ReceivingLevelScreen.Reason)},
|
||||
* {@link MinecraftServer#stopServer()},
|
||||
* {@link Minecraft#clearLevel(Screen)}, and
|
||||
* {@link ForgeInternalHandler#onDimensionUnload(Unload)}.
|
||||
* {@link Minecraft#clearClientLevel(Screen)}.
|
||||
* <p>
|
||||
* This event is not {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}.
|
||||
* <p>
|
||||
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}
|
||||
* on both logical sides.
|
||||
**/
|
||||
public static class Unload extends LevelEvent
|
||||
{
|
||||
public static class Unload extends LevelEvent {
|
||||
public Unload(LevelAccessor level) { super(level); }
|
||||
}
|
||||
|
||||
@@ -92,8 +91,7 @@ public class LevelEvent extends Event
|
||||
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}
|
||||
* only on the {@linkplain LogicalSide#SERVER logical server}.
|
||||
**/
|
||||
public static class Save extends LevelEvent
|
||||
{
|
||||
public static class Save extends LevelEvent {
|
||||
public Save(LevelAccessor level) { super(level); }
|
||||
}
|
||||
|
||||
@@ -110,18 +108,15 @@ public class LevelEvent extends Event
|
||||
* @see ServerLevelData#isInitialized()
|
||||
*/
|
||||
@Cancelable
|
||||
public static class CreateSpawnPosition extends LevelEvent
|
||||
{
|
||||
public static class CreateSpawnPosition extends LevelEvent {
|
||||
private final ServerLevelData settings;
|
||||
|
||||
public CreateSpawnPosition(LevelAccessor level, ServerLevelData settings)
|
||||
{
|
||||
public CreateSpawnPosition(LevelAccessor level, ServerLevelData settings) {
|
||||
super(level);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
public ServerLevelData getSettings()
|
||||
{
|
||||
public ServerLevelData getSettings() {
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
@@ -131,22 +126,20 @@ public class LevelEvent extends Event
|
||||
*
|
||||
* <p>If an entry is added to the list, it needs to be a globally unique instance.</p>
|
||||
*
|
||||
* The event is called in {@link net.minecraft.world.level.NaturalSpawner#mobsAt(ServerLevel,
|
||||
* StructureManager, ChunkGenerator, MobCategory, RandomSource, BlockPos)}.</p>
|
||||
* The event is called in {@link net.minecraft.world.level.NaturalSpawner#mobsAt(ServerLevel, StructureManager,
|
||||
* ChunkGenerator, MobCategory, BlockPos, Holder)}.</p>
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* Canceling the event will result in an empty list, meaning no entity will be spawned.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class PotentialSpawns extends LevelEvent
|
||||
{
|
||||
public static class PotentialSpawns extends LevelEvent {
|
||||
private final MobCategory mobcategory;
|
||||
private final BlockPos pos;
|
||||
private final List<MobSpawnSettings.SpawnerData> list;
|
||||
private final List<MobSpawnSettings.SpawnerData> view;
|
||||
private final List<Weighted<MobSpawnSettings.SpawnerData>> list;
|
||||
private final @UnmodifiableView List<Weighted<MobSpawnSettings.SpawnerData>> view;
|
||||
|
||||
public PotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedRandomList<MobSpawnSettings.SpawnerData> oldList)
|
||||
{
|
||||
public PotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedList<MobSpawnSettings.SpawnerData> oldList) {
|
||||
super(level);
|
||||
this.pos = pos;
|
||||
this.mobcategory = category;
|
||||
@@ -158,50 +151,39 @@ public class LevelEvent extends Event
|
||||
this.view = Collections.unmodifiableList(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the category of the mobs in the spawn list.}
|
||||
*/
|
||||
public MobCategory getMobCategory()
|
||||
{
|
||||
return mobcategory;
|
||||
/** @return the category of the mobs in the spawn list. */
|
||||
public MobCategory getMobCategory() {
|
||||
return this.mobcategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the block position where the chosen mob will be spawned.}
|
||||
*/
|
||||
public BlockPos getPos()
|
||||
{
|
||||
return pos;
|
||||
/** @return the block position where the chosen mob will be spawned. */
|
||||
public BlockPos getPos() {
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the list of mobs that can potentially be spawned.}
|
||||
*/
|
||||
public List<MobSpawnSettings.SpawnerData> getSpawnerDataList()
|
||||
{
|
||||
return view;
|
||||
/** @return the list of mobs that can potentially be spawned. */
|
||||
public @UnmodifiableView List<Weighted<MobSpawnSettings.SpawnerData>> getSpawnerDataList() {
|
||||
return this.view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a SpawnerData entry to the spawn list.
|
||||
*
|
||||
* @param data SpawnerData entry to be appended to the spawn list.
|
||||
* @param data SpawnerData entry to be appended to the spawn list.
|
||||
* @param weight The weight for the data entry to have in the list.
|
||||
*/
|
||||
public void addSpawnerData(MobSpawnSettings.SpawnerData data)
|
||||
{
|
||||
list.add(data);
|
||||
public void addSpawnerData(MobSpawnSettings.SpawnerData data, int weight) {
|
||||
this.list.add(new Weighted<>(data, weight));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a SpawnerData entry from the spawn list.
|
||||
* Removes all entries of the given SpawnerData from the spawn list.
|
||||
*
|
||||
* @param data SpawnerData entry to be removed from the spawn list.
|
||||
*
|
||||
* {@return {@code true} if the spawn list contained the specified element.}
|
||||
* @return {@code true} if the spawn list contained the specified element.
|
||||
*/
|
||||
public boolean removeSpawnerData(MobSpawnSettings.SpawnerData data)
|
||||
{
|
||||
return list.remove(data);
|
||||
public boolean removeSpawnerData(MobSpawnSettings.SpawnerData data) {
|
||||
return this.list.removeIf(weighted -> weighted.value().equals(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user