mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 19:59:42 +00:00
Some patch cleanup (#9951)
This commit is contained in:
1 parent
0cad6b14d9
commit
58012bfb17
18 files changed
+233
-113
No files matched your search
@@ -1,16 +1,21 @@
|
||||
--- a/com/mojang/blaze3d/vertex/VertexFormat.java
|
||||
+++ b/com/mojang/blaze3d/vertex/VertexFormat.java
|
||||
@@ -114,6 +_,13 @@
|
||||
@@ -12,7 +_,7 @@
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public class VertexFormat {
|
||||
+public class VertexFormat implements net.minecraftforge.client.extensions.IForgeVertexFormat {
|
||||
private final ImmutableList<VertexFormatElement> elements;
|
||||
private final ImmutableMap<String, VertexFormatElement> elementMapping;
|
||||
private final IntList offsets = new IntArrayList();
|
||||
@@ -113,6 +_,9 @@
|
||||
|
||||
return vertexbuffer;
|
||||
}
|
||||
|
||||
+
|
||||
+ public ImmutableMap<String, VertexFormatElement> getElementMapping() { return elementMapping; }
|
||||
+ public int getOffset(int index) { return offsets.getInt(index); }
|
||||
+ public boolean hasPosition() { return elements.stream().anyMatch(e -> e.getUsage() == VertexFormatElement.Usage.POSITION); }
|
||||
+ public boolean hasNormal() { return elements.stream().anyMatch(e -> e.getUsage() == VertexFormatElement.Usage.NORMAL); }
|
||||
+ public boolean hasColor() { return elements.stream().anyMatch(e -> e.getUsage() == VertexFormatElement.Usage.COLOR); }
|
||||
+ public boolean hasUV(int which) { return elements.stream().anyMatch(e -> e.getUsage() == VertexFormatElement.Usage.UV && e.getIndex() == which); }
|
||||
+
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static enum IndexType {
|
||||
SHORT(5123, 2),
|
||||
+9
-31
@@ -1,5 +1,14 @@
|
||||
--- a/net/minecraft/client/renderer/entity/layers/ElytraLayer.java
|
||||
+++ b/net/minecraft/client/renderer/entity/layers/ElytraLayer.java
|
||||
@@ -23,7 +_,7 @@
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public class ElytraLayer<T extends LivingEntity, M extends EntityModel<T>> extends RenderLayer<T, M> {
|
||||
+public class ElytraLayer<T extends LivingEntity, M extends EntityModel<T>> extends RenderLayer<T, M> implements net.minecraftforge.client.extensions.IForgeElytraLayer<T> {
|
||||
public static final ResourceLocation WINGS_LOCATION = new ResourceLocation("textures/entity/elytra.png");
|
||||
private final ElytraModel<T> elytraModel;
|
||||
|
||||
@@ -45,7 +_,7 @@
|
||||
float p_116960_
|
||||
) {
|
||||
@@ -22,34 +31,3 @@
|
||||
}
|
||||
|
||||
p_116951_.pushPose();
|
||||
@@ -68,5 +_,30 @@
|
||||
this.elytraModel.renderToBuffer(p_116951_, vertexconsumer, p_116953_, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
|
||||
p_116951_.popPose();
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Determines if the ElytraLayer should render.
|
||||
+ * ItemStack and Entity are provided for modder convenience,
|
||||
+ * For example, using the same ElytraLayer for multiple custom Elytra.
|
||||
+ *
|
||||
+ * @param stack The Elytra ItemStack
|
||||
+ * @param entity The entity being rendered.
|
||||
+ * @return If the ElytraLayer should render.
|
||||
+ */
|
||||
+ public boolean shouldRender(ItemStack stack, T entity) {
|
||||
+ return stack.getItem() == Items.ELYTRA;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the texture to use with this ElytraLayer.
|
||||
+ * This assumes the vanilla Elytra model.
|
||||
+ *
|
||||
+ * @param stack The Elytra ItemStack.
|
||||
+ * @param entity The entity being rendered.
|
||||
+ * @return The texture.
|
||||
+ */
|
||||
+ public ResourceLocation getElytraTexture(ItemStack stack, T entity) {
|
||||
+ return WINGS_LOCATION;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
@Override
|
||||
public void die(DamageSource p_9035_) {
|
||||
+ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_9035_)) return;
|
||||
+ if (net.minecraftforge.event.ForgeEventFactory.onLivingDeath(this, p_9035_)) return;
|
||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
if (flag) {
|
||||
|
||||
@@ -220,7 +220,7 @@
|
||||
}
|
||||
|
||||
public void die(DamageSource p_21014_) {
|
||||
+ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_21014_)) return;
|
||||
+ if (net.minecraftforge.event.ForgeEventFactory.onLivingDeath(this, p_21014_)) return;
|
||||
if (!this.isRemoved() && !this.dead) {
|
||||
Entity entity = p_21014_.getEntity();
|
||||
LivingEntity livingentity = this.getKillCredit();
|
||||
@@ -252,7 +252,7 @@
|
||||
this.dropExperience();
|
||||
+
|
||||
+ var drops = captureDrops(null);
|
||||
+ if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(this, p_21192_, drops, i, lastHurtByPlayerTime > 0)) {
|
||||
+ if (!net.minecraftforge.event.ForgeEventFactory.onLivingDrops(this, p_21192_, drops, i, lastHurtByPlayerTime > 0)) {
|
||||
+ drops.forEach(e -> level().addFreshEntity(e));
|
||||
+ }
|
||||
}
|
||||
@@ -439,7 +439,7 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
+ if (net.minecraftforge.common.ForgeHooks.onLivingTick(this)) return;
|
||||
+ if (net.minecraftforge.event.ForgeEventFactory.onLivingTick(this)) return;
|
||||
super.tick();
|
||||
this.updatingUsingItem();
|
||||
this.updateSwimAmount();
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
@Override
|
||||
public void die(DamageSource p_36152_) {
|
||||
+ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_36152_)) return;
|
||||
+ if (net.minecraftforge.event.ForgeEventFactory.onLivingDeath(this, p_36152_)) return;
|
||||
super.die(p_36152_);
|
||||
this.reapplyPosition();
|
||||
if (!this.isSpectator()) {
|
||||
|
||||
@@ -16,30 +16,18 @@
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@@ -104,5 +_,26 @@
|
||||
@@ -104,5 +_,14 @@
|
||||
@Override
|
||||
public String getSerializedName() {
|
||||
return this.name;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public net.minecraft.tags.TagKey<Item> getTag() {
|
||||
+ return tag;
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public static DyeColor getColor(ItemStack stack) {
|
||||
+ if (stack.getItem() instanceof DyeItem dye) {
|
||||
+ return dye.getDyeColor();
|
||||
+ }
|
||||
+
|
||||
+ for (int x = 0; x < BLACK.getId(); x++) {
|
||||
+ var color = byId(x);
|
||||
+ if (stack.is(color.getTag())) {
|
||||
+ return color;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return null;
|
||||
+ return net.minecraftforge.common.ForgeHooks.getDyeColorFromItemStack(stack);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
--- a/net/minecraft/world/level/biome/Biome.java
|
||||
+++ b/net/minecraft/world/level/biome/Biome.java
|
||||
@@ -35,8 +_,8 @@
|
||||
public final class Biome {
|
||||
@@ -32,11 +_,11 @@
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
|
||||
-public final class Biome {
|
||||
+public final class Biome implements net.minecraftforge.common.extensions.IForgeBiome {
|
||||
public static final Codec<Biome> DIRECT_CODEC = RecordCodecBuilder.create(
|
||||
p_220544_ -> p_220544_.group(
|
||||
- Biome.ClimateSettings.CODEC.forGetter(p_151717_ -> p_151717_.climateSettings),
|
||||
@@ -44,33 +48,15 @@
|
||||
}
|
||||
|
||||
public int getFogColor() {
|
||||
@@ -251,6 +_,29 @@
|
||||
@@ -251,6 +_,11 @@
|
||||
|
||||
public Optional<Music> getBackgroundMusic() {
|
||||
return this.specialEffects.getBackgroundMusic();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * {@return Cache of original biome data and biome data modified by biome modifiers}
|
||||
+ * Modified biome data is set by server after datapacks and serverconfigs load.
|
||||
+ * Climate and effects field reads are coremodded to redirect to this.
|
||||
+ **/
|
||||
+ @Override
|
||||
+ public net.minecraftforge.common.world.ModifiableBiomeInfo modifiableBiomeInfo() {
|
||||
+ return this.modifiableBiomeInfo;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * {@return The biome's climate settings, with modifications if called after modifiers are applied in server init.}
|
||||
+ */
|
||||
+ public ClimateSettings getModifiedClimateSettings() {
|
||||
+ return this.modifiableBiomeInfo().get().climateSettings();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * {@return The biome's client effects, with modifications if called after modifiers are applied in server init.}
|
||||
+ */
|
||||
+ public BiomeSpecialEffects getModifiedSpecialEffects() {
|
||||
+ return this.modifiableBiomeInfo().get().effects();
|
||||
}
|
||||
|
||||
public static class BiomeBuilder {
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.client.renderer.RenderType;
|
||||
* be the same as {@code entity}.
|
||||
*/
|
||||
public record RenderTypeGroup(RenderType block, RenderType entity, RenderType entityFabulous) {
|
||||
public static RenderTypeGroup EMPTY = new RenderTypeGroup(null, null, null);
|
||||
public static final RenderTypeGroup EMPTY = new RenderTypeGroup(null, null, null);
|
||||
|
||||
public RenderTypeGroup {
|
||||
if ((block == null) != (entity == null) || (block == null) != (entityFabulous == null))
|
||||
|
||||
@@ -10,6 +10,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
@@ -50,31 +55,46 @@ import net.minecraft.world.entity.decoration.ItemFrame;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.client.event.sound.PlaySoundSourceEvent;
|
||||
import net.minecraftforge.client.event.sound.PlayStreamingSourceEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class ForgeEventFactoryClient {
|
||||
private static final ModLoader ML = ModLoader.get();
|
||||
|
||||
private ForgeEventFactoryClient() {}
|
||||
|
||||
/**
|
||||
* Post an event to the {@link MinecraftForge#EVENT_BUS}
|
||||
* @return true if the event is {@link Cancelable} and has been canceled
|
||||
*/
|
||||
private static boolean post(Event e) {
|
||||
return MinecraftForge.EVENT_BUS.post(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post an event to the {@link MinecraftForge#EVENT_BUS}, then return the event object
|
||||
* @return the event object passed in and possibly modified by listeners
|
||||
*/
|
||||
private static <E extends Event> E fire(E e) {
|
||||
MinecraftForge.EVENT_BUS.post(e);
|
||||
post(e);
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post an event to the {@link ModLoader#get()} event bus
|
||||
*/
|
||||
private static <T extends Event & IModBusEvent> void postModBus(T e) {
|
||||
ML.postEvent(e);
|
||||
}
|
||||
|
||||
public static void onGatherLayers(Map<EntityType<?>, EntityRenderer<?>> renderers, Map<Model, EntityRenderer<? extends Player>> playerRenderers, Context context) {
|
||||
// TODO: Why is this a ModLoader event...
|
||||
ModLoader.get().postEvent(new EntityRenderersEvent.AddLayers(renderers, playerRenderers, context));
|
||||
postModBus(new EntityRenderersEvent.AddLayers(renderers, playerRenderers, context));
|
||||
}
|
||||
|
||||
public static void onRegisterShaders(ResourceProvider resourceProvider, List<Pair<ShaderInstance, Consumer<ShaderInstance>>> shaderList) {
|
||||
// TODO: Why i this a ModLoader event...
|
||||
ModLoader.get().postEvent(new RegisterShadersEvent(resourceProvider, shaderList));
|
||||
// TODO: Why is this a ModLoader event...
|
||||
postModBus(new RegisterShadersEvent(resourceProvider, shaderList));
|
||||
}
|
||||
|
||||
public static void onScreenMouseReleased(boolean[] state, Screen screen, double mouseX, double mouseY, int button) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import net.minecraft.client.renderer.entity.layers.ElytraLayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
public interface IForgeElytraLayer<T> {
|
||||
/**
|
||||
* Determines if the ElytraLayer should render.
|
||||
* ItemStack and Entity are provided for modder convenience,
|
||||
* For example, using the same ElytraLayer for multiple custom Elytra.
|
||||
*
|
||||
* @param stack The Elytra ItemStack
|
||||
* @param entity The entity being rendered.
|
||||
* @return If the ElytraLayer should render.
|
||||
*/
|
||||
default boolean shouldRender(ItemStack stack, T entity) {
|
||||
return stack.getItem() == Items.ELYTRA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the texture to use with this ElytraLayer.
|
||||
* This assumes the vanilla Elytra model.
|
||||
*
|
||||
* @param stack The Elytra ItemStack.
|
||||
* @param entity The entity being rendered.
|
||||
* @return The texture.
|
||||
*/
|
||||
default ResourceLocation getElytraTexture(ItemStack stack, T entity) {
|
||||
return ElytraLayer.WINGS_LOCATION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
|
||||
/**
|
||||
* Extension interface for {@link VertexFormat}.
|
||||
*/
|
||||
public interface IForgeVertexFormat {
|
||||
ImmutableList<VertexFormatElement> getElements();
|
||||
|
||||
default boolean hasPosition() {
|
||||
return getElements().stream().anyMatch(e -> e.getUsage() == VertexFormatElement.Usage.POSITION);
|
||||
}
|
||||
|
||||
default boolean hasNormal() {
|
||||
return getElements().stream().anyMatch(e -> e.getUsage() == VertexFormatElement.Usage.NORMAL);
|
||||
}
|
||||
|
||||
default boolean hasColor() {
|
||||
return getElements().stream().anyMatch(e -> e.getUsage() == VertexFormatElement.Usage.COLOR);
|
||||
}
|
||||
|
||||
default boolean hasUV(int which) {
|
||||
for (var e : getElements()) {
|
||||
if (e.getUsage() == VertexFormatElement.Usage.UV && e.getIndex() == which) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -226,10 +226,6 @@ public final class ForgeHooks {
|
||||
return brainBuilder.makeBrain(dynamic);
|
||||
}
|
||||
|
||||
public static boolean onLivingTick(LivingEntity entity) {
|
||||
return MinecraftForge.EVENT_BUS.post(new LivingTickEvent(entity));
|
||||
}
|
||||
|
||||
public static boolean onLivingAttack(LivingEntity entity, DamageSource src, float amount) {
|
||||
return entity instanceof Player || !MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount));
|
||||
}
|
||||
@@ -252,14 +248,6 @@ public final class ForgeHooks {
|
||||
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount());
|
||||
}
|
||||
|
||||
public static boolean onLivingDeath(LivingEntity entity, DamageSource src) {
|
||||
return MinecraftForge.EVENT_BUS.post(new LivingDeathEvent(entity, src));
|
||||
}
|
||||
|
||||
public static boolean onLivingDrops(LivingEntity entity, DamageSource source, Collection<ItemEntity> drops, int lootingLevel, boolean recentlyHit) {
|
||||
return MinecraftForge.EVENT_BUS.post(new LivingDropsEvent(entity, source, drops, lootingLevel, recentlyHit));
|
||||
}
|
||||
|
||||
public static int getLootingLevel(Entity target, @Nullable Entity killer, @Nullable DamageSource cause) {
|
||||
int looting = 0;
|
||||
if (killer instanceof LivingEntity living)
|
||||
@@ -778,7 +766,7 @@ public final class ForgeHooks {
|
||||
@SuppressWarnings("deprecation")
|
||||
public static synchronized void updateBurns() {
|
||||
VANILLA_BURNS.clear();
|
||||
FurnaceBlockEntity.getFuel().entrySet().forEach(e -> VANILLA_BURNS.put(ForgeRegistries.ITEMS.getDelegateOrThrow(e.getKey()), e.getValue()));
|
||||
FurnaceBlockEntity.getFuel().forEach((k, v) -> VANILLA_BURNS.put(ForgeRegistries.ITEMS.getDelegateOrThrow(k), v));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1260,4 +1248,19 @@ public final class ForgeHooks {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static DyeColor getDyeColorFromItemStack(ItemStack stack) {
|
||||
if (stack.getItem() instanceof DyeItem dye)
|
||||
return dye.getDyeColor();
|
||||
|
||||
for (int x = 0; x < DyeColor.BLACK.getId(); x++) {
|
||||
var color = DyeColor.byId(x);
|
||||
if (stack.is(color.getTag())) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSpecialEffects;
|
||||
import net.minecraftforge.common.world.ModifiableBiomeInfo;
|
||||
|
||||
public interface IForgeBiome {
|
||||
/**
|
||||
* {@return Cache of original biome data and biome data modified by biome modifiers}
|
||||
* Modified biome data is set by server after datapacks and serverconfigs load.
|
||||
* Climate and effects field reads are coremodded to redirect to this.
|
||||
**/
|
||||
ModifiableBiomeInfo modifiableBiomeInfo();
|
||||
|
||||
/**
|
||||
* {@return The biome's climate settings, with modifications if called after modifiers are applied in server init.}
|
||||
*/
|
||||
default Biome.ClimateSettings getModifiedClimateSettings() {
|
||||
return modifiableBiomeInfo().get().climateSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return The biome's client effects, with modifications if called after modifiers are applied in server init.}
|
||||
*/
|
||||
default BiomeSpecialEffects getModifiedSpecialEffects() {
|
||||
return modifiableBiomeInfo().get().effects();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
package net.minecraftforge.event;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -13,6 +14,11 @@ import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -113,7 +119,6 @@ import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.ToolAction;
|
||||
import net.minecraftforge.common.capabilities.CapabilityDispatcher;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
@@ -138,10 +143,13 @@ import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingBreatheEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingConversionEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDestroyBlockEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDrownEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingExperienceDropEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHealEvent;
|
||||
@@ -154,7 +162,6 @@ import net.minecraftforge.event.entity.living.MobSpawnEvent.AllowDespawn;
|
||||
import net.minecraftforge.event.entity.living.MobSpawnEvent.PositionCheck;
|
||||
import net.minecraftforge.event.entity.living.MobSpawnEvent.SpawnPlacementCheck;
|
||||
import net.minecraftforge.event.entity.living.ShieldBlockEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent.ILivingTargetType;
|
||||
import net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent;
|
||||
import net.minecraftforge.event.entity.player.AdvancementEvent.AdvancementEarnEvent;
|
||||
import net.minecraftforge.event.entity.player.AdvancementEvent.AdvancementProgressEvent;
|
||||
@@ -201,27 +208,37 @@ import net.minecraftforge.event.level.SleepFinishedTimeEvent;
|
||||
import net.minecraftforge.event.network.ChannelRegistrationChangeEvent;
|
||||
import net.minecraftforge.event.network.ConnectionStartEvent;
|
||||
import net.minecraftforge.event.network.GatherLoginConfigurationTasksEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.Event.Result;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class ForgeEventFactory {
|
||||
private static final ModLoader ML = ModLoader.get();
|
||||
|
||||
private ForgeEventFactory() {}
|
||||
|
||||
/**
|
||||
* Post an event to the {@link MinecraftForge#EVENT_BUS}
|
||||
* @return true if the event is {@link Cancelable} and has been canceled
|
||||
*/
|
||||
private static boolean post(Event e) {
|
||||
return MinecraftForge.EVENT_BUS.post(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post an event to the {@link MinecraftForge#EVENT_BUS}, then return the event object
|
||||
* @return the event object passed in and possibly modified by listeners
|
||||
*/
|
||||
private static <E extends Event> E fire(E e) {
|
||||
post(e);
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post an event to the {@link ModLoader#get()} event bus
|
||||
*/
|
||||
private static <T extends Event & IModBusEvent> void postModBus(T e) {
|
||||
ModLoader.get().postEvent(e);
|
||||
ML.postEvent(e);
|
||||
}
|
||||
|
||||
public static boolean onMultiBlockPlace(@Nullable Entity entity, List<BlockSnapshot> blockSnapshots, Direction direction) {
|
||||
@@ -912,6 +929,10 @@ public final class ForgeEventFactory {
|
||||
post(new EntityEvent.EnteringSection(entity, packedOldPos, packedNewPos));
|
||||
}
|
||||
|
||||
public static boolean onLivingTick(LivingEntity entity) {
|
||||
return post(new LivingEvent.LivingTickEvent(entity));
|
||||
}
|
||||
|
||||
public static LivingFallEvent onLivingFall(LivingEntity entity, float distance, float damageMultiplier) {
|
||||
return fire(new LivingFallEvent(entity, distance, damageMultiplier));
|
||||
}
|
||||
@@ -928,6 +949,14 @@ public final class ForgeEventFactory {
|
||||
return fire(new LivingKnockBackEvent(target, strength, ratioX, ratioZ));
|
||||
}
|
||||
|
||||
public static boolean onLivingDeath(LivingEntity entity, DamageSource src) {
|
||||
return post(new LivingDeathEvent(entity, src));
|
||||
}
|
||||
|
||||
public static boolean onLivingDrops(LivingEntity entity, DamageSource source, Collection<ItemEntity> drops, int lootingLevel, boolean recentlyHit) {
|
||||
return post(new LivingDropsEvent(entity, source, drops, lootingLevel, recentlyHit));
|
||||
}
|
||||
|
||||
public static void onLeftClickEmpty(Player player) {
|
||||
post(new PlayerInteractEvent.LeftClickEmpty(player));
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ package net.minecraftforge.event.entity.living;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.world.entity.LivingEntity;
|
||||
* {@link Player#die(DamageSource)}, and
|
||||
* {@link ServerPlayer#die(DamageSource)}. <br>
|
||||
* <br>
|
||||
* This event is fired via the {@link ForgeHooks#onLivingDeath(LivingEntity, DamageSource)}.<br>
|
||||
* This event is fired via the {@link ForgeEventFactory#onLivingDeath(LivingEntity, DamageSource)}.<br>
|
||||
* <br>
|
||||
* {@link #source} contains the DamageSource that caused the entity to die. <br>
|
||||
* <br>
|
||||
|
||||
@@ -10,8 +10,8 @@ import java.util.Collection;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ import net.minecraftforge.eventbus.api.Cancelable;
|
||||
* This event is fired whenever an Entity dies and drops items in
|
||||
* {@link LivingEntity#die(DamageSource)}.<br>
|
||||
* <br>
|
||||
* This event is fired via the {@link ForgeHooks#onLivingDrops(LivingEntity, DamageSource, Collection, int, boolean)} .<br>
|
||||
* This event is fired via the {@link ForgeEventFactory#onLivingDrops(LivingEntity, DamageSource, Collection, int, boolean)} .<br>
|
||||
* <br>
|
||||
* {@link #source} contains the DamageSource that caused the drop to occur.<br>
|
||||
* {@link #drops} contains the ArrayList of EntityItems that will be dropped.<br>
|
||||
|
||||
@@ -8,6 +8,7 @@ package net.minecraftforge.event.entity.living;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
@@ -40,7 +41,7 @@ public class LivingEvent extends EntityEvent
|
||||
/**
|
||||
* LivingUpdateEvent is fired when a LivingEntity is ticked in {@link LivingEntity#tick()}. <br>
|
||||
* <br>
|
||||
* This event is fired via the {@link ForgeHooks#onLivingTick(LivingEntity)}.<br>
|
||||
* This event is fired via the {@link ForgeEventFactory#onLivingTick(LivingEntity)}.<br>
|
||||
* <br>
|
||||
* This event is {@link Cancelable}.<br>
|
||||
* If this event is canceled, the Entity does not update.<br>
|
||||
|
||||
@@ -399,4 +399,5 @@ public net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType <
|
||||
protected net.minecraft.world.level.portal.PortalForcer f_77648_ # level
|
||||
public net.minecraft.world.level.storage.LevelResource <init>(Ljava/lang/String;)V # constructor
|
||||
private-f net.minecraft.world.level.storage.loot.LootPool f_79028_ # rolls
|
||||
private-f net.minecraft.world.level.storage.loot.LootPool f_79029_ # bonusRolls
|
||||
private-f net.minecraft.world.level.storage.loot.LootPool f_79029_ # bonusRolls
|
||||
public net.minecraft.client.renderer.entity.layers.ElytraLayer f_116934_ # WINGS_LOCATION
|
||||
Reference in new issue
Block a user