Skip to content

Commit

Permalink
Merge branch '1.21.x' into 1.21-water-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TelepathicGrunt authored Nov 9, 2024
2 parents 0a9c0a0 + 424b600 commit 3c8d47a
Show file tree
Hide file tree
Showing 52 changed files with 782 additions and 247 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ org.gradle.debug=false

java_version=21

minecraft_version=1.21.2
neoform_version=20241022.151510
minecraft_version=1.21.3
neoform_version=20241023.131943
# on snapshot versions, used to prefix the version
neoforge_snapshot_next_stable=21.3
neoforge_snapshot_next_stable=21.4

mergetool_version=2.0.0
accesstransformers_version=10.0.1
accesstransformers_version=11.0.1
coremods_version=6.0.4
eventbus_version=8.0.2
modlauncher_version=11.0.4
Expand All @@ -30,7 +30,7 @@ jetbrains_annotations_version=24.0.1
slf4j_api_version=2.0.7
apache_maven_artifact_version=3.8.5
jarjar_version=0.4.1
fancy_mod_loader_version=4.0.29
fancy_mod_loader_version=5.0.1
mojang_logging_version=1.1.1
log4j_version=2.22.1
guava_version=31.1.2-jre
Expand Down
8 changes: 8 additions & 0 deletions patches/net/minecraft/client/KeyboardHandler.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
return;
}
}
@@ -507,6 +_,7 @@
}
}
}
+ net.neoforged.neoforge.client.ClientHooks.onKeyInput(p_90895_, p_90896_, p_90897_, p_90898_);
}
}

@@ -516,10 +_,20 @@
if (screen != null && this.minecraft.getOverlay() == null) {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/resources/model/ModelManager.java
+++ b/net/minecraft/client/resources/model/ModelManager.java
@@ -71,13 +_,14 @@
@@ -71,18 +_,20 @@
TextureAtlas.LOCATION_BLOCKS,
ResourceLocation.withDefaultNamespace("blocks")
);
Expand All @@ -16,6 +16,12 @@

public ModelManager(TextureManager p_119406_, BlockColors p_119407_, int p_119408_) {
this.blockColors = p_119407_;
this.maxMipmapLevels = p_119408_;
this.blockModelShaper = new BlockModelShaper(this);
+ Map<ResourceLocation, ResourceLocation> VANILLA_ATLASES = net.neoforged.neoforge.client.ClientHooks.gatherMaterialAtlases(ModelManager.VANILLA_ATLASES);
this.atlases = new AtlasSet(VANILLA_ATLASES, p_119406_);
}

@@ -102,6 +_,7 @@
public final CompletableFuture<Void> reload(
PreparableReloadListener.PreparationBarrier p_249079_, ResourceManager p_251134_, Executor p_250550_, Executor p_249221_
Expand Down
4 changes: 2 additions & 2 deletions patches/net/minecraft/util/datafix/DataFixers.java.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/util/datafix/DataFixers.java
+++ b/net/minecraft/util/datafix/DataFixers.java
@@ -1307,10 +_,35 @@
@@ -1308,10 +_,35 @@
Schema schema199 = p_14514_.addSchema(3800, SAME_NAMESPACED);
UnaryOperator<String> unaryoperator2 = createRenamer(Map.of("minecraft:scute", "minecraft:turtle_scute"));
p_14514_.addFixer(ItemRenameFix.create(schema199, "Rename scute item to turtle_scute", unaryoperator2));
Expand Down Expand Up @@ -36,7 +36,7 @@
Schema schema201 = p_14514_.addSchema(3807, V3807::new);
p_14514_.addFixer(new AddNewChoices(schema201, "Added Vault", References.BLOCK_ENTITY));
Schema schema202 = p_14514_.addSchema(3807, 1, SAME_NAMESPACED);
@@ -1333,6 +_,18 @@
@@ -1334,6 +_,18 @@
schema209, "Rename jump strength attribute", createRenamer("minecraft:horse.jump_strength", "minecraft:generic.jump_strength")
)
);
Expand Down
17 changes: 17 additions & 0 deletions patches/net/minecraft/world/effect/MobEffect.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@
public static final Codec<Holder<MobEffect>> CODEC = BuiltInRegistries.MOB_EFFECT.holderByNameCodec();
public static final StreamCodec<RegistryFriendlyByteBuf, Holder<MobEffect>> STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.MOB_EFFECT);
private static final int AMBIENT_ALPHA = Mth.floor(38.25F);
@@ -65,6 +_,16 @@
this.particleFactory = p_333515_ -> p_333716_;
}

+ /**
+ * Neo: Constructor that can take in the particle factory as a function of the {@link MobEffectInstance}.
+ * This should be used if the desired {@link ParticleOptions} depends on the presence of other registry entries.
+ */
+ protected MobEffect(MobEffectCategory category, int color, Function<MobEffectInstance, ParticleOptions> particleFactory) {
+ this.category = category;
+ this.color = color;
+ this.particleFactory = particleFactory;
+ }
+
public int getBlendDurationTicks() {
return this.blendDurationTicks;
}
@@ -133,6 +_,18 @@
return this;
}
Expand Down
9 changes: 0 additions & 9 deletions patches/net/minecraft/world/entity/LivingEntity.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -512,15 +512,6 @@
}

protected float getWaterSlowDown() {
@@ -2184,7 +_,7 @@
public void travel(Vec3 p_21280_) {
if (this.isControlledByLocalInstance()) {
FluidState fluidstate = this.level().getFluidState(this.blockPosition());
- if ((this.isInWater() || this.isInLava()) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) {
+ if ((this.isInWater() || (this.isInFluidType(fluidstate) && fluidstate.getFluidType() != net.neoforged.neoforge.common.NeoForgeMod.LAVA_TYPE.value())) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidstate)) {
this.travelInFluid(p_21280_);
} else if (this.isFallFlying()) {
this.travelFallFlying();
@@ -2196,7 +_,7 @@

private void travelInAir(Vec3 p_362457_) {
Expand Down
14 changes: 14 additions & 0 deletions patches/net/minecraft/world/item/crafting/RecipeManager.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- a/net/minecraft/world/item/crafting/RecipeManager.java
+++ b/net/minecraft/world/item/crafting/RecipeManager.java
@@ -260,6 +_,11 @@
: Optional.empty();
}

+ // Neo: expose recipe map
+ public RecipeMap recipeMap() {
+ return this.recipes;
+ }
+
public interface CachedCheck<I extends RecipeInput, T extends Recipe<I>> {
Optional<RecipeHolder<T>> getRecipeFor(I p_344938_, ServerLevel p_379487_);
}
26 changes: 24 additions & 2 deletions patches/net/minecraft/world/level/ServerExplosion.java.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -165,7 +_,12 @@
return new ObjectArrayList<>(set);
}

+ @Deprecated
private void hurtEntities() {
+ this.hurtEntities(List.of());
+ }
+
+ private void hurtEntities(List<BlockPos> blocks) {
float f = this.radius * 2.0F;
int i = Mth.floor(this.center.x - (double)f - 1.0);
int j = Mth.floor(this.center.x + (double)f + 1.0);
@@ -174,7 +_,9 @@
int i1 = Mth.floor(this.center.z - (double)f - 1.0);
int j1 = Mth.floor(this.center.z + (double)f + 1.0);

- for (Entity entity : this.level.getEntities(this.source, new AABB((double)i, (double)k, (double)i1, (double)j, (double)l, (double)j1))) {
+ List<Entity> list = this.level.getEntities(this.source, new AABB((double)i, (double)k, (double)i1, (double)j, (double)l, (double)j1));
+ net.neoforged.neoforge.event.EventHooks.onExplosionDetonate(this.level, this, list, f);
+ net.neoforged.neoforge.event.EventHooks.onExplosionDetonate(this.level, this, list, blocks);
+ for (Entity entity : list) {
if (!entity.ignoreExplosion(this)) {
double d0 = Math.sqrt(entity.distanceToSqr(this.center)) / (double)f;
Expand All @@ -15,7 +28,16 @@
d2 *= d6;
d3 *= d6;
Vec3 vec3 = new Vec3(d1, d2, d3);
+ vec3 = net.neoforged.neoforge.event.EventHooks.getExplosionKnockback(this.level, this, entity, vec3);
+ vec3 = net.neoforged.neoforge.event.EventHooks.getExplosionKnockback(this.level, this, entity, vec3, blocks);
entity.setDeltaMovement(entity.getDeltaMovement().add(vec3));
if (entity instanceof Player) {
Player player = (Player)entity;
@@ -246,7 +_,7 @@
public void explode() {
this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center);
List<BlockPos> list = this.calculateExplodedPositions();
- this.hurtEntities();
+ this.hurtEntities(list);
if (this.interactsWithBlocks()) {
ProfilerFiller profilerfiller = Profiler.get();
profilerfiller.push("explosion_blocks");
7 changes: 7 additions & 0 deletions src/main/java/net/neoforged/neoforge/client/ClientHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
import net.neoforged.neoforge.client.event.RegisterMaterialAtlasesEvent;
import net.neoforged.neoforge.client.event.RegisterParticleProvidersEvent;
import net.neoforged.neoforge.client.event.RegisterShadersEvent;
import net.neoforged.neoforge.client.event.RegisterSpriteSourceTypesEvent;
Expand Down Expand Up @@ -1094,4 +1095,10 @@ public static boolean isInTranslucentBlockOutlinePass(Level level, BlockPos pos,
ChunkRenderTypeSet renderTypes = model.getRenderTypes(state, OUTLINE_PASS_RANDOM, level.getModelData(pos));
return renderTypes.contains(RenderType.TRANSLUCENT) || renderTypes.contains(RenderType.TRIPWIRE);
}

public static Map<ResourceLocation, ResourceLocation> gatherMaterialAtlases(Map<ResourceLocation, ResourceLocation> vanillaAtlases) {
vanillaAtlases = new HashMap<>(vanillaAtlases);
ModLoader.postEvent(new RegisterMaterialAtlasesEvent(vanillaAtlases));
return Map.copyOf(vanillaAtlases);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) NeoForged and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/

package net.neoforged.neoforge.client.event;

import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.resources.TextureAtlasHolder;
import net.minecraft.client.resources.model.Material;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.resources.ResourceLocation;
import net.neoforged.bus.api.Event;
import net.neoforged.bus.api.ICancellableEvent;
import net.neoforged.fml.LogicalSide;
import net.neoforged.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;

/**
* Fired for registering {@linkplain TextureAtlas texture atlases} that will be used with {@link Material} or
* other systems which retrieve the atlas via {@link Minecraft#getTextureAtlas(ResourceLocation)} or
* {@link ModelManager#getAtlas(ResourceLocation)}.
* <p>
* If an atlas is registered via this event, then it must <b>NOT</b> be used through a {@link TextureAtlasHolder}.
* <p>
* This event fires during startup when the {@link ModelManager} is constructed.
* <p>
* This event is not {@linkplain ICancellableEvent cancellable}.
* <p>
* This event is fired on the mod-specific event bus, only on the {@linkplain LogicalSide#CLIENT logical client}.
*/
public class RegisterMaterialAtlasesEvent extends Event implements IModBusEvent {
private final Map<ResourceLocation, ResourceLocation> atlases;

@ApiStatus.Internal
public RegisterMaterialAtlasesEvent(Map<ResourceLocation, ResourceLocation> atlases) {
this.atlases = atlases;
}

/**
* Register a texture atlas with the given name and info location
*
* @param atlasLocation The name of the texture atlas
* @param atlasInfoLocation The location of the atlas info JSON relative to the {@code atlases} directory
*/
public void register(ResourceLocation atlasLocation, ResourceLocation atlasInfoLocation) {
ResourceLocation oldAtlasInfoLoc = this.atlases.putIfAbsent(atlasLocation, atlasInfoLocation);
if (oldAtlasInfoLoc != null) {
throw new IllegalStateException(String.format(
"Duplicate registration of atlas: %s (old info: %s, new info: %s)",
atlasLocation,
oldAtlasInfoLoc,
atlasInfoLocation));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ default void blitInscribed(ResourceLocation texture, int x, int y, int boundsWid
if (centerX) x += (w - boundsWidth) / 2;
}

self().blit(RenderType::guiTextured, texture, x, y, boundsWidth, boundsHeight, 0, 0, rectWidth, rectHeight, rectWidth, rectHeight);
self().blit(RenderType::guiTextured, texture, x, y, 0, 0, boundsWidth, boundsHeight, rectWidth, rectHeight, rectWidth, rectHeight);
}

// TODO: 1.20.2: do we need to fix these or can we just remove them?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Functio
if (!context.isComponentVisible(name, true))
continue;
var model = entry.getValue();
bakedPartsBuilder.put(name, model.bake(baker, spriteGetter, modelState));
bakedPartsBuilder.put(name, baker.bakeUncached(model, modelState, spriteGetter));
}
var bakedParts = bakedPartsBuilder.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Functio
BakedModel baked = new Baked(
context.useAmbientOcclusion(), context.isGui3d(), context.useBlockLight(),
spriteGetter.apply(context.getMaterial("particle")),
baseModel.bake(baker, spriteGetter, modelState),
ImmutableMap.copyOf(Maps.transformValues(perspectives, value -> value.bake(baker, spriteGetter, modelState))));
baker.bakeUncached(baseModel, modelState, spriteGetter),
ImmutableMap.copyOf(Maps.transformValues(perspectives, value -> baker.bakeUncached(value, modelState, spriteGetter))));
if (!overrides.isEmpty()) {
baked = new ItemModel.BakedModelWithOverrides(baked, new BakedOverrides(baker, overrides, spriteGetter));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ public <V extends Comparable<? super V>> ConfigValue<V> defineInRange(String pat
public <V extends Comparable<? super V>> ConfigValue<V> defineInRange(List<String> path, Supplier<V> defaultSupplier, V min, V max, Class<V> clazz) {
Range<V> range = new Range<>(clazz, min, max);
context.setRange(range);
comment("Range: " + range.toString());
comment(" Default: " + defaultSupplier.get());
comment(" Range: " + range);
return define(path, defaultSupplier, range);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.RegistryOps;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
Expand Down Expand Up @@ -63,7 +62,7 @@ public CompletableFuture<?> run(CachedOutput cache) {
return lookupProvider.thenCompose(provider -> {
gather(provider);

final DynamicOps<JsonElement> dynamicOps = RegistryOps.create(JsonOps.INSTANCE, provider);
final DynamicOps<JsonElement> dynamicOps = provider.createSerializationContext(JsonOps.INSTANCE);

return CompletableFuture.allOf(this.builders.entrySet().stream().map(entry -> {
DataMapType<?, ?> type = entry.getKey();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/neoforged/neoforge/event/EventHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ public static boolean onExplosionStart(Level level, ServerExplosion explosion) {
return NeoForge.EVENT_BUS.post(new ExplosionEvent.Start(level, explosion)).isCanceled();
}

public static void onExplosionDetonate(Level level, ServerExplosion explosion, List<Entity> list, double diameter) {
public static void onExplosionDetonate(Level level, ServerExplosion explosion, List<Entity> entities, List<BlockPos> blocks) {
//Filter entities to only those who are effected, to prevent modders from seeing more then will be hurt.
/* Enable this if we get issues with modders looping to much.
Iterator<Entity> itr = list.iterator();
Expand All @@ -600,7 +600,7 @@ public static void onExplosionDetonate(Level level, ServerExplosion explosion, L
if (e.isImmuneToExplosions() || dist > 1.0F) itr.remove();
}
*/
NeoForge.EVENT_BUS.post(new ExplosionEvent.Detonate(level, explosion, list));
NeoForge.EVENT_BUS.post(new ExplosionEvent.Detonate(level, explosion, entities, blocks));
}

/**
Expand All @@ -613,8 +613,8 @@ public static void onExplosionDetonate(Level level, ServerExplosion explosion, L
* @param initialVelocity The explosion calculated velocity for the entity
* @return The new explosion velocity to add to the entity's existing velocity
*/
public static Vec3 getExplosionKnockback(Level level, ServerExplosion explosion, Entity entity, Vec3 initialVelocity) {
ExplosionKnockbackEvent event = new ExplosionKnockbackEvent(level, explosion, entity, initialVelocity);
public static Vec3 getExplosionKnockback(Level level, ServerExplosion explosion, Entity entity, Vec3 initialVelocity, List<BlockPos> blocks) {
ExplosionKnockbackEvent event = new ExplosionKnockbackEvent(level, explosion, entity, initialVelocity, blocks);
NeoForge.EVENT_BUS.post(event);
return event.getKnockbackVelocity();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package net.neoforged.neoforge.event.level;

import java.util.List;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerExplosion;
Expand Down Expand Up @@ -63,17 +64,18 @@ public Start(Level level, ServerExplosion explosion) {
*/
public static class Detonate extends ExplosionEvent {
private final List<Entity> entityList;
private final List<BlockPos> blockList;

public Detonate(Level level, ServerExplosion explosion, List<Entity> entityList) {
public Detonate(Level level, ServerExplosion explosion, List<Entity> entityList, List<BlockPos> blockList) {
super(level, explosion);
this.entityList = entityList;
this.blockList = blockList;
}

/** return the list of blocks affected by the explosion. */
// FIXME porting: explosions changed a bit
/*public List<BlockPos> getAffectedBlocks() {
return getExplosion().getToBlow();
}*/
public List<BlockPos> getAffectedBlocks() {
return this.blockList;
}

/** return the list of entities affected by the explosion. */
public List<Entity> getAffectedEntities() {
Expand Down
Loading

0 comments on commit 3c8d47a

Please sign in to comment.