[1.19.x] Apply general renames, A SRG is provided for modders. (#8840)

See https://gist.github.com/SizableShrimp/882a671ff74256d150776da08c89ef72
This commit is contained in:
SizableShrimp authored and GitHub committed 2022-07-11 18:27:48 -07:00
1 parent 5e8c786406
commit b8b40e1f54
140 files changed
+1138 -1149

No files matched your search

@@ -14,12 +14,12 @@ import net.minecraftforge.forgespi.language.IModInfo;
import java.util.Optional;
import java.util.function.BiFunction;
public class ConfigGuiHandler
public class ConfigScreenHandler
{
public record ConfigGuiFactory(BiFunction<Minecraft, Screen, Screen> screenFunction) implements IExtensionPoint<ConfigGuiFactory> {}
public static Optional<BiFunction<Minecraft, Screen, Screen>> getGuiFactoryFor(IModInfo selectedMod)
public record ConfigScreenFactory(BiFunction<Minecraft, Screen, Screen> screenFunction) implements IExtensionPoint<ConfigScreenFactory> {}
public static Optional<BiFunction<Minecraft, Screen, Screen>> getScreenFactoryFor(IModInfo selectedMod)
{
return ModList.get().getModContainerById(selectedMod.getModId()).
flatMap(mc -> mc.getCustomExtension(ConfigGuiFactory.class).map(ConfigGuiFactory::screenFunction));
flatMap(mc -> mc.getCustomExtension(ConfigScreenFactory.class).map(ConfigScreenFactory::screenFunction));
}
}
@@ -19,10 +19,11 @@ import java.util.stream.Collectors;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraftforge.client.ConfigScreenHandler;
import net.minecraftforge.client.gui.widget.ModListWidget;
import net.minecraftforge.client.gui.widget.ScrollPanel;
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
import net.minecraftforge.resource.PathResourcePack;
import net.minecraftforge.resource.PathPackResources;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -50,7 +51,6 @@ import net.minecraftforge.common.util.MavenVersionStringHelper;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.VersionChecker;
import net.minecraftforge.client.ConfigGuiHandler;
import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.fml.loading.StringUtils;
import net.minecraftforge.resource.ResourcePackLoader;
@@ -302,7 +302,7 @@ public class ModListScreen extends Screen
if (selected == null) return;
try
{
ConfigGuiHandler.getGuiFactoryFor(selected.getInfo()).map(f->f.apply(this.minecraft, this)).ifPresent(newScreen -> this.minecraft.setScreen(newScreen));
ConfigScreenHandler.getScreenFactoryFor(selected.getInfo()).map(f->f.apply(this.minecraft, this)).ifPresent(newScreen -> this.minecraft.setScreen(newScreen));
}
catch (final Exception e)
{
@@ -398,7 +398,7 @@ public class ModListScreen extends Screen
return;
}
IModInfo selectedMod = selected.getInfo();
this.configButton.active = ConfigGuiHandler.getGuiFactoryFor(selectedMod).isPresent();
this.configButton.active = ConfigScreenHandler.getScreenFactoryFor(selectedMod).isPresent();
List<String> lines = new ArrayList<>();
VersionChecker.CheckResult vercheck = VersionChecker.getResult(selectedMod);
@@ -406,7 +406,7 @@ public class ModListScreen extends Screen
Pair<ResourceLocation, Size2i> logoData = selectedMod.getLogoFile().map(logoFile->
{
TextureManager tm = this.minecraft.getTextureManager();
final PathResourcePack resourcePack = ResourcePackLoader.getPackFor(selectedMod.getModId())
final PathPackResources resourcePack = ResourcePackLoader.getPackFor(selectedMod.getModId())
.orElse(ResourcePackLoader.getPackFor("forge").
orElseThrow(()->new RuntimeException("Can't find forge, WHAT!")));
try
@@ -29,7 +29,7 @@ import net.minecraftforge.internal.BrandingControl;
import net.minecraftforge.logging.CrashReportExtender;
import net.minecraftforge.common.util.LogicalSidedProvider;
import net.minecraftforge.forgespi.locating.IModFile;
import net.minecraftforge.resource.PathResourcePack;
import net.minecraftforge.resource.PathPackResources;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -46,7 +46,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfig;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.client.gui.LoadingErrorScreen;
import net.minecraftforge.resource.DelegatingResourcePack;
import net.minecraftforge.resource.DelegatingPackResources;
import net.minecraftforge.resource.ResourcePackLoader;
import net.minecraftforge.server.LanguageHook;
import net.minecraftforge.forgespi.language.IModInfo;
@@ -182,13 +182,13 @@ public class ClientModLoader
return loading;
}
private static RepositorySource buildPackFinder(Map<IModFile, ? extends PathResourcePack> modResourcePacks) {
private static RepositorySource buildPackFinder(Map<IModFile, ? extends PathPackResources> modResourcePacks) {
return (packList, factory) -> clientPackFinder(modResourcePacks, packList, factory);
}
private static void clientPackFinder(Map<IModFile, ? extends PathResourcePack> modResourcePacks, Consumer<Pack> consumer, Pack.PackConstructor factory) {
List<PathResourcePack> hiddenPacks = new ArrayList<>();
for (Entry<IModFile, ? extends PathResourcePack> e : modResourcePacks.entrySet())
private static void clientPackFinder(Map<IModFile, ? extends PathPackResources> modResourcePacks, Consumer<Pack> consumer, Pack.PackConstructor factory) {
List<PathPackResources> hiddenPacks = new ArrayList<>();
for (Entry<IModFile, ? extends PathPackResources> e : modResourcePacks.entrySet())
{
IModInfo mod = e.getKey().getModInfos().get(0);
final String name = "mod:" + mod.getModId();
@@ -205,7 +205,7 @@ public class ClientModLoader
hiddenPacks.add(e.getValue());
}
}
final Pack packInfo = Pack.create("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources",
final Pack packInfo = Pack.create("mod_resources", true, () -> new DelegatingPackResources("mod_resources", "Mod Resources",
new PackMetadataSection(Component.translatable("fml.resources.modresources", hiddenPacks.size()), PackType.CLIENT_RESOURCES.getVersion(SharedConstants.getCurrentVersion())),
hiddenPacks), factory, Pack.Position.BOTTOM, PackSource.DEFAULT);
consumer.accept(packInfo);
@@ -11,7 +11,7 @@ import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.level.ChunkEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
@@ -26,11 +26,9 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.mojang.serialization.Codec;
import com.mojang.serialization.Lifecycle;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.ResourceLocationException;
import net.minecraft.Util;
import net.minecraft.advancements.Advancement;
import net.minecraft.core.*;
import net.minecraft.network.chat.*;
@@ -86,7 +84,6 @@ import net.minecraft.world.*;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.block.entity.FurnaceBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.BlockHitResult;
@@ -101,8 +98,6 @@ import net.minecraftforge.common.loot.LootTableIdCondition;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.common.util.Lazy;
import net.minecraftforge.common.util.MavenVersionStringHelper;
import net.minecraftforge.common.world.BiomeGenerationSettingsBuilder;
import net.minecraftforge.common.world.MobSpawnSettingsBuilder;
import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.DifficultyChangeEvent;
import net.minecraftforge.event.ForgeEventFactory;
@@ -122,7 +117,7 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingTickEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.living.LivingKnockBackEvent;
@@ -136,8 +131,8 @@ import net.minecraftforge.event.entity.player.CriticalHitEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.entity.living.LivingGetProjectileEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.NoteBlockEvent;
import net.minecraftforge.event.level.BlockEvent;
import net.minecraftforge.event.level.NoteBlockEvent;
import net.minecraftforge.eventbus.api.Event.Result;
import net.minecraftforge.fluids.FluidType;
import net.minecraftforge.fml.ModContainer;
@@ -149,7 +144,6 @@ import net.minecraftforge.registries.ForgeRegistry;
import net.minecraftforge.registries.GameData;
import net.minecraftforge.registries.RegistryManager;
import net.minecraftforge.server.ServerLifecycleHooks;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
@@ -164,10 +158,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.state.pattern.BlockInWorld;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.material.EmptyFluid;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.LavaFluid;
import net.minecraft.world.level.material.WaterFluid;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -227,7 +218,7 @@ public class ForgeHooks
result = entity.getPickedResult(target);
if (result.isEmpty())
LOGGER.warn("Picking on: [{}] {} gave null item", target.getType(), ForgeRegistries.ENTITIES.getKey(entity.getType()));
LOGGER.warn("Picking on: [{}] {} gave null item", target.getType(), ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()));
}
if (result.isEmpty())
@@ -267,9 +258,9 @@ public class ForgeHooks
MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
}
public static boolean onLivingUpdate(LivingEntity entity)
public static boolean onLivingTick(LivingEntity entity)
{
return MinecraftForge.EVENT_BUS.post(new LivingUpdateEvent(entity));
return MinecraftForge.EVENT_BUS.post(new LivingTickEvent(entity));
}
public static boolean onLivingAttack(LivingEntity entity, DamageSource src, float amount)
@@ -394,8 +385,8 @@ public class ForgeHooks
return null;
if (!player.level.isClientSide)
player.getCommandSenderWorld().addFreshEntity(event.getEntityItem());
return event.getEntityItem();
player.getCommandSenderWorld().addFreshEntity(event.getEntity());
return event.getEntity();
}
public static boolean onVanillaGameEvent(Level level, GameEvent vanillaEvent, Vec3 pos, GameEvent.Context context)
@@ -664,11 +655,11 @@ public class ForgeHooks
return craftingPlayer.get();
}
@NotNull
public static ItemStack getContainerItem(@NotNull ItemStack stack)
public static ItemStack getCraftingRemainingItem(@NotNull ItemStack stack)
{
if (stack.getItem().hasContainerItem(stack))
if (stack.getItem().hasCraftingRemainingItem(stack))
{
stack = stack.getItem().getContainerItem(stack);
stack = stack.getItem().getCraftingRemainingItem(stack);
if (!stack.isEmpty() && stack.isDamageableItem() && stack.getDamageValue() > stack.getMaxDamage())
{
ForgeEventFactory.onPlayerDestroyItem(craftingPlayer.get(), stack, null);
@@ -1011,7 +1002,7 @@ public class ForgeHooks
}
else if (item instanceof SpawnEggItem)
{
ResourceLocation resourceLocation = ForgeRegistries.ENTITIES.getKey(((SpawnEggItem) item).getType(null));
ResourceLocation resourceLocation = ForgeRegistries.ENTITY_TYPES.getKey(((SpawnEggItem) item).getType(null));
if (resourceLocation != null)
{
return resourceLocation.getNamespace();
@@ -1081,7 +1072,7 @@ public class ForgeHooks
if (serializer == null)
{
// ForgeRegistries.DATA_SERIALIZERS is a deferred register now, so if this method is called too early, the registry will be null
ForgeRegistry<EntityDataSerializer<?>> registry = (ForgeRegistry<EntityDataSerializer<?>>) ForgeRegistries.DATA_SERIALIZERS.get();
ForgeRegistry<EntityDataSerializer<?>> registry = (ForgeRegistry<EntityDataSerializer<?>>) ForgeRegistries.ENTITY_DATA_SERIALIZERS.get();
if (registry != null)
serializer = registry.getValue(id);
}
@@ -1094,7 +1085,7 @@ public class ForgeHooks
if (id < 0)
{
// ForgeRegistries.DATA_SERIALIZERS is a deferred register now, so if this method is called too early, the registry will be null
ForgeRegistry<EntityDataSerializer<?>> registry = (ForgeRegistry<EntityDataSerializer<?>>) ForgeRegistries.DATA_SERIALIZERS.get();
ForgeRegistry<EntityDataSerializer<?>> registry = (ForgeRegistry<EntityDataSerializer<?>>) ForgeRegistries.ENTITY_DATA_SERIALIZERS.get();
if (registry != null)
id = registry.getID(serializer);
}
@@ -9,17 +9,16 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.util.thread.BlockableEventLoop;
import net.minecraft.server.TickTask;
import net.minecraft.server.level.ServerLevel;
import net.minecraftforge.common.loot.LootModifierManager;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.event.AddReloadListenerEvent;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.event.level.ChunkEvent;
import net.minecraftforge.event.level.LevelEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.event.TagsUpdatedEvent;
@@ -34,7 +33,7 @@ import net.minecraftforge.server.command.ConfigCommand;
public class ForgeInternalHandler
{
@SubscribeEvent(priority = EventPriority.HIGH)
public void onEntityJoinWorld(EntityJoinWorldEvent event)
public void onEntityJoinWorld(EntityJoinLevelEvent event)
{
Entity entity = event.getEntity();
if (entity.getClass().equals(ItemEntity.class))
@@ -43,13 +42,13 @@ public class ForgeInternalHandler
Item item = stack.getItem();
if (item.hasCustomEntity(stack))
{
Entity newEntity = item.createEntity(event.getWorld(), entity, stack);
Entity newEntity = item.createEntity(event.getLevel(), entity, stack);
if (newEntity != null)
{
entity.discard();
event.setCanceled(true);
var executor = LogicalSidedProvider.WORKQUEUE.get(event.getWorld().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER);
executor.tell(new TickTask(0, () -> event.getWorld().addFreshEntity(newEntity)));
var executor = LogicalSidedProvider.WORKQUEUE.get(event.getLevel().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER);
executor.tell(new TickTask(0, () -> event.getLevel().addFreshEntity(newEntity)));
}
}
}
@@ -57,10 +56,10 @@ public class ForgeInternalHandler
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDimensionUnload(WorldEvent.Unload event)
public void onDimensionUnload(LevelEvent.Unload event)
{
if (event.getWorld() instanceof ServerLevel)
FakePlayerFactory.unloadLevel((ServerLevel) event.getWorld());
if (event.getLevel() instanceof ServerLevel)
FakePlayerFactory.unloadLevel((ServerLevel) event.getLevel());
}
@SubscribeEvent
@@ -79,7 +78,7 @@ public class ForgeInternalHandler
@SubscribeEvent
public void onChunkUnload(ChunkEvent.Unload event)
{
if (!event.getWorld().isClientSide())
if (!event.getLevel().isClientSide())
FarmlandWaterManager.removeTickets(event.getChunk());
}
@@ -95,7 +94,7 @@ public class ForgeInternalHandler
@SubscribeEvent
public void playerLogin(PlayerEvent.PlayerLoggedInEvent event)
{
UsernameCache.setUsername(event.getPlayer().getUUID(), event.getPlayer().getGameProfile().getName());
UsernameCache.setUsername(event.getEntity().getUUID(), event.getEntity().getGameProfile().getName());
}
@SubscribeEvent
@@ -63,7 +63,7 @@ import net.minecraftforge.registries.*;
import net.minecraftforge.network.NetworkConstants;
import net.minecraftforge.event.server.ServerStoppingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.network.filters.VanillaPacketSplitter;
import net.minecraftforge.server.command.EnumArgument;
import net.minecraftforge.server.command.ModIdArgument;
@@ -78,7 +78,7 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.crafting.CompoundIngredient;
import net.minecraftforge.common.crafting.ConditionalRecipe;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.crafting.NBTIngredient;
import net.minecraftforge.common.crafting.StrictNBTIngredient;
import net.minecraftforge.common.crafting.VanillaIngredientSerializer;
import net.minecraftforge.common.crafting.conditions.AndCondition;
import net.minecraftforge.common.crafting.conditions.FalseCondition;
@@ -167,7 +167,7 @@ public class ForgeMod
Decoration.CODEC.fieldOf("step").forGetter(AddFeaturesBiomeModifier::step)
).apply(builder, AddFeaturesBiomeModifier::new))
);
/**
* Stock biome modifier for removing features from biomes.
*/
@@ -181,7 +181,7 @@ public class ForgeMod
).optionalFieldOf("steps", EnumSet.allOf(Decoration.class)).forGetter(RemoveFeaturesBiomeModifier::steps)
).apply(builder, RemoveFeaturesBiomeModifier::new))
);
/**
* Stock biome modifier for adding mob spawns to biomes.
*/
@@ -196,7 +196,7 @@ public class ForgeMod
).fieldOf("spawners").forGetter(AddSpawnsBiomeModifier::spawners)
).apply(builder, AddSpawnsBiomeModifier::new))
);
/**
* Stock biome modifier for removing mob spawns from biomes.
*/
@@ -535,7 +535,7 @@ public class ForgeMod
CraftingHelper.register(TagEmptyCondition.Serializer.INSTANCE);
CraftingHelper.register(new ResourceLocation("forge", "compound"), CompoundIngredient.Serializer.INSTANCE);
CraftingHelper.register(new ResourceLocation("forge", "nbt"), NBTIngredient.Serializer.INSTANCE);
CraftingHelper.register(new ResourceLocation("forge", "nbt"), StrictNBTIngredient.Serializer.INSTANCE);
CraftingHelper.register(new ResourceLocation("forge", "partial_nbt"), PartialNBTIngredient.Serializer.INSTANCE);
CraftingHelper.register(new ResourceLocation("forge", "difference"), DifferenceIngredient.Serializer.INSTANCE);
CraftingHelper.register(new ResourceLocation("forge", "intersection"), IntersectionIngredient.Serializer.INSTANCE);
@@ -343,7 +343,7 @@ public class TierSortingRegistry
private static void playerLoggedIn(PlayerEvent.PlayerLoggedInEvent event)
{
if (event.getPlayer() instanceof ServerPlayer serverPlayer)
if (event.getEntity() instanceof ServerPlayer serverPlayer)
{
syncToPlayer(serverPlayer);
}
@@ -63,7 +63,7 @@ public class VillagerTradingManager
*/
private static void postVillagerEvents()
{
for (VillagerProfession prof : ForgeRegistries.PROFESSIONS)
for (VillagerProfession prof : ForgeRegistries.VILLAGER_PROFESSIONS)
{
Int2ObjectMap<ItemListing[]> trades = VANILLA_TRADES.getOrDefault(prof, new Int2ObjectOpenHashMap<>());
Int2ObjectMap<List<ItemListing>> mutableTrades = new Int2ObjectOpenHashMap<>();
@@ -23,13 +23,12 @@ import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/** Ingredient that matches the given items, performing a partial NBT match. Use {@link NBTIngredient} if you want exact match on NBT */
/** Ingredient that matches the given items, performing a partial NBT match. Use {@link StrictNBTIngredient} if you want exact match on NBT */
public class PartialNBTIngredient extends AbstractIngredient
{
private final Set<Item> items;
@@ -17,19 +17,19 @@ import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.Nullable;
/** Ingredient that matches the given stack, performing an exact NBT match. Use {@link PartialNBTIngredient} if you need partial match. */
public class NBTIngredient extends AbstractIngredient
public class StrictNBTIngredient extends AbstractIngredient
{
private final ItemStack stack;
protected NBTIngredient(ItemStack stack)
protected StrictNBTIngredient(ItemStack stack)
{
super(Stream.of(new Ingredient.ItemValue(stack)));
this.stack = stack;
}
/** Creates a new ingredient matching the given stack and tag */
public static NBTIngredient of(ItemStack stack)
public static StrictNBTIngredient of(ItemStack stack)
{
return new NBTIngredient(stack);
return new StrictNBTIngredient(stack);
}
@Override
@@ -65,22 +65,22 @@ public class NBTIngredient extends AbstractIngredient
return json;
}
public static class Serializer implements IIngredientSerializer<NBTIngredient>
public static class Serializer implements IIngredientSerializer<StrictNBTIngredient>
{
public static final Serializer INSTANCE = new Serializer();
@Override
public NBTIngredient parse(FriendlyByteBuf buffer) {
return new NBTIngredient(buffer.readItem());
public StrictNBTIngredient parse(FriendlyByteBuf buffer) {
return new StrictNBTIngredient(buffer.readItem());
}
@Override
public NBTIngredient parse(JsonObject json) {
return new NBTIngredient(CraftingHelper.getItemStack(json, true));
public StrictNBTIngredient parse(JsonObject json) {
return new StrictNBTIngredient(CraftingHelper.getItemStack(json, true));
}
@Override
public void write(FriendlyByteBuf buffer, NBTIngredient ingredient) {
public void write(FriendlyByteBuf buffer, StrictNBTIngredient ingredient) {
buffer.writeItem(ingredient.stack);
}
}
@@ -33,8 +33,8 @@ import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.VanillaPackResources;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.client.model.generators.ModelBuilder;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
import net.minecraftforge.forgespi.language.IModFileInfo;
import net.minecraftforge.resource.ResourcePackLoader;
import org.jetbrains.annotations.Nullable;
@@ -27,7 +27,6 @@ import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType;
import net.minecraftforge.common.data.ExistingFileHelper.ResourceType;
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
import org.slf4j.Logger;
/**
@@ -70,12 +70,12 @@ public interface IForgeBlockEntity extends ICapabilitySerializable<CompoundTag>
}
/**
* Gets a {@link CompoundTag} that can be used to store custom data for this tile entity.
* Gets a {@link CompoundTag} that can be used to store custom data for this block entity.
* It will be written, and read from disc, so it persists over world saves.
*
* @return A compound tag for custom data
* @return A compound tag for custom persistent data
*/
CompoundTag getTileData();
CompoundTag getPersistentData();
default void onChunkUnloaded(){}
@@ -215,16 +215,16 @@ public interface IForgeItem
}
/**
* ItemStack sensitive version of getContainerItem. Returns a full ItemStack
* instance of the result.
* ItemStack sensitive version of {@link Item#getCraftingRemainingItem()}.
* Returns a full ItemStack instance of the result.
*
* @param itemStack The current ItemStack
* @return The resulting ItemStack
*/
@SuppressWarnings("deprecation")
default ItemStack getContainerItem(ItemStack itemStack)
default ItemStack getCraftingRemainingItem(ItemStack itemStack)
{
if (!hasContainerItem(itemStack))
if (!hasCraftingRemainingItem(itemStack))
{
return ItemStack.EMPTY;
}
@@ -232,13 +232,13 @@ public interface IForgeItem
}
/**
* ItemStack sensitive version of hasContainerItem
* ItemStack sensitive version of {@link Item#hasCraftingRemainingItem()}.
*
* @param stack The current item stack
* @return True if this item has a 'container'
* @return True if this item has a crafting remaining item
*/
@SuppressWarnings("deprecation")
default boolean hasContainerItem(ItemStack stack)
default boolean hasCraftingRemainingItem(ItemStack stack)
{
return self().hasCraftingRemainingItem();
}
@@ -481,24 +481,24 @@ public interface IForgeItem
/**
* Gets the maximum number of items that this stack should be able to hold. This
* is a ItemStack (and thus NBT) sensitive version of Item.getItemStackLimit()
* is a ItemStack (and thus NBT) sensitive version of {@link Item#getMaxStackSize()}.
*
* @param stack The ItemStack
* @return The maximum number this item can be stacked to
* @return The maximum size this item can be stacked to
*/
@SuppressWarnings("deprecation")
default int getItemStackLimit(ItemStack stack)
default int getMaxStackSize(ItemStack stack)
{
return self().getMaxStackSize();
}
/**
* ItemStack sensitive version of getItemEnchantability
* ItemStack sensitive version of {@link Item#getEnchantmentValue()}.
*
* @param stack The ItemStack
* @return the item echantability value
* @return the enchantment value
*/
default int getItemEnchantability(ItemStack stack)
default int getEnchantmentValue(ItemStack stack)
{
return self().getEnchantmentValue();
}
@@ -49,24 +49,24 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundTag>
}
/**
* ItemStack sensitive version of getContainerItem. Returns a full ItemStack
* instance of the result.
* ItemStack sensitive version of {@link Item#getCraftingRemainingItem()}.
* Returns a full ItemStack instance of the result.
*
* @return The resulting ItemStack
*/
default ItemStack getContainerItem()
default ItemStack getCraftingRemainingItem()
{
return self().getItem().getContainerItem(self());
return self().getItem().getCraftingRemainingItem(self());
}
/**
* ItemStack sensitive version of hasContainerItem
* ItemStack sensitive version of {@link Item#hasCraftingRemainingItem()}.
*
* @return True if this item has a 'container'
* @return True if this item has a crafting remaining item
*/
default boolean hasContainerItem()
default boolean hasCraftingRemainingItem()
{
return self().getItem().hasContainerItem(self());
return self().getItem().hasCraftingRemainingItem(self());
}
/**
@@ -193,13 +193,13 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundTag>
}
/**
* ItemStack sensitive version of getItemEnchantability
* ItemStack sensitive version of {@link Item#getEnchantmentValue()}.
*
* @return the item echantability value
* @return the enchantment value of this ItemStack
*/
default int getItemEnchantability()
default int getEnchantmentValue()
{
return self().getItem().getItemEnchantability(self());
return self().getItem().getEnchantmentValue(self());
}
/**
@@ -24,11 +24,11 @@ import java.util.function.Function;
/**
* Implementation that defines what a global loot modifier must implement in order to be functional.
* {@link LootModifier} Supplies base functionality; most modders should only need to extend that.<br/>
* Requires a {@link Codec} to be registered: {@link ForgeRegistries#LOOT_MODIFIER_SERIALIZERS}, and returned in {@link #codec()}
* Requires a {@link Codec} to be registered: {@link ForgeRegistries#GLOBAL_LOOT_MODIFIER_SERIALIZERS}, and returned in {@link #codec()}
* Individual instances of modifiers must be registered via json, see forge:loot_modifiers/global_loot_modifiers
*/
public interface IGlobalLootModifier {
Codec<IGlobalLootModifier> DIRECT_CODEC = ExtraCodecs.lazyInitializedCodec(() -> ForgeRegistries.LOOT_MODIFIER_SERIALIZERS.get().getCodec())
Codec<IGlobalLootModifier> DIRECT_CODEC = ExtraCodecs.lazyInitializedCodec(() -> ForgeRegistries.GLOBAL_LOOT_MODIFIER_SERIALIZERS.get().getCodec())
.dispatch(IGlobalLootModifier::codec, Function.identity());
Codec<LootItemCondition[]> LOOT_CONDITIONS_CODEC = Codec.PASSTHROUGH.flatXmap(
@@ -41,7 +41,7 @@ public class LootModifierManager extends SimpleJsonResourceReloadListener {
private Map<ResourceLocation, IGlobalLootModifier> registeredLootModifiers = ImmutableMap.of();
private static final String folder = "loot_modifiers";
public LootModifierManager() {
super(GSON_INSTANCE, folder);
}
@@ -75,7 +75,7 @@ public class LootModifierManager extends SimpleJsonResourceReloadListener {
//use layered config to fetch modifier data files (modifiers missing from config are disabled)
for (ResourceLocation location : finalLocations)
{
Codec<? extends IGlobalLootModifier> codec = ForgeRegistries.LOOT_MODIFIER_SERIALIZERS.get().getValue(location);
Codec<? extends IGlobalLootModifier> codec = ForgeRegistries.GLOBAL_LOOT_MODIFIER_SERIALIZERS.get().getValue(location);
if (codec == null)
{
LOGGER.warn("Unknown or unregistered codec for GlobalLootModifier: {}", location);
@@ -9,20 +9,20 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.saveddata.SavedData;
import org.jetbrains.annotations.Nullable;
public class WorldCapabilityData extends SavedData
public class LevelCapabilityData extends SavedData
{
public static final String ID = "capabilities";
private INBTSerializable<CompoundTag> serializable;
private CompoundTag capNBT = null;
public WorldCapabilityData(@Nullable INBTSerializable<CompoundTag> serializable)
public LevelCapabilityData(@Nullable INBTSerializable<CompoundTag> serializable)
{
this.serializable = serializable;
}
public static WorldCapabilityData load(CompoundTag tag, @Nullable INBTSerializable<CompoundTag> serializable) {
WorldCapabilityData data = new WorldCapabilityData(serializable);
public static LevelCapabilityData load(CompoundTag tag, @Nullable INBTSerializable<CompoundTag> serializable) {
LevelCapabilityData data = new LevelCapabilityData(serializable);
data.read(tag);
return data;
}
@@ -206,7 +206,7 @@ public final class ForgeBiomeModifiers
for (MobCategory category : MobCategory.values())
{
List<SpawnerData> spawns = spawnBuilder.getSpawner(category);
spawns.removeIf(spawnerData -> this.entityTypes.contains(ForgeRegistries.ENTITIES.getHolder(spawnerData.type).get()));
spawns.removeIf(spawnerData -> this.entityTypes.contains(ForgeRegistries.ENTITY_TYPES.getHolder(spawnerData.type).get()));
}
}
}
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.forge.event.lifecycle;
package net.minecraftforge.data.event;
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
import net.minecraft.DetectedVersion;
@@ -5,12 +5,11 @@
package net.minecraftforge.data.loading;
import java.util.Collections;
import net.minecraft.server.Bootstrap;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.fml.ModLoader;
import net.minecraftforge.fml.ModWorkManager;
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
import net.minecraftforge.data.event.GatherDataEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -109,18 +109,18 @@ import net.minecraftforge.event.entity.player.PlayerWakeUpEvent;
import net.minecraftforge.event.entity.player.SleepingLocationCheckEvent;
import net.minecraftforge.event.entity.player.SleepingTimeCheckEvent;
import net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.BlockToolModificationEvent;
import net.minecraftforge.event.world.BlockEvent.CreateFluidSourceEvent;
import net.minecraftforge.event.world.BlockEvent.EntityMultiPlaceEvent;
import net.minecraftforge.event.world.BlockEvent.EntityPlaceEvent;
import net.minecraftforge.event.world.BlockEvent.NeighborNotifyEvent;
import net.minecraftforge.event.world.ChunkWatchEvent;
import net.minecraftforge.event.world.ExplosionEvent;
import net.minecraftforge.event.world.PistonEvent;
import net.minecraftforge.event.world.SaplingGrowTreeEvent;
import net.minecraftforge.event.world.SleepFinishedTimeEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.event.level.BlockEvent;
import net.minecraftforge.event.level.BlockEvent.BlockToolModificationEvent;
import net.minecraftforge.event.level.BlockEvent.CreateFluidSourceEvent;
import net.minecraftforge.event.level.BlockEvent.EntityMultiPlaceEvent;
import net.minecraftforge.event.level.BlockEvent.EntityPlaceEvent;
import net.minecraftforge.event.level.BlockEvent.NeighborNotifyEvent;
import net.minecraftforge.event.level.ChunkWatchEvent;
import net.minecraftforge.event.level.ExplosionEvent;
import net.minecraftforge.event.level.PistonEvent;
import net.minecraftforge.event.level.SaplingGrowTreeEvent;
import net.minecraftforge.event.level.SleepFinishedTimeEvent;
import net.minecraftforge.event.level.LevelEvent;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.Result;
import net.minecraftforge.fml.LogicalSide;
@@ -402,9 +402,9 @@ public class ForgeEventFactory
return event.getResultStatus();
}
public static void onPlayerWakeup(Player player, boolean wakeImmediately, boolean updateWorldFlag)
public static void onPlayerWakeup(Player player, boolean wakeImmediately, boolean updateLevel)
{
MinecraftForge.EVENT_BUS.post(new PlayerWakeUpEvent(player, wakeImmediately, updateWorldFlag));
MinecraftForge.EVENT_BUS.post(new PlayerWakeUpEvent(player, wakeImmediately, updateLevel));
}
public static void onPlayerFall(Player player, float distance, float multiplier)
@@ -445,7 +445,7 @@ public class ForgeEventFactory
public static boolean onCreateWorldSpawn(Level level, ServerLevelData settings)
{
return MinecraftForge.EVENT_BUS.post(new WorldEvent.CreateSpawnPosition(level, settings));
return MinecraftForge.EVENT_BUS.post(new LevelEvent.CreateSpawnPosition(level, settings));
}
public static float onLivingHeal(LivingEntity entity, float amount)
@@ -583,7 +583,7 @@ public class ForgeEventFactory
{
net.minecraftforge.event.enchanting.EnchantmentLevelSetEvent e = new net.minecraftforge.event.enchanting.EnchantmentLevelSetEvent(level, pos, enchantRow, power, itemStack, enchantmentLevel);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(e);
return e.getLevel();
return e.getEnchantLevel();
}
public static boolean onEntityDestroyBlock(LivingEntity entity, BlockPos pos, BlockState state)
@@ -600,9 +600,9 @@ public class ForgeEventFactory
return result == Result.DEFAULT ? level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) : result == Result.ALLOW;
}
public static boolean saplingGrowTree(LevelAccessor level, RandomSource rand, BlockPos pos)
public static boolean saplingGrowTree(LevelAccessor level, RandomSource randomSource, BlockPos pos)
{
SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(level, rand, pos);
SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(level, randomSource, pos);
MinecraftForge.EVENT_BUS.post(event);
return event.getResult() != Result.DENY;
}
@@ -772,14 +772,14 @@ public class ForgeEventFactory
MinecraftForge.EVENT_BUS.post(new TickEvent.PlayerTickEvent(TickEvent.Phase.END, player));
}
public static void onPreWorldTick(Level level, BooleanSupplier haveTime)
public static void onPreLevelTick(Level level, BooleanSupplier haveTime)
{
MinecraftForge.EVENT_BUS.post(new TickEvent.WorldTickEvent(LogicalSide.SERVER, TickEvent.Phase.START, level, haveTime));
MinecraftForge.EVENT_BUS.post(new TickEvent.LevelTickEvent(LogicalSide.SERVER, TickEvent.Phase.START, level, haveTime));
}
public static void onPostWorldTick(Level level, BooleanSupplier haveTime)
public static void onPostLevelTick(Level level, BooleanSupplier haveTime)
{
MinecraftForge.EVENT_BUS.post(new TickEvent.WorldTickEvent(LogicalSide.SERVER, TickEvent.Phase.END, level, haveTime));
MinecraftForge.EVENT_BUS.post(new TickEvent.LevelTickEvent(LogicalSide.SERVER, TickEvent.Phase.END, level, haveTime));
}
public static void onPreClientTick()
@@ -45,7 +45,7 @@ public class RegisterCommandsEvent extends Event
/**
* {@return the environment the command is being registered for}
*/
public Commands.CommandSelection getEnvironment()
public Commands.CommandSelection getCommandSelection()
{
return environment;
}
@@ -15,22 +15,13 @@ import net.minecraftforge.server.ServerLifecycleHooks;
*/
public class TagsUpdatedEvent extends Event
{
private final RegistryAccess registries;
private final RegistryAccess registryAccess;
private final UpdateCause updateCause;
private final boolean integratedServer;
@Deprecated(forRemoval = true, since = "1.18.2")
public TagsUpdatedEvent(RegistryAccess registries)
public TagsUpdatedEvent(RegistryAccess registryAccess, boolean fromClientPacket, boolean isIntegratedServerConnection)
{
this.registries = registries;
this.updateCause = ClientGamePacketListener.class.isAssignableFrom(StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass()) ? UpdateCause.CLIENT_PACKET_RECEIVED : UpdateCause.SERVER_DATA_LOAD;
var currentServer = ServerLifecycleHooks.getCurrentServer();
this.integratedServer = currentServer != null && !currentServer.isDedicatedServer();
}
public TagsUpdatedEvent(RegistryAccess registries, boolean fromClientPacket, boolean isIntegratedServerConnection)
{
this.registries = registries;
this.registryAccess = registryAccess;
this.updateCause = fromClientPacket ? UpdateCause.CLIENT_PACKET_RECEIVED : UpdateCause.SERVER_DATA_LOAD;
this.integratedServer = isIntegratedServerConnection;
}
@@ -38,9 +29,9 @@ public class TagsUpdatedEvent extends Event
/**
* @return The dynamic registries that have had their tags rebound.
*/
public RegistryAccess getTagManager()
public RegistryAccess getRegistryAccess()
{
return registries;
return registryAccess;
}
/**
@@ -18,7 +18,7 @@ import net.minecraftforge.fml.LogicalSide;
public class TickEvent extends Event
{
public enum Type {
WORLD, PLAYER, CLIENT, SERVER, RENDER;
LEVEL, PLAYER, CLIENT, SERVER, RENDER;
}
public enum Phase {
@@ -71,14 +71,14 @@ public class TickEvent extends Event
}
}
public static class WorldTickEvent extends TickEvent {
public final Level world;
public static class LevelTickEvent extends TickEvent {
public final Level level;
private final BooleanSupplier haveTime;
public WorldTickEvent(LogicalSide side, Phase phase, Level world, BooleanSupplier haveTime)
public LevelTickEvent(LogicalSide side, Phase phase, Level level, BooleanSupplier haveTime)
{
super(Type.WORLD, side, phase);
this.world = world;
super(Type.LEVEL, side, phase);
this.level = level;
this.haveTime = haveTime;
}
@@ -20,24 +20,24 @@ import org.jetbrains.annotations.NotNull;
*/
public class EnchantmentLevelSetEvent extends net.minecraftforge.eventbus.api.Event
{
private final Level world;
private final Level level;
private final BlockPos pos;
private final int enchantRow;
private final int power;
@NotNull
private final ItemStack itemStack;
private final int originalLevel;
private int level;
private int enchantLevel;
public EnchantmentLevelSetEvent(Level world, BlockPos pos, int enchantRow, int power, @NotNull ItemStack itemStack, int level)
public EnchantmentLevelSetEvent(Level level, BlockPos pos, int enchantRow, int power, @NotNull ItemStack itemStack, int enchantLevel)
{
this.world = world;
this.level = level;
this.pos = pos;
this.enchantRow = enchantRow;
this.power = power;
this.itemStack = itemStack;
this.originalLevel = level;
this.level = level;
this.originalLevel = enchantLevel;
this.enchantLevel = enchantLevel;
}
/**
@@ -45,9 +45,9 @@ public class EnchantmentLevelSetEvent extends net.minecraftforge.eventbus.api.Ev
*
* @return the world object
*/
public Level getWorld()
public Level getLevel()
{
return world;
return level;
}
/**
@@ -106,9 +106,9 @@ public class EnchantmentLevelSetEvent extends net.minecraftforge.eventbus.api.Ev
*
* @return the level of the enchantment for this row (0-30)
*/
public int getLevel()
public int getEnchantLevel()
{
return level;
return enchantLevel;
}
/**
@@ -116,8 +116,8 @@ public class EnchantmentLevelSetEvent extends net.minecraftforge.eventbus.api.Ev
*
* @param level the new level of the enchantment (0-30)
*/
public void setLevel(int level)
public void setEnchantLevel(int level)
{
this.level = level;
this.enchantLevel = level;
}
}
@@ -36,7 +36,7 @@ public class EntityAttributeModificationEvent extends Event implements IModBusEv
{
this.entityAttributes = mapIn;
this.entityTypes = ImmutableList.copyOf(
ForgeRegistries.ENTITIES.getValues().stream()
ForgeRegistries.ENTITY_TYPES.getValues().stream()
.filter(DefaultAttributes::hasSupplier)
.map(entityType -> (EntityType<? extends LivingEntity>) entityType)
.collect(Collectors.toList())
@@ -58,7 +58,7 @@ public class EntityEvent extends Event
* This event is fired on server and client after an Entity has entered a different section. <br>
* Sections are 16x16x16 block grids of the world.<br>
* This event does not fire when a new entity is spawned, only when an entity moves from one section to another one.
* Use {@link EntityJoinWorldEvent} to detect new entities joining the world.
* Use {@link EntityJoinLevelEvent} to detect new entities joining the world.
* <br>
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.<br>
* <br>
@@ -0,0 +1,64 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.fml.LogicalSide;
/**
* This event is fired whenever an {@link Entity} joins a {@link Level}.
* This event is fired whenever an entity is added to a level in {@link Level#addFreshEntity(Entity)}
* and {@code PersistentEntitySectionManager#addNewEntity(Entity, boolean)}.
* <p>
* <strong>Note:</strong> This event may be called before the underlying {@link LevelChunk} is promoted to {@link ChunkStatus#FULL}.
* You will cause chunk loading deadlocks if you do not delay your world interactions.
* <p>
* This event is {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}.
* If the event is canceled, the entity will not be added to the level.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}
* on both logical sides.
**/
@Cancelable
public class EntityJoinLevelEvent extends EntityEvent
{
private final Level level;
private final boolean loadedFromDisk;
public EntityJoinLevelEvent(Entity entity, Level level)
{
this(entity, level, false);
}
public EntityJoinLevelEvent(Entity entity, Level level, boolean loadedFromDisk)
{
super(entity);
this.level = level;
this.loadedFromDisk = loadedFromDisk;
}
/**
* {@return the level that the entity is set to join}
*/
public Level getLevel()
{
return level;
}
/**
* @return {@code true} if the entity was loaded from disk, {@code false} otherwise.
* On the {@linkplain LogicalSide#CLIENT logical client}, this will always return {@code false}.
*/
public boolean loadedFromDisk()
{
return loadedFromDisk;
}
}
@@ -1,65 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* EntityJoinWorldEvent is fired when an Entity joins the world. <br>
* This event is fired whenever an Entity is added to the world in
* {@code Level#loadEntities(Collection)},
* {@code net.minecraft.world.ServerWorld#loadEntities(Collection)}
* {@code World#joinEntityInSurroundings(Entity)}, and
* {@code World#spawnEntity(Entity)}. <br>
* <strong>Note:</strong> This event may be called before the underlying {@link LevelChunk} is promoted to {@link ChunkStatus#FULL}.
* You will cause chunk loading deadlocks if you don't delay your world interactions.<br>
* <br>
* {@link #world} contains the world in which the entity is to join.<br>
* <br>
* This event is {@link Cancelable}.<br>
* If this event is canceled, the Entity is not added to the world.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
@net.minecraftforge.eventbus.api.Cancelable
public class EntityJoinWorldEvent extends EntityEvent
{
private final Level world;
private final boolean loadedFromDisk;
public EntityJoinWorldEvent(Entity entity, Level world)
{
this(entity, world, false);
}
public EntityJoinWorldEvent(Entity entity, Level world, boolean loadedFromDisk)
{
super(entity);
this.world = world;
this.loadedFromDisk = loadedFromDisk;
}
public Level getWorld()
{
return world;
}
/**
* @return {@code true} if the entity was loaded from disk. On client entities, the info isn't available and this will always return {@code false}.
*/
public boolean loadedFromDisk()
{
return loadedFromDisk;
}
}
@@ -0,0 +1,40 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.entity.LevelCallback;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* This event is fired whenever an {@link Entity} leaves a {@link Level}.
* This event is fired whenever an entity is removed from the level in {@link LevelCallback#onTrackingEnd(Object)}.
* <p>
* This event is not {@linkplain Cancelable cancellable} and does not {@linkplain net.minecraftforge.eventbus.api.Event.HasResult have a result}.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}
* on both logical sides.
**/
public class EntityLeaveLevelEvent extends EntityEvent
{
private final Level level;
public EntityLeaveLevelEvent(Entity entity, Level level)
{
super(entity);
this.level = level;
}
/**
* {@return the level the entity is set to leave}
*/
public Level getLevel()
{
return level;
}
}
@@ -1,43 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* EntityLeaveWorldEvent is fired when an Entity leaves the world. <br>
* This event is fired whenever an Entity is removed from the world in
* {@link ClientLevel#removeEntity(int, Entity.RemovalReason)}. <br>
* <br>
* {@link #world} contains the world from which the entity is removed. <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}
*/
public class EntityLeaveWorldEvent extends EntityEvent
{
private final Level world;
public EntityLeaveWorldEvent(Entity entity, Level world)
{
super(entity);
this.world = world;
}
public Level getWorld()
{
return world;
}
}
@@ -30,16 +30,16 @@ public class EntityMountEvent extends EntityEvent
private final Entity entityMounting;
private final Entity entityBeingMounted;
private final Level worldObj;
private final Level level;
private final boolean isMounting;
public EntityMountEvent(Entity entityMounting, Entity entityBeingMounted, Level entityWorld, boolean isMounting)
public EntityMountEvent(Entity entityMounting, Entity entityBeingMounted, Level level, boolean isMounting)
{
super(entityMounting);
this.entityMounting = entityMounting;
this.entityBeingMounted = entityBeingMounted;
this.worldObj = entityWorld;
this.level = level;
this.isMounting = isMounting;
}
@@ -63,8 +63,8 @@ public class EntityMountEvent extends EntityEvent
return entityBeingMounted;
}
public Level getWorldObj()
public Level getLevel()
{
return worldObj;
return level;
}
}
@@ -9,31 +9,32 @@ import net.minecraft.world.entity.item.ItemEntity;
import net.minecraftforge.event.entity.EntityEvent;
/**
* Base class for all EntityItem events. Contains a reference to the
* EntityItem of interest. For most EntityItem events, there's little to no
* Base class for all {@link ItemEntity} events. Contains a reference to the
* ItemEntity of interest. For most ItemEntity events, there's little to no
* additional useful data from the firing method that isn't already contained
* within the EntityItem instance.
* within the ItemEntity instance.
*/
public class ItemEvent extends EntityEvent
{
private final ItemEntity entityItem;
private final ItemEntity itemEntity;
/**
* Creates a new event for an EntityItem.
*
* @param itemEntity The EntityItem for this event
* Creates a new event for an {@link ItemEntity}.
*
* @param itemEntity The ItemEntity for this event
*/
public ItemEvent(ItemEntity itemEntity)
{
super(itemEntity);
this.entityItem = itemEntity;
this.itemEntity = itemEntity;
}
/**
* The relevant EntityItem for this event, already cast for you.
* The relevant {@link ItemEntity} for this event.
*/
public ItemEntity getEntityItem()
@Override
public ItemEntity getEntity()
{
return entityItem;
return itemEntity;
}
}
@@ -15,7 +15,7 @@ import net.minecraftforge.eventbus.api.Event;
import org.jetbrains.annotations.Nullable;
/**
* LivingEvent is fired whenever an event involving Living entities occurs.<br>
* LivingEvent is fired whenever an event involving a {@link LivingEntity} occurs.<br>
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
@@ -23,24 +23,24 @@ import org.jetbrains.annotations.Nullable;
**/
public class LivingEvent extends EntityEvent
{
private final LivingEntity entityLiving;
private final LivingEntity livingEntity;
public LivingEvent(LivingEntity entity)
{
super(entity);
entityLiving = entity;
livingEntity = entity;
}
public LivingEntity getEntityLiving()
@Override
public LivingEntity getEntity()
{
return entityLiving;
return livingEntity;
}
/**
* LivingUpdateEvent is fired when an Entity is updated. <br>
* This event is fired whenever an Entity is updated in
* {@link LivingEntity#tick()}. <br>
* LivingUpdateEvent is fired when a LivingEntity is ticked in {@link LivingEntity#tick()}. <br>
* <br>
* This event is fired via the {@link ForgeHooks#onLivingUpdate(LivingEntity)}.<br>
* This event is fired via the {@link ForgeHooks#onLivingTick(LivingEntity)}.<br>
* <br>
* This event is {@link Cancelable}.<br>
* If this event is canceled, the Entity does not update.<br>
@@ -50,9 +50,9 @@ public class LivingEvent extends EntityEvent
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
@Cancelable
public static class LivingUpdateEvent extends LivingEvent
public static class LivingTickEvent extends LivingEvent
{
public LivingUpdateEvent(LivingEntity e){ super(e); }
public LivingTickEvent(LivingEntity e){ super(e); }
}
/**
@@ -6,56 +6,92 @@
package net.minecraftforge.event.entity.living;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.LevelAccessor;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.Nullable;
/**
* LivingSpawnEvent is fired for any events associated with Living Entities spawn status. <br>
* If a method utilizes this event as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* {@link #world} contains the world in which this living Entity is being spawned.<br>
* {@link #x} contains the x-coordinate this entity is being spawned at.<br>
* {@link #y} contains the y-coordinate this entity is being spawned at.<br>
* {@link #z} contains the z-coordinate this entity is being spawned at.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
**/
* This event is fired whenever a {@link Mob} should do something spawn-related.
* <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}
* only on the {@linkplain LogicalSide#SERVER logical server}.
*/
public class LivingSpawnEvent extends LivingEvent
{
private final LevelAccessor world;
private final LevelAccessor level;
private final Mob mob;
private final double x;
private final double y;
private final double z;
public LivingSpawnEvent(Mob entity, LevelAccessor world, double x, double y, double z)
public LivingSpawnEvent(Mob mob, LevelAccessor level, double x, double y, double z)
{
super(entity);
this.world = world;
super(mob);
this.mob = mob;
this.level = level;
this.x = x;
this.y = y;
this.z = z;
}
public LevelAccessor getWorld() { return world; }
public double getX() { return x; }
public double getY() { return y; }
public double getZ() { return z; }
/**
* Fires before mob spawn events.
*
* Result is significant:
* DEFAULT: use vanilla spawn rules
* ALLOW: allow the spawn
* DENY: deny the spawn
*
* {@return the mob that is causing a spawn action}
*/
@Override
public Mob getEntity()
{
return this.mob;
}
/**
* {@return the level relating to the mob spawn action}
*/
public LevelAccessor getLevel()
{
return this.level;
}
/**
* {@return the x-coordinate relating to the mob spawn action}
*/
public double getX()
{
return this.x;
}
/**
* {@return the y-coordinate relating to the mob spawn action}
*/
public double getY()
{
return this.y;
}
/**
* {@return the z-coordinate relating to the mob spawn action}
*/
public double getZ()
{
return this.z;
}
/**
* This event is fired before a {@link Mob} spawns.
* <p>
* This event is not {@linkplain Cancelable cancellable}, but does {@linkplain HasResult have a result}.
* {@linkplain Result#DEFAULT DEFAULT} indicates that default spawn rules should be used.
* {@linkplain Result#ALLOW ALLOW} indicates that the mob should spawn regardless of default spawn rules.
* {@linkplain Result#DENY DENY} indicates that the mob should not spawn.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#SERVER logical server}.
*/
@HasResult
public static class CheckSpawn extends LivingSpawnEvent
@@ -64,19 +100,9 @@ public class LivingSpawnEvent extends LivingEvent
private final BaseSpawner spawner;
private final MobSpawnType spawnReason;
/**
* CheckSpawn is fired when an Entity is about to be spawned.
* @param entity the spawning entity
* @param world the world to spawn in
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
* @param spawner position of the MobSpawner
* null if it this spawn is coming from a WorldSpawner
*/
public CheckSpawn(Mob entity, LevelAccessor world, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason)
public CheckSpawn(Mob mob, LevelAccessor level, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason)
{
super(entity, world, x, y, z);
super(mob, level, x, y, z);
this.spawner = spawner;
this.spawnReason = spawnReason;
}
@@ -99,18 +125,14 @@ public class LivingSpawnEvent extends LivingEvent
}
/**
* SpecialSpawn is fired when an Entity is to be spawned.<br>
* This allows you to do special inializers in the new entity.<br>
* <br>
* This event is fired via the {@link ForgeEventFactory#doSpecialSpawn(Mob, LevelAccessor, float, float, float, BaseSpawner, MobSpawnType)}.<br>
* <br>
* This event is {@link Cancelable}.<br>
* If this event is canceled, the Entity is not spawned.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
* This event is fired whenever a {@link Mob} is set to be spawned, to allow for mod-specific initializers.
* <p>
* This event is {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}.
* If the event is canceled, the mob will not spawn.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#SERVER logical server}.
*/
@Cancelable
public static class SpecialSpawn extends LivingSpawnEvent
{
@@ -118,9 +140,9 @@ public class LivingSpawnEvent extends LivingEvent
private final BaseSpawner spawner;
private final MobSpawnType spawnReason;
public SpecialSpawn(Mob entity, LevelAccessor world, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason)
public SpecialSpawn(Mob entity, LevelAccessor level, double x, double y, double z, @Nullable BaseSpawner spawner, MobSpawnType spawnReason)
{
super(entity, world, x, y, z);
super(entity, level, x, y, z);
this.spawner = spawner;
this.spawnReason = spawnReason;
}
@@ -138,25 +160,27 @@ public class LivingSpawnEvent extends LivingEvent
}
/**
* Fired each tick for despawnable mobs to allow control over despawning.
* {@link Result#DEFAULT} will pass the mob on to vanilla despawn mechanics.
* {@link Result#ALLOW} will force the mob to despawn.
* {@link Result#DENY} will force the mob to remain.
* This is fired every tick for every despawnable entity. Be efficient in your handlers.
*
* Note: this is not fired <em>if</em> the mob is definitely going to otherwise despawn. It is fired to check if
* the mob can be allowed to despawn. See {@link LivingEntity#checkDespawn()}
* This event is fired for a {@link Mob} that can despawn <i>each mob tick</i>.
* This event only fires if a mob can be allowed to despawn and will not
* otherwise fire if a despawn is certain.
* <p>
* This event is not {@linkplain Cancelable cancellable}, but does {@linkplain HasResult have a result}.
* {@link Result#DEFAULT} indicates that default despawn mechanics should be used.
* {@link Result#ALLOW} indicates that the mob should forcefully despawn.
* {@link Result#DENY} indicates that the mob should forcefully stay spawned.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#SERVER logical server}.
*
* @see LivingEntity#checkDespawn()
* @author cpw
*
*/
@HasResult
public static class AllowDespawn extends LivingSpawnEvent
{
public AllowDespawn(Mob entity)
public AllowDespawn(Mob mob)
{
super(entity, entity.level, entity.getX(), entity.getY(), entity.getZ());
super(mob, mob.level, mob.getX(), mob.getY(), mob.getZ());
}
}
}
@@ -0,0 +1,164 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity.living;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* This event is fired when an interaction between a {@link LivingEntity} and {@link MobEffectInstance} happens.
* <p>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
*/
public class MobEffectEvent extends LivingEvent
{
@Nullable
protected final MobEffectInstance effectInstance;
public MobEffectEvent(LivingEntity living, MobEffectInstance effectInstance)
{
super(living);
this.effectInstance = effectInstance;
}
@Nullable
public MobEffectInstance getEffectInstance()
{
return effectInstance;
}
/**
* This Event is fired when a {@link MobEffect} is about to get removed from an Entity.
* This Event is {@link Cancelable}. If canceled, the effect will not be removed.
* This Event does not have a result.
*/
@Cancelable
public static class Remove extends MobEffectEvent
{
private final MobEffect effect;
public Remove(LivingEntity living, MobEffect effect)
{
super(living, living.getEffect(effect));
this.effect = effect;
}
public Remove(LivingEntity living, MobEffectInstance effectInstance)
{
super(living, effectInstance);
this.effect = effectInstance.getEffect();
}
/**
* @return the {@link MobEffectEvent} which is being removed from the entity
*/
public MobEffect getEffect()
{
return this.effect;
}
/**
* @return the {@link MobEffectInstance}. In the remove event, this can be null if the entity does not have a {@link MobEffect} of the right type active.
*/
@Override
@Nullable
public MobEffectInstance getEffectInstance()
{
return super.getEffectInstance();
}
}
/**
* This event is fired to check if a {@link MobEffectInstance} can be applied to an entity.
* This event is not {@link Cancelable}.
* This event {@link HasResult has a result}.
* <p>
* {@link Result#ALLOW ALLOW} will apply this mob effect.
* {@link Result#DENY DENY} will not apply this mob effect.
* {@link Result#DEFAULT DEFAULT} will run vanilla logic to determine if this mob effect is applicable in {@link LivingEntity#canBeAffected}.
*/
@HasResult
public static class Applicable extends MobEffectEvent
{
public Applicable(LivingEntity living, @NotNull MobEffectInstance effectInstance)
{
super(living, effectInstance);
}
@Override
@NotNull
public MobEffectInstance getEffectInstance()
{
return super.getEffectInstance();
}
}
/**
* This event is fired when a new {@link MobEffectInstance} is added to an entity.
* This event is also fired if an entity already has the effect but with a different duration or amplifier.
* This event is not {@link Cancelable}.
* This event does not have a result.
*/
public static class Added extends MobEffectEvent
{
private final MobEffectInstance oldEffectInstance;
private final Entity source;
public Added(LivingEntity living, MobEffectInstance oldEffectInstance, MobEffectInstance newEffectInstance, Entity source)
{
super(living, newEffectInstance);
this.oldEffectInstance = oldEffectInstance;
this.source = source;
}
/**
* @return the added {@link MobEffectInstance}. This is the unmerged MobEffectInstance if the old MobEffectInstance is not null.
*/
@Override
@NotNull
public MobEffectInstance getEffectInstance()
{
return super.getEffectInstance();
}
/**
* @return the old {@link MobEffectInstance}. This can be null if the entity did not have an effect of this kind before.
*/
@Nullable
public MobEffectInstance getOldEffectInstance()
{
return oldEffectInstance;
}
/**
* @return the entity source of the effect, or {@code null} if none exists
*/
@Nullable
public Entity getEffectSource()
{
return source;
}
}
/**
* This event is fired when a {@link MobEffectInstance} expires on an entity.
* This event is not {@link Cancelable}.
* This event does not have a result.
*/
public static class Expired extends MobEffectEvent
{
public Expired(LivingEntity living, MobEffectInstance effectInstance)
{
super(living, effectInstance);
}
}
}
@@ -1,167 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.entity.living;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* This Event and its subevents gets fired from {@link LivingEntity} on the {@link MinecraftForge#EVENT_BUS}.<br>
*/
public class PotionEvent extends LivingEvent
{
@Nullable
protected final MobEffectInstance effect;
public PotionEvent(LivingEntity living, MobEffectInstance effect)
{
super(living);
this.effect = effect;
}
/**
* Retuns the PotionEffect.
*/
@Nullable
public MobEffectInstance getPotionEffect()
{
return effect;
}
/**
* This Event is fired when a Potion is about to get removed from an Entity.
* This Event is {@link Cancelable}.
* This Event does not have a result.
*/
@Cancelable
public static class PotionRemoveEvent extends PotionEvent
{
private final MobEffect potion;
public PotionRemoveEvent(LivingEntity living, MobEffect potion)
{
super(living, living.getEffect(potion));
this.potion = potion;
}
public PotionRemoveEvent(LivingEntity living, MobEffectInstance effect)
{
super(living, effect);
this.potion = effect.getEffect();
}
/**
* @return the Potion which is tried to remove from the Entity.
*/
public MobEffect getPotion()
{
return this.potion;
}
/**
* @return the PotionEffect. In the remove event this can be null if the Entity does not have a {@link MobEffect} of the right type active.
*/
@Override
@Nullable
public MobEffectInstance getPotionEffect()
{
return super.getPotionEffect();
}
}
/**
* This Event is fired to check if a Potion can get applied to an Entity.
* This Event is not {@link Cancelable}
* This Event has a result {@link HasResult}.
* ALLOW will apply this potion effect.
* DENY will not apply this potion effect.
* DEFAULT will run vanilla logic to determine if this potion isApplicable.
*/
@HasResult
public static class PotionApplicableEvent extends PotionEvent
{
public PotionApplicableEvent(LivingEntity living, MobEffectInstance effect)
{
super(living, effect);
}
/**
* @return the PotionEffect.
*/
@Override
@NotNull
public MobEffectInstance getPotionEffect()
{
return super.getPotionEffect();
}
}
/**
* This Event is fired when a new Potion is added to the Entity. This is also fired if the Entity already has this effect but with different duration/level.
* This Event is not {@link Cancelable}
* This Event does not have a Result.
*/
public static class PotionAddedEvent extends PotionEvent
{
private final MobEffectInstance oldEffect;
private final Entity source;
public PotionAddedEvent(LivingEntity living, MobEffectInstance oldEffect, MobEffectInstance newEffect, Entity source)
{
super(living, newEffect);
this.oldEffect = oldEffect;
this.source = source;
}
/**
* @return the added PotionEffect. This is the umerged PotionEffect if the old PotionEffect is not null.
*/
@Override
@NotNull
public MobEffectInstance getPotionEffect()
{
return super.getPotionEffect();
}
/**
* @return the old PotionEffect. THis can be null if the entity did not have an effect of this kind before.
*/
@Nullable
public MobEffectInstance getOldPotionEffect()
{
return oldEffect;
}
/**
* Returns the entity source of the effect, or {@code null} if none exists.
*
* @return the entity source of the effect, or {@code null}
*/
@Nullable
public Entity getPotionSource()
{
return source;
}
}
/**
* This Event is fired when a Potion effect expires on an Entity.
* This Event is not {@link Cancelable}
* This Event does not have a Result.
*/
public static class PotionExpiryEvent extends PotionEvent
{
public PotionExpiryEvent(LivingEntity living, MobEffectInstance effect)
{
super(living, effect);
}
}
}
@@ -11,64 +11,68 @@ import net.minecraft.world.level.Level;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* ZombieEvent is fired whenever a zombie is spawned for aid.
* If a method utilizes this event as its parameter, the method will
* receive every child event of this class.
*
*
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
**/
public class ZombieEvent extends EntityEvent {
private final Zombie zombie;
public ZombieEvent(Zombie entity)
public ZombieEvent(Zombie zombie)
{
super(entity);
super(zombie);
this.zombie = zombie;
}
public Zombie getSummoner()
@Override
public Zombie getEntity()
{
return (Zombie) getEntity();
return this.zombie;
}
/**
* SummonAidEvent is fired when a Zombie Entity is summoned.
* This event is fired whenever a Zombie Entity is summoned in
* This event is fired whenever a Zombie Entity is summoned in
* {@code Zombie#actuallyHurt(DamageSource, float)}.
*
*
* This event is fired via the {@link ForgeEventFactory#fireZombieSummonAid(Zombie, Level, int, int, int, LivingEntity, double)}.
*
* {@link #customSummonedAid} remains null, but can be populated with a custom EntityZombie which will be spawned.
* {@link #world} contains the world that this summoning is occurring in.
* {@link #x} contains the x-coordinate at which this summoning event is occurring.
* {@link #y} contains the y-coordinate at which this summoning event is occurring.
* {@link #z} contains the z-coordinate at which this summoning event is occurring.
* {@link #attacker} contains the living Entity that attacked and caused this event to fire.
* {@link #summonChance} contains the likelihood that a Zombie would successfully be summoned.
*
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
*
*
* {@link #getCustomSummonedAid()} remains null, but can be populated with a custom EntityZombie which will be spawned.
* {@link #getLevel()} contains the world that this summoning is occurring in.
* {@link #getX()} contains the x-coordinate at which this summoning event is occurring.
* {@link #getY()} contains the y-coordinate at which this summoning event is occurring.
* {@link #getZ()} contains the z-coordinate at which this summoning event is occurring.
* {@link #getAttacker()} contains the living Entity that attacked and caused this event to fire.
* {@link #getSummonChance()} contains the likelihood that a Zombie would successfully be summoned.
*
* This event is not {@link Cancelable}.
*
* This event has a result. {@link HasResult}
* {@link Result#ALLOW} Zombie is summoned.
* {@link Result#DENY} Zombie is not summoned.
*
*
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
@HasResult
public static class SummonAidEvent extends ZombieEvent {
private Zombie customSummonedAid;
private final Level world;
private final Level level;
private final int x;
private final int y;
private final int z;
private final LivingEntity attacker;
private final double summonChance;
public SummonAidEvent(Zombie entity, Level world, int x, int y, int z, LivingEntity attacker, double summonChance)
public SummonAidEvent(Zombie zombie, Level level, int x, int y, int z, LivingEntity attacker, double summonChance)
{
super(entity);
this.world = world;
super(zombie);
this.level = level;
this.x = x;
this.y = y;
this.z = z;
@@ -81,7 +85,7 @@ public class ZombieEvent extends EntityEvent {
*/
public Zombie getCustomSummonedAid() { return customSummonedAid; }
public void setCustomSummonedAid(Zombie customSummonedAid) { this.customSummonedAid = customSummonedAid; }
public Level getWorld() { return world; }
public Level getLevel() { return level; }
public int getX() { return x; }
public int getY() { return y; }
public int getZ() { return z; }
@@ -40,21 +40,21 @@ public class AnvilRepairEvent extends PlayerEvent
* @return the output
*/
@NotNull
public ItemStack getItemResult() { return output; }
public ItemStack getOutput() { return output; }
/**
* Get the first item input into the anvil
* @return the first input slot
*/
@NotNull
public ItemStack getItemInput() { return left; }
public ItemStack getLeft() { return left; }
/**
* Get the second item input into the anvil
* @return the second input slot
*/
@NotNull
public ItemStack getIngredientInput() { return right; }
public ItemStack getRight() { return right; }
public float getBreakChance() { return breakChance; }
public void setBreakChance(float breakChance) { this.breakChance = breakChance; }
@@ -33,22 +33,22 @@ import org.jetbrains.annotations.NotNull;
public class ArrowLooseEvent extends PlayerEvent
{
private final ItemStack bow;
private final Level world;
private final Level level;
private final boolean hasAmmo;
private int charge;
public ArrowLooseEvent(Player player, @NotNull ItemStack bow, Level world, int charge, boolean hasAmmo)
public ArrowLooseEvent(Player player, @NotNull ItemStack bow, Level level, int charge, boolean hasAmmo)
{
super(player);
this.bow = bow;
this.world = world;
this.level = level;
this.charge = charge;
this.hasAmmo = hasAmmo;
}
@NotNull
public ItemStack getBow() { return this.bow; }
public Level getWorld() { return this.world; }
public Level getLevel() { return this.level; }
public boolean hasAmmo() { return this.hasAmmo; }
public int getCharge() { return this.charge; }
public void setCharge(int charge) { this.charge = charge; }
@@ -25,22 +25,22 @@ public class ArrowNockEvent extends PlayerEvent
{
private final ItemStack bow;
private final InteractionHand hand;
private final Level world;
private final Level level;
private final boolean hasAmmo;
private InteractionResultHolder<ItemStack> action;
public ArrowNockEvent(Player player, @NotNull ItemStack item, InteractionHand hand, Level world, boolean hasAmmo)
public ArrowNockEvent(Player player, @NotNull ItemStack item, InteractionHand hand, Level level, boolean hasAmmo)
{
super(player);
this.bow = item;
this.hand = hand;
this.world = world;
this.level = level;
this.hasAmmo = hasAmmo;
}
@NotNull
public ItemStack getBow() { return this.bow; }
public Level getWorld() { return this.world; }
public Level getLevel() { return this.level; }
public InteractionHand getHand() { return this.hand; }
public boolean hasAmmo() { return this.hasAmmo; }
public InteractionResultHolder<ItemStack> getAction()
@@ -27,23 +27,23 @@ import org.jetbrains.annotations.NotNull;
public class BonemealEvent extends PlayerEvent
{
private final Level world;
private final Level level;
private final BlockPos pos;
private final BlockState block;
private final ItemStack stack;
public BonemealEvent(@NotNull Player player, @NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState block, @NotNull ItemStack stack)
public BonemealEvent(@NotNull Player player, @NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState block, @NotNull ItemStack stack)
{
super(player);
this.world = world;
this.level = level;
this.pos = pos;
this.block = block;
this.stack = stack;
}
public Level getWorld()
public Level getLevel()
{
return world;
return level;
}
public BlockPos getPos()
@@ -29,23 +29,23 @@ public class FillBucketEvent extends PlayerEvent
{
private final ItemStack current;
private final Level world;
private final Level level;
@Nullable
private final HitResult target;
private ItemStack result;
public FillBucketEvent(Player player, @NotNull ItemStack current, Level world, @Nullable HitResult target)
public FillBucketEvent(Player player, @NotNull ItemStack current, Level level, @Nullable HitResult target)
{
super(player);
this.current = current;
this.world = world;
this.level = level;
this.target = target;
}
@NotNull
public ItemStack getEmptyBucket() { return this.current; }
public Level getWorld(){ return this.world; }
public Level getLevel(){ return this.level; }
@Nullable
public HitResult getTarget() { return this.target; }
@NotNull
@@ -23,12 +23,12 @@ public class ItemTooltipEvent extends PlayerEvent
private final List<Component> toolTip;
/**
* This event is fired in {@link ItemStack#getTooltipLines(Player, TooltipFlag)}, which in turn is called from it's respective GUIContainer.
* Tooltips are also gathered with a null entityPlayer during startup by {@link Minecraft#createSearchTrees()}.
* This event is fired in {@link ItemStack#getTooltipLines(Player, TooltipFlag)}, which in turn is called from its respective GUIContainer.
* Tooltips are also gathered with a null player during startup by {@link Minecraft#createSearchTrees()}.
*/
public ItemTooltipEvent(@NotNull ItemStack itemStack, @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags)
public ItemTooltipEvent(@NotNull ItemStack itemStack, @Nullable Player player, List<Component> list, TooltipFlag flags)
{
super(entityPlayer);
super(player);
this.itemStack = itemStack;
this.toolTip = list;
this.flags = flags;
@@ -64,8 +64,8 @@ public class ItemTooltipEvent extends PlayerEvent
*/
@Override
@Nullable
public Player getPlayer()
public Player getEntity()
{
return super.getPlayer();
return super.getEntity();
}
}
@@ -5,7 +5,6 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
@@ -33,7 +32,7 @@ import org.jetbrains.annotations.Nullable;
* {@link Player#attack(Entity)},
* {@code Player#hurtCurrentlyUsedShield(float)},
* {@link Player#interactOn(Entity, InteractionHand)},
* {@link ForgeHooks#getContainerItem(ItemStack)},
* {@link ForgeHooks#getCraftingRemainingItem(ItemStack)},
* {@link ServerPlayerGameMode#useItem(ServerPlayer, Level, ItemStack, InteractionHand)} ,
* {@link ServerPlayerGameMode#useItemOn(ServerPlayer, Level, ItemStack, InteractionHand, BlockHitResult)}
* and {@link ServerPlayerGameMode#destroyBlock(BlockPos)}.<br>
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* PlayerEvent is fired whenever an event involving Living entities occurs. <br>
* PlayerEvent is fired whenever an event involving a {@link Player} occurs. <br>
* If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
@@ -35,17 +35,20 @@ import org.jetbrains.annotations.Nullable;
**/
public class PlayerEvent extends LivingEvent
{
private final Player entityPlayer;
private final Player player;
public PlayerEvent(Player player)
{
super(player);
entityPlayer = player;
this.player = player;
}
@Override
public Player getEntity()
{
return player;
}
/**
* @return Player
*/
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
@@ -322,7 +322,7 @@ public class PlayerInteractEvent extends PlayerEvent
@NotNull
public ItemStack getItemStack()
{
return getPlayer().getItemInHand(hand);
return getEntity().getItemInHand(hand);
}
/**
@@ -348,11 +348,11 @@ public class PlayerInteractEvent extends PlayerEvent
}
/**
* @return Convenience method to get the world of this interaction.
* @return Convenience method to get the level of this interaction.
*/
public Level getWorld()
public Level getLevel()
{
return getPlayer().getCommandSenderWorld();
return getEntity().level;
}
/**
@@ -360,7 +360,7 @@ public class PlayerInteractEvent extends PlayerEvent
*/
public LogicalSide getSide()
{
return getWorld().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER;
return getLevel().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER;
}
/**
@@ -19,15 +19,15 @@ import org.jetbrains.annotations.Nullable;
@Cancelable
public class PlayerSetSpawnEvent extends PlayerEvent
{
private final ResourceKey<Level> spawnWorld;
private final ResourceKey<Level> spawnLevel;
private final boolean forced;
@Nullable
private final BlockPos newSpawn;
public PlayerSetSpawnEvent(Player player, ResourceKey<Level> spawnWorld, @Nullable BlockPos newSpawn, boolean forced)
public PlayerSetSpawnEvent(Player player, ResourceKey<Level> spawnLevel, @Nullable BlockPos newSpawn, boolean forced)
{
super(player);
this.spawnWorld = spawnWorld;
this.spawnLevel = spawnLevel;
this.newSpawn = newSpawn;
this.forced = forced;
}
@@ -46,8 +46,8 @@ public class PlayerSetSpawnEvent extends PlayerEvent
return newSpawn;
}
public ResourceKey<Level> getSpawnWorld()
public ResourceKey<Level> getSpawnLevel()
{
return spawnWorld;
return spawnLevel;
}
}
@@ -16,13 +16,13 @@ public class PlayerWakeUpEvent extends PlayerEvent
{
private final boolean wakeImmediately;
private final boolean updateWorld;
private final boolean updateLevel;
public PlayerWakeUpEvent(Player player, boolean wakeImmediately, boolean updateWorld)
public PlayerWakeUpEvent(Player player, boolean wakeImmediately, boolean updateLevel)
{
super(player);
this.wakeImmediately = wakeImmediately;
this.updateWorld = updateWorld;
this.updateLevel = updateLevel;
}
/**
@@ -35,5 +35,5 @@ public class PlayerWakeUpEvent extends PlayerEvent
* Indicates if the server should be notified of sleeping changes.
* This will only be false if the server is considered 'up to date' already, because, for example, it initiated the call.
*/
public boolean updateWorld() { return updateWorld; }
public boolean updateLevel() { return updateLevel; }
}
@@ -3,12 +3,13 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.world;
package net.minecraftforge.event.level;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.world.level.portal.PortalShape;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
@@ -36,19 +37,19 @@ public class BlockEvent extends Event
{
private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockEvent", "false"));
private final LevelAccessor world;
private final LevelAccessor level;
private final BlockPos pos;
private final BlockState state;
public BlockEvent(LevelAccessor world, BlockPos pos, BlockState state)
public BlockEvent(LevelAccessor level, BlockPos pos, BlockState state)
{
this.pos = pos;
this.world = world;
this.level = level;
this.state = state;
}
public LevelAccessor getWorld()
public LevelAccessor getLevel()
{
return world;
return level;
}
public BlockPos getPos()
@@ -72,9 +73,9 @@ public class BlockEvent extends Event
private final Player player;
private int exp;
public BreakEvent(Level world, BlockPos pos, BlockState state, Player player)
public BreakEvent(Level level, BlockPos pos, BlockState state, Player player)
{
super(world, pos, state);
super(level, pos, state);
this.player = player;
if (state == null || !ForgeHooks.isCorrectToolForDrops(state, player)) // Handle empty block or player unable to break block scenario
@@ -85,7 +86,7 @@ public class BlockEvent extends Event
{
int fortuneLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, player.getMainHandItem());
int silkTouchLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, player.getMainHandItem());
this.exp = state.getExpDrop(world, world.random, pos, fortuneLevel, silkTouchLevel);
this.exp = state.getExpDrop(level, level.random, pos, fortuneLevel, silkTouchLevel);
}
}
@@ -193,9 +194,9 @@ public class BlockEvent extends Event
private final EnumSet<Direction> notifiedSides;
private final boolean forceRedstoneUpdate;
public NeighborNotifyEvent(Level world, BlockPos pos, BlockState state, EnumSet<Direction> notifiedSides, boolean forceRedstoneUpdate)
public NeighborNotifyEvent(Level level, BlockPos pos, BlockState state, EnumSet<Direction> notifiedSides, boolean forceRedstoneUpdate)
{
super(world, pos, state);
super(level, pos, state);
this.notifiedSides = notifiedSides;
this.forceRedstoneUpdate = forceRedstoneUpdate;
}
@@ -229,20 +230,20 @@ public class BlockEvent extends Event
@HasResult
public static class CreateFluidSourceEvent extends Event
{
private final LevelReader world;
private final LevelReader level;
private final BlockPos pos;
private final BlockState state;
public CreateFluidSourceEvent(LevelReader world, BlockPos pos, BlockState state)
public CreateFluidSourceEvent(LevelReader level, BlockPos pos, BlockState state)
{
this.world = world;
this.level = level;
this.pos = pos;
this.state = state;
}
public LevelReader getWorld()
public LevelReader getLevel()
{
return world;
return level;
}
public BlockPos getPos()
@@ -271,12 +272,12 @@ public class BlockEvent extends Event
private BlockState newState;
private BlockState origState;
public FluidPlaceBlockEvent(LevelAccessor world, BlockPos pos, BlockPos liquidPos, BlockState state)
public FluidPlaceBlockEvent(LevelAccessor level, BlockPos pos, BlockPos liquidPos, BlockState state)
{
super(world, pos, state);
super(level, pos, state);
this.liquidPos = liquidPos;
this.newState = state;
this.origState = world.getBlockState(pos);
this.origState = level.getBlockState(pos);
}
/**
@@ -315,9 +316,9 @@ public class BlockEvent extends Event
*/
public static class CropGrowEvent extends BlockEvent
{
public CropGrowEvent(Level world, BlockPos pos, BlockState state)
public CropGrowEvent(Level level, BlockPos pos, BlockState state)
{
super(world, pos, state);
super(level, pos, state);
}
/**
@@ -334,9 +335,9 @@ public class BlockEvent extends Event
@HasResult
public static class Pre extends CropGrowEvent
{
public Pre(Level world, BlockPos pos, BlockState state)
public Pre(Level level, BlockPos pos, BlockState state)
{
super(world, pos, state);
super(level, pos, state);
}
}
@@ -352,9 +353,9 @@ public class BlockEvent extends Event
public static class Post extends CropGrowEvent
{
private final BlockState originalState;
public Post(Level world, BlockPos pos, BlockState original, BlockState state)
public Post(Level level, BlockPos pos, BlockState original, BlockState state)
{
super(world, pos, state);
super(level, pos, state);
originalState = original;
}
@@ -376,9 +377,9 @@ public class BlockEvent extends Event
private final Entity entity;
private final float fallDistance;
public FarmlandTrampleEvent(Level world, BlockPos pos, BlockState state, float fallDistance, Entity entity)
public FarmlandTrampleEvent(Level level, BlockPos pos, BlockState state, float fallDistance, Entity entity)
{
super(world, pos, state);
super(level, pos, state);
this.entity = entity;
this.fallDistance = fallDistance;
}
@@ -393,8 +394,8 @@ public class BlockEvent extends Event
}
/* Fired when an attempt is made to spawn a nether portal from
* {@link net.minecraft.block.BlockPortal#trySpawnPortal(World, BlockPos)}.
/** Fired when an attempt is made to spawn a nether portal from
* {@link BaseFireBlock#onPlace(BlockState, Level, BlockPos, BlockState, boolean)}.
*
* If cancelled, the portal will not be spawned.
*/
@@ -403,9 +404,9 @@ public class BlockEvent extends Event
{
private final PortalShape size;
public PortalSpawnEvent(LevelAccessor world, BlockPos pos, BlockState state, PortalShape size)
public PortalSpawnEvent(LevelAccessor level, BlockPos pos, BlockState state, PortalShape size)
{
super(world, pos, state);
super(level, pos, state);
this.size = size;
}
@@ -420,7 +421,7 @@ public class BlockEvent extends Event
* For example: Used to determine if {@link ToolActions#AXE_STRIP an axe can strip},
* {@link ToolActions#SHOVEL_FLATTEN a shovel can path}, or {@link ToolActions#HOE_TILL a hoe can till}.
* <p>
* Care must be taken to ensure world-modifying events are only performed if {@link #isSimulated()} returns {@code false}.
* Care must be taken to ensure level-modifying events are only performed if {@link #isSimulated()} returns {@code false}.
* <p>
* This event is {@link Cancelable}. If canceled, this will prevent the tool
* from changing the block's state.
@@ -469,11 +470,11 @@ public class BlockEvent extends Event
}
/**
* Returns {@code true} if this event should not perform any actions that modify the world.
* If {@code false}, then world-modifying actions can be performed.
* Returns {@code true} if this event should not perform any actions that modify the level.
* If {@code false}, then level-modifying actions can be performed.
*
* @return {@code true} if this event should not perform any actions that modify the world.
* If {@code false}, then world-modifying actions can be performed.
* @return {@code true} if this event should not perform any actions that modify the level.
* If {@code false}, then level-modifying actions can be performed.
*/
public boolean isSimulated()
{
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.world;
package net.minecraftforge.event.level;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
@@ -79,7 +79,7 @@ public class ChunkDataEvent extends ChunkEvent
* This event is fired during chunk saving in
* {@code ChunkMap#save(ChunkAccess)}. <br>
* <br>
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.<br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
@@ -3,11 +3,8 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.world;
package net.minecraftforge.event.level;
import net.minecraft.client.multiplayer.ClientChunkCache;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
@@ -16,8 +13,6 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import java.util.BitSet;
/**
* ChunkEvent is fired when an event involving a chunk occurs.<br>
* If a method utilizes this {@link Event} as its parameter, the method will
@@ -27,7 +22,7 @@ import java.util.BitSet;
* <br>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public class ChunkEvent extends WorldEvent
public class ChunkEvent extends LevelEvent
{
private final ChunkAccess chunk;
@@ -37,9 +32,9 @@ public class ChunkEvent extends WorldEvent
this.chunk = chunk;
}
public ChunkEvent(ChunkAccess chunk, LevelAccessor world)
public ChunkEvent(ChunkAccess chunk, LevelAccessor level)
{
super(world);
super(level);
this.chunk = chunk;
}
@@ -49,11 +44,11 @@ public class ChunkEvent extends WorldEvent
}
/**
* ChunkEvent.Load is fired when vanilla Minecraft attempts to load a Chunk into the world.<br>
* ChunkEvent.Load is fired when vanilla Minecraft attempts to load a Chunk into the level.<br>
* This event is fired during chunk loading in <br>
*
*
* Chunk.onChunkLoad(). <br>
* <strong>Note:</strong> This event may be called before the underlying {@link LevelChunk} is promoted to {@link ChunkStatus#FULL}. You will cause chunk loading deadlocks if you don't delay your world interactions.<br>
* <strong>Note:</strong> This event may be called before the underlying {@link LevelChunk} is promoted to {@link ChunkStatus#FULL}. You will cause chunk loading deadlocks if you don't delay your level interactions.<br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
@@ -70,7 +65,7 @@ public class ChunkEvent extends WorldEvent
}
/**
* ChunkEvent.Unload is fired when vanilla Minecraft attempts to unload a Chunk from the world.<br>
* ChunkEvent.Unload is fired when vanilla Minecraft attempts to unload a Chunk from the level.<br>
* This event is fired during chunk unloading in <br>
* Chunk.onChunkUnload(). <br>
* <br>
@@ -3,61 +3,67 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.world;
package net.minecraftforge.event.level;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import org.apache.commons.lang3.mutable.MutableObject;
import net.minecraftforge.fml.LogicalSide;
/**
* ChunkWatchEvent is fired when an event involving a chunk being watched occurs.
* This event is fired whenever a chunk has a watch-related action.
* <p>
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.
* <p>
* {@link #pos} contains the ChunkPos of the Chunk this event is affecting.<br>
* {@link #world} contains the World of the Chunk this event is affecting.<br>
* {@link #player} contains the {@link ServerPlayer} that is involved with this chunk being watched.
* <p>
* The {@link #player}'s world may not be the same as the world of the chunk
* The {@linkplain #getPlayer() player}'s level may not be the same as the {@linkplain #getLevel() level of the chunk}
* when the player is teleporting to another dimension.
* <p>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
* 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}
* only on the {@linkplain LogicalSide#SERVER logical server}.
**/
public class ChunkWatchEvent extends Event
{
private final ServerLevel world;
private final ServerLevel level;
private final ServerPlayer player;
private final ChunkPos pos;
public ChunkWatchEvent(ServerPlayer player, ChunkPos pos, ServerLevel world)
public ChunkWatchEvent(ServerPlayer player, ChunkPos pos, ServerLevel level)
{
this.player = player;
this.pos = pos;
this.world = world;
this.level = level;
}
/**
* {@return the server player involved with the watch action}
*/
public ServerPlayer getPlayer()
{
return this.player;
}
/**
* {@return the chunk position this watch event is affecting}
*/
public ChunkPos getPos()
{
return this.pos;
}
public ServerLevel getWorld()
/**
* {@return the server level containing the chunk}
*/
public ServerLevel getLevel()
{
return this.world;
return this.level;
}
/**
* ChunkWatchEvent.Watch is fired when a {@link ServerPlayer} begins watching a chunk.
* This event is fired whenever a {@link ServerPlayer} begins watching a chunk.
* <p>
* This event is fired when a chunk is added to the watched chunks of a {@link ServerPlayer}
* and the chunk's data is sent to the client (see
@@ -65,16 +71,18 @@ public class ChunkWatchEvent extends Event
* <p>
* This event may be used to send additional chunk-related data to the client.
* <p>
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable} and
* {@link HasResult does not have a result}.
* 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}
* only on the {@linkplain LogicalSide#SERVER logical server}.
**/
public static class Watch extends ChunkWatchEvent
{
private final LevelChunk chunk;
public Watch(ServerPlayer player, LevelChunk chunk, ServerLevel world)
public Watch(ServerPlayer player, LevelChunk chunk, ServerLevel level)
{
super(player, chunk.getPos(), world);
super(player, chunk.getPos(), level);
this.chunk = chunk;
}
@@ -85,16 +93,18 @@ public class ChunkWatchEvent extends Event
}
/**
* ChunkWatchEvent.UnWatch is fired when a {@link ServerPlayer} stops watching a chunk.
* This event is fired whenever a {@link ServerPlayer} stops watching a chunk.
* <p>
* This event is fired when a chunk is removed from the watched chunks of an {@link ServerPlayer}
* in {@code net.minecraft.server.level.ChunkMap#updateChunkTracking(ServerPlayer, ChunkPos, Packet[], boolean, boolean)}.
* <p>
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable} and
* {@link HasResult does not have a result}.
* 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}
* only on the {@linkplain LogicalSide#SERVER logical server}.
**/
public static class UnWatch extends ChunkWatchEvent
{
public UnWatch(ServerPlayer player, ChunkPos pos, ServerLevel world) {super(player, pos, world);}
public UnWatch(ServerPlayer player, ChunkPos pos, ServerLevel level) {super(player, pos, level);}
}
}
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.world;
package net.minecraftforge.event.level;
import java.util.List;
@@ -15,7 +15,7 @@ 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>
/** ExplosionEvent triggers when an explosion happens in the level.<br>
* <br>
* ExplosionEvent.Start is fired before the explosion actually occurs.<br>
* ExplosionEvent.Detonate is fired once the explosion has a list of affected blocks and entities.<br>
@@ -27,18 +27,18 @@ import net.minecraft.world.level.Level;
*/
public class ExplosionEvent extends Event
{
private final Level world;
private final Level level;
private final Explosion explosion;
public ExplosionEvent(Level world, Explosion explosion)
public ExplosionEvent(Level level, Explosion explosion)
{
this.world = world;
this.level = level;
this.explosion = explosion;
}
public Level getWorld()
public Level getLevel()
{
return world;
return level;
}
public Explosion getExplosion()
@@ -48,16 +48,16 @@ public class ExplosionEvent extends Event
/** ExplosionEvent.Start is fired before the explosion actually occurs. Canceling this event will stop the explosion.<br>
* <br>
* This event is {@link net.minecraftforge.eventbus.api.Cancelable}.<br>
* This event is {@link Cancelable}.<br>
* This event does not use {@link HasResult}.<br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
*/
@Cancelable
public static class Start extends ExplosionEvent
{
public Start(Level world, Explosion explosion)
public Start(Level level, Explosion explosion)
{
super(world, explosion);
super(level, explosion);
}
}
@@ -71,9 +71,9 @@ public class ExplosionEvent extends Event
{
private final List<Entity> entityList;
public Detonate(Level world, Explosion explosion, List<Entity> entityList)
public Detonate(Level level, Explosion explosion, List<Entity> entityList)
{
super(world, explosion);
super(level, explosion);
this.entityList = entityList;
}
@@ -0,0 +1,120 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.level;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.ProgressListener;
import net.minecraft.world.level.LevelAccessor;
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;
/**
* 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
{
private final LevelAccessor level;
public LevelEvent(LevelAccessor level)
{
this.level = level;
}
/**
* {@return the level this event is affecting}
*/
public LevelAccessor getLevel()
{
return level;
}
/**
* This event is fired whenever a level loads.
* This event is fired whenever a level loads in ClientLevel's constructor and
* {@literal MinecraftServer#createLevels(ChunkProgressListener)}.
* <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 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 MinecraftServer#stopServer()},
* {@link Minecraft#clearLevel(Screen)}, and
* {@link ForgeInternalHandler#onDimensionUnload(Unload)}.
* <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 Unload(LevelAccessor level) { super(level); }
}
/**
* This event fires whenever a level is saved.
* This event is fired when a level is saved in
* {@link ServerLevel#save(ProgressListener, boolean, boolean)}.
* <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}
* only on the {@linkplain LogicalSide#SERVER logical server}.
**/
public static class Save extends LevelEvent
{
public Save(LevelAccessor level) { super(level); }
}
/**
* This event fires whenever a {@link ServerLevel} is initialized for the first time
* and a spawn position needs to be chosen.
* <p>
* This event is {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}.
* If the event is canceled, the vanilla logic to choose a spawn position will be skipped.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}
* only on the {@linkplain LogicalSide#SERVER logical server}.
*
* @see ServerLevelData#isInitialized()
*/
@Cancelable
public static class CreateSpawnPosition extends LevelEvent
{
private final ServerLevelData settings;
public CreateSpawnPosition(LevelAccessor level, ServerLevelData settings)
{
super(level);
this.settings = settings;
}
public ServerLevelData getSettings()
{
return settings;
}
}
}
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.world;
package net.minecraftforge.event.level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.world;
package net.minecraftforge.event.level;
import net.minecraft.world.level.block.piston.PistonStructureResolver;
import net.minecraft.core.Direction;
@@ -62,8 +62,8 @@ public abstract class PistonEvent extends BlockEvent
@Nullable
public PistonStructureResolver getStructureHelper()
{
if(this.getWorld() instanceof Level) {
return new PistonStructureResolver((Level) this.getWorld(), this.getPos(), this.getDirection(), this.getPistonMoveType().isExtend);
if(this.getLevel() instanceof Level) {
return new PistonStructureResolver((Level) this.getLevel(), this.getPos(), this.getDirection(), this.getPistonMoveType().isExtend);
} else {
return null;
}
@@ -0,0 +1,58 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.level;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
* This event is fired whenever a sapling grows into a tree.
* This event is fired during sapling growth in
* {@link SaplingBlock#advanceTree(ServerLevel, BlockPos, BlockState, RandomSource)}.
* <p>
* This event is not {@linkplain Cancelable cancellable} but does {@linkplain HasResult have a result}.
* {@linkplain Result#ALLOW ALLOW} and {@linkplain Result#DEFAULT DEFAULT} will allow the sapling to grow.
* {@linkplain Result#DENY DENY} will prevent the sapling from growing.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}
* only on the {@linkplain net.minecraftforge.fml.LogicalSide#SERVER logical server}.
*/
@HasResult
public class SaplingGrowTreeEvent extends LevelEvent
{
private final BlockPos pos;
private final RandomSource randomSource;
public SaplingGrowTreeEvent(LevelAccessor level, RandomSource randomSource, BlockPos pos)
{
super(level);
this.randomSource = randomSource;
this.pos = pos;
}
/**
* {@return the coordinates of the sapling attempting to grow}
*/
public BlockPos getPos()
{
return pos;
}
/**
* {@return the random source which initiated the sapling growth}
*/
public RandomSource getRandomSource()
{
return this.randomSource;
}
}
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.world;
package net.minecraftforge.event.level;
import net.minecraft.server.level.ServerLevel;
@@ -12,16 +12,16 @@ import net.minecraft.server.level.ServerLevel;
*
* setWakeUpTime(wakeUpTime) sets a new time that will be added to the dayTime.<br>
*/
public class SleepFinishedTimeEvent extends WorldEvent
public class SleepFinishedTimeEvent extends LevelEvent
{
private long newTime;
private final long minTime;
public SleepFinishedTimeEvent(ServerLevel worldIn, long newTimeIn, long minTimeIn)
public SleepFinishedTimeEvent(ServerLevel level, long newTime, long minTime)
{
super(worldIn);
this.newTime = newTimeIn;
this.minTime = minTimeIn;
super(level);
this.newTime = newTime;
this.minTime = minTime;
}
/**
@@ -27,14 +27,14 @@ import net.minecraftforge.eventbus.api.Event;
public class VillageSiegeEvent extends Event
{
private final VillageSiege siege;
private final Level world;
private final Level level;
private final Player player;
private final Vec3 attemptedSpawnPos;
public VillageSiegeEvent(VillageSiege siege, Level world, Player player, Vec3 attemptedSpawnPos)
public VillageSiegeEvent(VillageSiege siege, Level level, Player player, Vec3 attemptedSpawnPos)
{
this.siege = siege;
this.world = world;
this.level = level;
this.player = player;
this.attemptedSpawnPos = attemptedSpawnPos;
}
@@ -44,9 +44,9 @@ public class VillageSiegeEvent extends Event
return siege;
}
public Level getWorld()
public Level getLevel()
{
return world;
return level;
}
public Player getPlayer()
@@ -1,36 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
/*package net.minecraftforge.event.world;
/**
* Register all of your custom ModDimensons here, fired during server loading when
* dimension data is read from the world file.
*
* Contains a list of missing entries. Registering an entry with the DimensionManger
* will remove the matching entry from the missing list.
* /
public class RegisterDimensionsEvent extends Event
{
private final Map<ResourceLocation, SavedEntry> missing;
private final Set<ResourceLocation> keys;
public RegisterDimensionsEvent(Map<ResourceLocation, SavedEntry> missing)
{
this.missing = missing;
this.keys = Collections.unmodifiableSet(this.missing.keySet());
}
public Set<ResourceLocation> getMissingNames()
{
return keys;
}
@Nullable
public SavedEntry getEntry(ResourceLocation key)
{
return missing.get(key);
}
}*/
@@ -1,57 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.world;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
* SaplingGrowTreeEvent is fired when a sapling grows into a tree.<br>
* This event is fired during sapling growth in
* {@link SaplingBlock#advanceTree(ServerLevel, BlockPos, BlockState, RandomSource)} .<br>
* <br>
* {@link #pos} contains the coordinates of the growing sapling. <br>
* {@link #rand} contains an instance of Random for use. <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event has a result. {@link HasResult} <br>
* This result determines if the sapling is allowed to grow. <br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
@HasResult
public class SaplingGrowTreeEvent extends WorldEvent
{
private final BlockPos pos;
private final RandomSource rand;
public SaplingGrowTreeEvent(LevelAccessor world, RandomSource rand, BlockPos pos)
{
super(world);
this.rand = rand;
this.pos = pos;
}
public BlockPos getPos()
{
return pos;
}
public RandomSource getRand()
{
return rand;
}
}
@@ -1,121 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event.world;
import java.util.function.Supplier;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.ProgressListener;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.dimension.DimensionType;
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;
/**
* WorldEvent is fired when an event involving the world occurs.<br>
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* {@link #world} contains the World this event is occurring in.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public class WorldEvent extends Event
{
private final LevelAccessor world;
public WorldEvent(LevelAccessor world)
{
this.world = world;
}
public LevelAccessor getWorld()
{
return world;
}
/**
* WorldEvent.Load is fired when Minecraft loads a world.<br>
* This event is fired when a world is loaded in
* {@code ClientLevel#ClientLevel(ClientPacketListener, ClientLevel.ClientLevelData, ResourceKey, DimensionType, int, int, Supplier, LevelRenderer, boolean, long)},
* {@code MinecraftServer#createLevels(ChunkProgressListener)}. <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public static class Load extends WorldEvent
{
public Load(LevelAccessor world) { super(world); }
}
/**
* WorldEvent.Unload is fired when Minecraft unloads a world.<br>
* This event is fired when a world is unloaded in
* {@link Minecraft#setLevel(ClientLevel)},
* {@link MinecraftServer#stopServer()},,
* {@link Minecraft#clearLevel(Screen)}
* {@link ForgeInternalHandler#onDimensionUnload(Unload)}. <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public static class Unload extends WorldEvent
{
public Unload(LevelAccessor world) { super(world); }
}
/**
* WorldEvent.Save is fired when Minecraft saves a world.<br>
* This event is fired when a world is saved in
* {@link ServerLevel#save(ProgressListener, boolean, boolean)}. <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public static class Save extends WorldEvent
{
public Save(LevelAccessor world) { super(world); }
}
/**
* Called by WorldServer when it attempts to create a spawnpoint for a dimension.
* Canceling the event will prevent the vanilla code from running.
*/
@net.minecraftforge.eventbus.api.Cancelable
public static class CreateSpawnPosition extends WorldEvent
{
private final ServerLevelData settings;
public CreateSpawnPosition(LevelAccessor world, ServerLevelData settings)
{
super(world);
this.settings = settings;
}
public ServerLevelData getSettings()
{
return settings;
}
}
}
@@ -18,13 +18,13 @@ import net.minecraftforge.fluids.capability.templates.FluidTank;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class TileFluidHandler extends BlockEntity
public class FluidHandlerBlockEntity extends BlockEntity
{
protected FluidTank tank = new FluidTank(FluidType.BUCKET_VOLUME);
private final LazyOptional<IFluidHandler> holder = LazyOptional.of(() -> tank);
public TileFluidHandler(@NotNull BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state)
public FluidHandlerBlockEntity(@NotNull BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state)
{
super(blockEntityType, pos, state);
}
@@ -16,8 +16,8 @@ import java.util.stream.Collectors;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.network.chat.Component;
import net.minecraftforge.client.ConfigScreenHandler;
import net.minecraftforge.fml.util.thread.EffectiveSide;
import net.minecraftforge.client.ConfigGuiHandler.ConfigGuiFactory;
import net.minecraftforge.network.ConnectionData.ModMismatchData;
import net.minecraftforge.network.filters.NetworkFilters;
import org.apache.commons.lang3.tuple.Pair;
@@ -144,35 +144,35 @@ public class NetworkHooks
/**
* Request to open a GUI on the client, from the server
*
* Refer to {@link ConfigGuiFactory} for how to provide a function to consume
* Refer to {@link ConfigScreenHandler.ConfigScreenFactory} for how to provide a function to consume
* these GUI requests on the client.
*
* @param player The player to open the GUI for
* @param containerSupplier A supplier of container properties including the registry name of the container
*/
public static void openGui(ServerPlayer player, MenuProvider containerSupplier)
public static void openScreen(ServerPlayer player, MenuProvider containerSupplier)
{
openGui(player, containerSupplier, buf -> {});
openScreen(player, containerSupplier, buf -> {});
}
/**
* Request to open a GUI on the client, from the server
*
* Refer to {@link ConfigGuiFactory} for how to provide a function to consume
* Refer to {@link ConfigScreenHandler.ConfigScreenFactory} for how to provide a function to consume
* these GUI requests on the client.
*
* @param player The player to open the GUI for
* @param containerSupplier A supplier of container properties including the registry name of the container
* @param pos A block pos, which will be encoded into the auxillary data for this request
*/
public static void openGui(ServerPlayer player, MenuProvider containerSupplier, BlockPos pos)
public static void openScreen(ServerPlayer player, MenuProvider containerSupplier, BlockPos pos)
{
openGui(player, containerSupplier, buf -> buf.writeBlockPos(pos));
openScreen(player, containerSupplier, buf -> buf.writeBlockPos(pos));
}
/**
* Request to open a GUI on the client, from the server
*
* Refer to {@link ConfigGuiFactory} for how to provide a function to consume
* Refer to {@link ConfigScreenHandler.ConfigScreenFactory} for how to provide a function to consume
* these GUI requests on the client.
*
* The maximum size for #extraDataWriter is 32600 bytes.
@@ -181,7 +181,7 @@ public class NetworkHooks
* @param containerSupplier A supplier of container properties including the registry name of the container
* @param extraDataWriter Consumer to write any additional data the GUI needs
*/
public static void openGui(ServerPlayer player, MenuProvider containerSupplier, Consumer<FriendlyByteBuf> extraDataWriter)
public static void openScreen(ServerPlayer player, MenuProvider containerSupplier, Consumer<FriendlyByteBuf> extraDataWriter)
{
if (player.level.isClientSide) return;
player.doCloseContainer();
@@ -19,8 +19,8 @@ public class ForgeDeferredRegistriesSetup
if (setup)
throw new IllegalStateException("Setup has already been called!");
ForgeRegistries.DEFERRED_DATA_SERIALIZERS.register(modEventBus);
ForgeRegistries.DEFERRED_LOOT_MODIFIER_SERIALIZERS.register(modEventBus);
ForgeRegistries.DEFERRED_ENTITY_DATA_SERIALIZERS.register(modEventBus);
ForgeRegistries.DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS.register(modEventBus);
ForgeRegistries.DEFERRED_BIOME_MODIFIER_SERIALIZERS.register(modEventBus);
ForgeRegistries.DEFERRED_FLUID_TYPES.register(modEventBus);
ForgeRegistries.DEFERRED_BIOME_MODIFIERS.register(modEventBus);
@@ -65,10 +65,10 @@ public class ForgeRegistries
public static final IForgeRegistry<SoundEvent> SOUND_EVENTS = RegistryManager.ACTIVE.getRegistry(Keys.SOUND_EVENTS);
public static final IForgeRegistry<Potion> POTIONS = RegistryManager.ACTIVE.getRegistry(Keys.POTIONS);
public static final IForgeRegistry<Enchantment> ENCHANTMENTS = RegistryManager.ACTIVE.getRegistry(Keys.ENCHANTMENTS);
public static final IForgeRegistry<EntityType<?>> ENTITIES = RegistryManager.ACTIVE.getRegistry(Keys.ENTITY_TYPES);
public static final IForgeRegistry<BlockEntityType<?>> BLOCK_ENTITIES = RegistryManager.ACTIVE.getRegistry(Keys.BLOCK_ENTITY_TYPES);
public static final IForgeRegistry<EntityType<?>> ENTITY_TYPES = RegistryManager.ACTIVE.getRegistry(Keys.ENTITY_TYPES);
public static final IForgeRegistry<BlockEntityType<?>> BLOCK_ENTITY_TYPES = RegistryManager.ACTIVE.getRegistry(Keys.BLOCK_ENTITY_TYPES);
public static final IForgeRegistry<ParticleType<?>> PARTICLE_TYPES = RegistryManager.ACTIVE.getRegistry(Keys.PARTICLE_TYPES);
public static final IForgeRegistry<MenuType<?>> CONTAINERS = RegistryManager.ACTIVE.getRegistry(Keys.CONTAINER_TYPES);
public static final IForgeRegistry<MenuType<?>> MENU_TYPES = RegistryManager.ACTIVE.getRegistry(Keys.MENU_TYPES);
public static final IForgeRegistry<PaintingVariant> PAINTING_VARIANTS = RegistryManager.ACTIVE.getRegistry(Keys.PAINTING_VARIANTS);
public static final IForgeRegistry<RecipeType<?>> RECIPE_TYPES = RegistryManager.ACTIVE.getRegistry(Keys.RECIPE_TYPES);
public static final IForgeRegistry<RecipeSerializer<?>> RECIPE_SERIALIZERS = RegistryManager.ACTIVE.getRegistry(Keys.RECIPE_SERIALIZERS);
@@ -76,7 +76,7 @@ public class ForgeRegistries
public static final IForgeRegistry<StatType<?>> STAT_TYPES = RegistryManager.ACTIVE.getRegistry(Keys.STAT_TYPES);
// Villages
public static final IForgeRegistry<VillagerProfession> PROFESSIONS = RegistryManager.ACTIVE.getRegistry(Keys.VILLAGER_PROFESSIONS);
public static final IForgeRegistry<VillagerProfession> VILLAGER_PROFESSIONS = RegistryManager.ACTIVE.getRegistry(Keys.VILLAGER_PROFESSIONS);
public static final IForgeRegistry<PoiType> POI_TYPES = RegistryManager.ACTIVE.getRegistry(Keys.POI_TYPES);
public static final IForgeRegistry<MemoryModuleType<?>> MEMORY_MODULE_TYPES = RegistryManager.ACTIVE.getRegistry(Keys.MEMORY_MODULE_TYPES);
public static final IForgeRegistry<SensorType<?>> SENSOR_TYPES = RegistryManager.ACTIVE.getRegistry(Keys.SENSOR_TYPES);
@@ -95,15 +95,35 @@ public class ForgeRegistries
public static final IForgeRegistry<Biome> BIOMES = RegistryManager.ACTIVE.getRegistry(Keys.BIOMES);
// Custom forge registries
static final DeferredRegister<EntityDataSerializer<?>> DEFERRED_DATA_SERIALIZERS = DeferredRegister.create(Keys.DATA_SERIALIZERS, Keys.DATA_SERIALIZERS.location().getNamespace());
public static final Supplier<IForgeRegistry<EntityDataSerializer<?>>> DATA_SERIALIZERS = DEFERRED_DATA_SERIALIZERS.makeRegistry(GameData::getDataSerializersRegistryBuilder);
static final DeferredRegister<Codec<? extends IGlobalLootModifier>> DEFERRED_LOOT_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.LOOT_MODIFIER_SERIALIZERS, Keys.LOOT_MODIFIER_SERIALIZERS.location().getNamespace());
public static final Supplier<IForgeRegistry<Codec<? extends IGlobalLootModifier>>> LOOT_MODIFIER_SERIALIZERS = DEFERRED_LOOT_MODIFIER_SERIALIZERS.makeRegistry(GameData::getGLMSerializersRegistryBuilder);
static final DeferredRegister<EntityDataSerializer<?>> DEFERRED_ENTITY_DATA_SERIALIZERS = DeferredRegister.create(Keys.ENTITY_DATA_SERIALIZERS, Keys.ENTITY_DATA_SERIALIZERS.location().getNamespace());
/**
* Calling {@link Supplier#get()} before {@link NewRegistryEvent} is fired will result in a null registry returned.
* Use {@link Keys#ENTITY_DATA_SERIALIZERS} to create a {@link DeferredRegister}.
*/
public static final Supplier<IForgeRegistry<EntityDataSerializer<?>>> ENTITY_DATA_SERIALIZERS = DEFERRED_ENTITY_DATA_SERIALIZERS.makeRegistry(GameData::getDataSerializersRegistryBuilder);
static final DeferredRegister<Codec<? extends IGlobalLootModifier>> DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS.location().getNamespace());
/**
* Calling {@link Supplier#get()} before {@link NewRegistryEvent} is fired will result in a null registry returned.
* Use {@link Keys#GLOBAL_LOOT_MODIFIER_SERIALIZERS} to create a {@link DeferredRegister}.
*/
public static final Supplier<IForgeRegistry<Codec<? extends IGlobalLootModifier>>> GLOBAL_LOOT_MODIFIER_SERIALIZERS = DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS.makeRegistry(GameData::getGLMSerializersRegistryBuilder);
static final DeferredRegister<Codec<? extends BiomeModifier>> DEFERRED_BIOME_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.BIOME_MODIFIER_SERIALIZERS, Keys.BIOME_MODIFIER_SERIALIZERS.location().getNamespace());
/**
* Calling {@link Supplier#get()} before {@link NewRegistryEvent} is fired will result in a null registry returned.
* Use {@link Keys#BIOME_MODIFIER_SERIALIZERS} to create a {@link DeferredRegister}.
*/
public static final Supplier<IForgeRegistry<Codec<? extends BiomeModifier>>> BIOME_MODIFIER_SERIALIZERS = DEFERRED_BIOME_MODIFIER_SERIALIZERS.makeRegistry(() -> new RegistryBuilder<Codec<? extends BiomeModifier>>().disableSaving().disableSync());
static final DeferredRegister<Codec<? extends StructureModifier>> DEFERRED_STRUCTURE_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.STRUCTURE_MODIFIER_SERIALIZERS, Keys.STRUCTURE_MODIFIER_SERIALIZERS.location().getNamespace());
/**
* Calling {@link Supplier#get()} before {@link NewRegistryEvent} is fired will result in a null registry returned.
* Use {@link Keys#STRUCTURE_MODIFIER_SERIALIZERS} to create a {@link DeferredRegister}.
*/
public static final Supplier<IForgeRegistry<Codec<? extends StructureModifier>>> STRUCTURE_MODIFIER_SERIALIZERS = DEFERRED_STRUCTURE_MODIFIER_SERIALIZERS.makeRegistry(() -> new RegistryBuilder<Codec<? extends StructureModifier>>().disableSaving().disableSync());
static final DeferredRegister<FluidType> DEFERRED_FLUID_TYPES = DeferredRegister.create(Keys.FLUID_TYPES, Keys.FLUID_TYPES.location().getNamespace());
/**
* Calling {@link Supplier#get()} before {@link NewRegistryEvent} is fired will result in a null registry returned.
* Use {@link Keys#FLUID_TYPES} to create a {@link DeferredRegister}.
*/
public static final Supplier<IForgeRegistry<FluidType>> FLUID_TYPES = DEFERRED_FLUID_TYPES.makeRegistry(GameData::getFluidTypeRegistryBuilder);
// Custom forge datapack registries
@@ -126,7 +146,7 @@ public class ForgeRegistries
public static final ResourceKey<Registry<EntityType<?>>> ENTITY_TYPES = key("entity_type");
public static final ResourceKey<Registry<PaintingVariant>> PAINTING_VARIANTS = key("painting_variant");
public static final ResourceKey<Registry<ParticleType<?>>> PARTICLE_TYPES = key("particle_type");
public static final ResourceKey<Registry<MenuType<?>>> CONTAINER_TYPES = key("menu");
public static final ResourceKey<Registry<MenuType<?>>> MENU_TYPES = key("menu");
public static final ResourceKey<Registry<BlockEntityType<?>>> BLOCK_ENTITY_TYPES = key("block_entity_type");
public static final ResourceKey<Registry<RecipeType<?>>> RECIPE_TYPES = key("recipe_type");
public static final ResourceKey<Registry<RecipeSerializer<?>>> RECIPE_SERIALIZERS = key("recipe_serializer");
@@ -147,8 +167,8 @@ public class ForgeRegistries
public static final ResourceKey<Registry<Biome>> BIOMES = key("worldgen/biome");
// Forge
public static final ResourceKey<Registry<EntityDataSerializer<?>>> DATA_SERIALIZERS = key("forge:data_serializers");
public static final ResourceKey<Registry<Codec<? extends IGlobalLootModifier>>> LOOT_MODIFIER_SERIALIZERS = key("forge:loot_modifier_serializers");
public static final ResourceKey<Registry<EntityDataSerializer<?>>> ENTITY_DATA_SERIALIZERS = key("forge:data_serializers");
public static final ResourceKey<Registry<Codec<? extends IGlobalLootModifier>>> GLOBAL_LOOT_MODIFIER_SERIALIZERS = key("forge:loot_modifier_serializers");
public static final ResourceKey<Registry<Codec<? extends BiomeModifier>>> BIOME_MODIFIER_SERIALIZERS = key("forge:biome_modifier_serializers");
public static final ResourceKey<Registry<Codec<? extends StructureModifier>>> STRUCTURE_MODIFIER_SERIALIZERS = key("forge:structure_modifier_serializers");
public static final ResourceKey<Registry<FluidType>> FLUID_TYPES = key("forge:fluid_type");
@@ -111,7 +111,7 @@ public class GameData
makeRegistry(ENTITY_TYPES, "pig").legacyName("entities").vanillaHolder(EntityType::builtInRegistryHolder).create();
makeRegistry(BLOCK_ENTITY_TYPES).disableSaving().legacyName("blockentities").create();
makeRegistry(PARTICLE_TYPES).disableSaving().create();
makeRegistry(CONTAINER_TYPES).disableSaving().create();
makeRegistry(MENU_TYPES).disableSaving().create();
makeRegistry(PAINTING_VARIANTS, "kebab").create();
makeRegistry(RECIPE_TYPES).disableSaving().disableSync().create();
makeRegistry(RECIPE_SERIALIZERS).disableSaving().create();
@@ -140,12 +140,12 @@ public class GameData
static RegistryBuilder<EntityDataSerializer<?>> getDataSerializersRegistryBuilder()
{
return makeRegistry(DATA_SERIALIZERS, 256 /*vanilla space*/, MAX_VARINT).disableSaving().disableOverrides();
return makeRegistry(ENTITY_DATA_SERIALIZERS, 256 /*vanilla space*/, MAX_VARINT).disableSaving().disableOverrides();
}
static RegistryBuilder<Codec<? extends IGlobalLootModifier>> getGLMSerializersRegistryBuilder()
{
return makeRegistry(LOOT_MODIFIER_SERIALIZERS).disableSaving().disableSync();
return makeRegistry(GLOBAL_LOOT_MODIFIER_SERIALIZERS).disableSaving().disableSync();
}
static RegistryBuilder<FluidType> getFluidTypeRegistryBuilder()
@@ -22,7 +22,7 @@ import net.minecraft.server.packs.metadata.MetadataSectionSerializer;
import net.minecraft.server.packs.metadata.pack.PackMetadataSection;
import net.minecraft.resources.ResourceLocation;
public class DelegatingResourcePack extends AbstractPackResources
public class DelegatingPackResources extends AbstractPackResources
{
private final List<PackResources> delegates;
private Map<String, List<PackResources>> namespacesAssets;
@@ -31,7 +31,7 @@ public class DelegatingResourcePack extends AbstractPackResources
private final String name;
private final PackMetadataSection packInfo;
public DelegatingResourcePack(String id, String name, PackMetadataSection packInfo, List<? extends PackResources> packs)
public DelegatingPackResources(String id, String name, PackMetadataSection packInfo, List<? extends PackResources> packs)
{
super(new File(id));
this.name = name;
@@ -75,7 +75,7 @@ public class DelegatingResourcePack extends AbstractPackResources
{
return name;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getMetadataSection(MetadataSectionSerializer<T> deserializer) throws IOException
@@ -33,7 +33,7 @@ import java.util.stream.Collectors;
* such as to have alternative textures to use along with Programmer Art, or optional
* alternative recipes for compatibility ot to replace vanilla recipes.
*/
public class PathResourcePack extends AbstractPackResources
public class PathPackResources extends AbstractPackResources
{
private final Path source;
private final String packName;
@@ -47,7 +47,7 @@ public class PathResourcePack extends AbstractPackResources
* This name should be unique within the pack finder, preferably the name of the file or folder containing the resources.
* @param source the root path of the pack. This needs to point to the folder that contains "assets" and/or "data", not the asset folder itself!
*/
public PathResourcePack(String packName, final Path source)
public PathPackResources(String packName, final Path source)
{
super(new File("dummy"));
this.source = source;
@@ -30,19 +30,19 @@ import net.minecraftforge.forgespi.locating.IModFile;
import org.jetbrains.annotations.NotNull;
public class ResourcePackLoader {
private static Map<IModFile, PathResourcePack> modResourcePacks;
private static Map<IModFile, PathPackResources> modResourcePacks;
public static Optional<PathResourcePack> getPackFor(String modId) {
public static Optional<PathPackResources> getPackFor(String modId) {
return Optional.ofNullable(ModList.get().getModFileById(modId)).
map(IModFileInfo::getFile).map(mf->modResourcePacks.get(mf));
}
@Deprecated
public static void loadResourcePacks(PackRepository resourcePacks, BiFunction<Map<IModFile, ? extends PathResourcePack>, BiConsumer<? super PathResourcePack, Pack>, ? extends RepositorySource> packFinder) {
public static void loadResourcePacks(PackRepository resourcePacks, BiFunction<Map<IModFile, ? extends PathPackResources>, BiConsumer<? super PathPackResources, Pack>, ? extends RepositorySource> packFinder) {
loadResourcePacks(resourcePacks, (map) -> packFinder.apply(map, (rp,p) -> {}));
}
public static void loadResourcePacks(PackRepository resourcePacks, Function<Map<IModFile, ? extends PathResourcePack>, ? extends RepositorySource> packFinder) {
public static void loadResourcePacks(PackRepository resourcePacks, Function<Map<IModFile, ? extends PathPackResources>, ? extends RepositorySource> packFinder) {
modResourcePacks = ModList.get().getModFiles().stream()
.filter(mf->mf.requiredLanguageLoaders().stream().noneMatch(ls->ls.languageName().equals("minecraft")))
.map(mf -> Pair.of(mf, createPackForMod(mf)))
@@ -51,9 +51,9 @@ public class ResourcePackLoader {
}
@NotNull
public static PathResourcePack createPackForMod(IModFileInfo mf)
public static PathPackResources createPackForMod(IModFileInfo mf)
{
return new PathResourcePack(mf.getFile().getFileName(), mf.getFile().getFilePath()){
return new PathPackResources(mf.getFile().getFileName(), mf.getFile().getFilePath()){
final IModFile modFile = mf.getFile();
@NotNull
@Override
@@ -12,7 +12,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
@@ -40,7 +39,7 @@ import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.forgespi.locating.IModFile;
import net.minecraftforge.registries.ForgeRegistries.Keys;
import net.minecraftforge.resource.PathResourcePack;
import net.minecraftforge.resource.PathPackResources;
import net.minecraftforge.server.permission.PermissionAPI;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -51,7 +50,6 @@ import net.minecraft.network.Connection;
import net.minecraft.network.ConnectionProtocol;
import net.minecraft.network.protocol.handshake.ClientIntentionPacket;
import net.minecraft.network.protocol.login.ClientboundLoginDisconnectPacket;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.api.distmarker.Dist;
@@ -65,7 +63,6 @@ import net.minecraftforge.event.server.ServerStoppedEvent;
import net.minecraftforge.event.server.ServerStoppingEvent;
import net.minecraftforge.fml.loading.FileUtils;
import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.registries.DataPackRegistriesHooks;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.GameData;
@@ -192,12 +189,12 @@ public class ServerLifecycleHooks
}
//INTERNAL MODDERS DO NOT USE
public static RepositorySource buildPackFinder(Map<IModFile, ? extends PathResourcePack> modResourcePacks) {
public static RepositorySource buildPackFinder(Map<IModFile, ? extends PathPackResources> modResourcePacks) {
return (packList, factory) -> serverPackFinder(modResourcePacks, packList, factory);
}
private static void serverPackFinder(Map<IModFile, ? extends PathResourcePack> modResourcePacks, Consumer<Pack> consumer, Pack.PackConstructor factory) {
for (Entry<IModFile, ? extends PathResourcePack> e : modResourcePacks.entrySet())
private static void serverPackFinder(Map<IModFile, ? extends PathPackResources> modResourcePacks, Consumer<Pack> consumer, Pack.PackConstructor factory) {
for (Entry<IModFile, ? extends PathPackResources> e : modResourcePacks.entrySet())
{
IModInfo mod = e.getKey().getModInfos().get(0);
if (Objects.equals(mod.getModId(), "minecraft")) continue; // skip the minecraft "mod"
@@ -212,7 +209,7 @@ public class ServerLifecycleHooks
consumer.accept(packInfo);
}
}
private static void runModifiers(final MinecraftServer server)
{
final RegistryAccess registries = server.registryAccess();
@@ -226,7 +223,7 @@ public class ServerLifecycleHooks
.holders()
.map(Holder::value)
.toList();
// Apply sorted biome modifiers to each biome.
registries.registryOrThrow(Registry.BIOME_REGISTRY).holders().forEach(biomeHolder ->
{
@@ -52,7 +52,7 @@ class EntityCommand
return Commands.literal("list")
.requires(cs->cs.hasPermission(2)) //permission
.then(Commands.argument("filter", StringArgumentType.string())
.suggests((ctx, builder) -> SharedSuggestionProvider.suggest(ForgeRegistries.ENTITIES.getKeys().stream().map(ResourceLocation::toString).map(StringArgumentType::escapeIfRequired), builder))
.suggests((ctx, builder) -> SharedSuggestionProvider.suggest(ForgeRegistries.ENTITY_TYPES.getKeys().stream().map(ResourceLocation::toString).map(StringArgumentType::escapeIfRequired), builder))
.then(Commands.argument("dim", DimensionArgument.dimension())
.executes(ctx -> execute(ctx.getSource(), StringArgumentType.getString(ctx, "filter"), DimensionArgument.getDimension(ctx, "dim").dimension()))
)
@@ -65,7 +65,7 @@ class EntityCommand
{
final String cleanFilter = filter.replace("?", ".?").replace("*", ".*?");
Set<ResourceLocation> names = ForgeRegistries.ENTITIES.getKeys().stream().filter(n -> n.toString().matches(cleanFilter)).collect(Collectors.toSet());
Set<ResourceLocation> names = ForgeRegistries.ENTITY_TYPES.getKeys().stream().filter(n -> n.toString().matches(cleanFilter)).collect(Collectors.toSet());
if (names.isEmpty())
throw INVALID_FILTER.create();
@@ -76,7 +76,7 @@ class EntityCommand
Map<ResourceLocation, MutablePair<Integer, Map<ChunkPos, Integer>>> list = Maps.newHashMap();
level.getEntities().getAll().forEach(e -> {
MutablePair<Integer, Map<ChunkPos, Integer>> info = list.computeIfAbsent(ForgeRegistries.ENTITIES.getKey(e.getType()), k -> MutablePair.of(0, Maps.newHashMap()));
MutablePair<Integer, Map<ChunkPos, Integer>> info = list.computeIfAbsent(ForgeRegistries.ENTITY_TYPES.getKey(e.getType()), k -> MutablePair.of(0, Maps.newHashMap()));
ChunkPos chunk = new ChunkPos(e.blockPosition());
info.left++;
info.right.put(chunk, info.right.getOrDefault(chunk, 0) + 1);
@@ -143,7 +143,7 @@ class TrackCommand
double averageTimings = data.getAverageTimings();
String tickTime = (averageTimings > 1000 ? TIME_FORMAT.format(averageTimings / 1000) : TIME_FORMAT.format(averageTimings)) + (averageTimings < 1000 ? "\u03bcs" : "ms");
return Component.translatable("commands.forge.tracking.timing_entry", ForgeRegistries.ENTITIES.getKey(entity.getType()), entity.level.dimension().location().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime);
return Component.translatable("commands.forge.tracking.timing_entry", ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()), entity.level.dimension().location().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime);
})
);
}
@@ -163,7 +163,7 @@ class TrackCommand
double averageTimings = data.getAverageTimings();
String tickTime = (averageTimings > 1000 ? TIME_FORMAT.format(averageTimings / 1000) : TIME_FORMAT.format(averageTimings)) + (averageTimings < 1000 ? "\u03bcs" : "ms");
return Component.translatable("commands.forge.tracking.timing_entry", ForgeRegistries.BLOCK_ENTITIES.getKey(be.getType()), be.getLevel().dimension().location().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime);
return Component.translatable("commands.forge.tracking.timing_entry", ForgeRegistries.BLOCK_ENTITY_TYPES.getKey(be.getType()), be.getLevel().dimension().location().toString(), pos.getX(), pos.getY(), pos.getZ(), tickTime);
})
);
}