mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
1.21.3 update
This commit is contained in:
806 files changed
+6314
-10501
No files matched your search
@@ -9,6 +9,7 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.level.block.BaseFireBlock;
|
||||
@@ -338,7 +339,7 @@ public class BlockEvent extends Event {
|
||||
private final Entity entity;
|
||||
private final float fallDistance;
|
||||
|
||||
public FarmlandTrampleEvent(Level level, BlockPos pos, BlockState state, float fallDistance, Entity entity) {
|
||||
public FarmlandTrampleEvent(ServerLevel level, BlockPos pos, BlockState state, float fallDistance, Entity entity) {
|
||||
super(level, pos, state);
|
||||
this.entity = entity;
|
||||
this.fallDistance = fallDistance;
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
|
||||
package net.minecraftforge.event.level;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiManager;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.chunk.status.ChunkType;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkSerializer;
|
||||
import net.minecraft.world.level.chunk.storage.SerializableChunkData;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
@@ -27,26 +26,26 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
||||
**/
|
||||
public class ChunkDataEvent extends ChunkEvent {
|
||||
private final CompoundTag data;
|
||||
private final SerializableChunkData data;
|
||||
|
||||
public ChunkDataEvent(ChunkAccess chunk, CompoundTag data) {
|
||||
public ChunkDataEvent(ChunkAccess chunk, SerializableChunkData data) {
|
||||
super(chunk);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ChunkDataEvent(ChunkAccess chunk, LevelAccessor world, CompoundTag data) {
|
||||
public ChunkDataEvent(ChunkAccess chunk, LevelAccessor world, SerializableChunkData data) {
|
||||
super(chunk, world);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public CompoundTag getData() {
|
||||
public SerializableChunkData getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChunkDataEvent.Load is fired when vanilla Minecraft attempts to load Chunk data.<br>
|
||||
* This event is fired during chunk loading in
|
||||
* {@link ChunkSerializer#read(ServerLevel, PoiManager, ChunkPos, CompoundTag)} which means it is async, so be careful.<br>
|
||||
* {@link ChunkSerializer#read(ServerLevel, PoiManager, ChunkPos, SerializableChunkData)} which means it is async, so be careful.<br>
|
||||
* <br>
|
||||
* This event is not {@link Cancelable}.<br>
|
||||
* <br>
|
||||
@@ -57,7 +56,7 @@ public class ChunkDataEvent extends ChunkEvent {
|
||||
public static class Load extends ChunkDataEvent {
|
||||
private ChunkType status;
|
||||
|
||||
public Load(ChunkAccess chunk, CompoundTag data, ChunkType status) {
|
||||
public Load(ChunkAccess chunk, SerializableChunkData data, ChunkType status) {
|
||||
super(chunk, data);
|
||||
this.status = status;
|
||||
}
|
||||
@@ -79,7 +78,7 @@ public class ChunkDataEvent extends ChunkEvent {
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
||||
**/
|
||||
public static class Save extends ChunkDataEvent {
|
||||
public Save(ChunkAccess chunk, LevelAccessor world, CompoundTag data) {
|
||||
public Save(ChunkAccess chunk, LevelAccessor world, SerializableChunkData data) {
|
||||
super(chunk, world, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,24 +25,20 @@ import net.minecraft.world.level.Level;
|
||||
* Children do not use {@link HasResult}.<br>
|
||||
* Children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
||||
*/
|
||||
public class ExplosionEvent extends Event
|
||||
{
|
||||
public class ExplosionEvent extends Event {
|
||||
private final Level level;
|
||||
private final Explosion explosion;
|
||||
|
||||
public ExplosionEvent(Level level, Explosion explosion)
|
||||
{
|
||||
public ExplosionEvent(Level level, Explosion explosion) {
|
||||
this.level = level;
|
||||
this.explosion = explosion;
|
||||
}
|
||||
|
||||
public Level getLevel()
|
||||
{
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public Explosion getExplosion()
|
||||
{
|
||||
public Explosion getExplosion() {
|
||||
return explosion;
|
||||
}
|
||||
|
||||
@@ -53,10 +49,8 @@ public class ExplosionEvent extends Event
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Start extends ExplosionEvent
|
||||
{
|
||||
public Start(Level level, Explosion explosion)
|
||||
{
|
||||
public static class Start extends ExplosionEvent {
|
||||
public Start(Level level, Explosion explosion) {
|
||||
super(level, explosion);
|
||||
}
|
||||
}
|
||||
@@ -67,25 +61,23 @@ public class ExplosionEvent extends Event
|
||||
* This event does not use {@link HasResult}.<br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
|
||||
*/
|
||||
public static class Detonate extends ExplosionEvent
|
||||
{
|
||||
public static class Detonate extends ExplosionEvent {
|
||||
private final List<BlockPos> blocks;
|
||||
private final List<Entity> entityList;
|
||||
|
||||
public Detonate(Level level, Explosion explosion, List<Entity> entityList)
|
||||
{
|
||||
public Detonate(Level level, Explosion explosion, List<BlockPos> blocks, List<Entity> entityList) {
|
||||
super(level, explosion);
|
||||
this.blocks = blocks;
|
||||
this.entityList = entityList;
|
||||
}
|
||||
|
||||
/** return the list of blocks affected by the explosion. */
|
||||
public List<BlockPos> getAffectedBlocks()
|
||||
{
|
||||
return getExplosion().getToBlow();
|
||||
public List<BlockPos> getAffectedBlocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/** return the list of entities affected by the explosion. */
|
||||
public List<Entity> getAffectedEntities()
|
||||
{
|
||||
public List<Entity> getAffectedEntities() {
|
||||
return entityList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,15 +30,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
// TODO: Rename to BlockFeatureGrowEvent in 1.20
|
||||
@HasResult
|
||||
public class SaplingGrowTreeEvent extends LevelEvent
|
||||
{
|
||||
@Deprecated(forRemoval = true, since = "1.21.1") // Dont remove, rename
|
||||
public class SaplingGrowTreeEvent extends LevelEvent {
|
||||
private final RandomSource randomSource;
|
||||
private final BlockPos pos;
|
||||
@Nullable
|
||||
private Holder<ConfiguredFeature<?, ?>> feature;
|
||||
|
||||
public SaplingGrowTreeEvent(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable Holder<ConfiguredFeature<?, ?>> feature)
|
||||
{
|
||||
public SaplingGrowTreeEvent(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable Holder<ConfiguredFeature<?, ?>> feature) {
|
||||
super(level);
|
||||
this.randomSource = randomSource;
|
||||
this.pos = pos;
|
||||
@@ -48,16 +47,14 @@ public class SaplingGrowTreeEvent extends LevelEvent
|
||||
/**
|
||||
* {@return the random source which initiated the sapling growth}
|
||||
*/
|
||||
public RandomSource getRandomSource()
|
||||
{
|
||||
public RandomSource getRandomSource() {
|
||||
return this.randomSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the coordinates of the sapling attempting to grow}
|
||||
*/
|
||||
public BlockPos getPos()
|
||||
{
|
||||
public BlockPos getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@@ -65,24 +62,21 @@ public class SaplingGrowTreeEvent extends LevelEvent
|
||||
* {@return the holder of the feature which will be placed, possibly null}
|
||||
*/
|
||||
@Nullable
|
||||
public Holder<ConfiguredFeature<?, ?>> getFeature()
|
||||
{
|
||||
public Holder<ConfiguredFeature<?, ?>> getFeature() {
|
||||
return feature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param feature a {@linkplain Holder} referencing a tree feature to be placed instead of the current feature.
|
||||
*/
|
||||
public void setFeature(@Nullable Holder<ConfiguredFeature<?, ?>> feature)
|
||||
{
|
||||
public void setFeature(@Nullable Holder<ConfiguredFeature<?, ?>> feature) {
|
||||
this.feature = feature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param featureKey a {@linkplain ResourceKey} referencing a tree feature to be placed instead of the current feature.
|
||||
*/
|
||||
public void setFeature(ResourceKey<ConfiguredFeature<?, ?>> featureKey)
|
||||
{
|
||||
this.feature = this.getLevel().registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(featureKey).orElse(null);
|
||||
public void setFeature(ResourceKey<ConfiguredFeature<?, ?>> featureKey) {
|
||||
this.feature = this.getLevel().registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(featureKey).orElse(null);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user