Merge 1.20 into 1.20.4
This commit is contained in:
commit
c8485eaef8
|
|
@ -91,11 +91,6 @@ public class DynamicBakedModelProvider implements Map<ResourceLocation, BakedMod
|
||||||
currentInstance = this;
|
currentInstance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMissingModel(BakedModel model) {
|
|
||||||
this.missingModel = model;
|
|
||||||
this.put(ModelBakery.MISSING_MODEL_LOCATION, this.missingModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ModelBakery.BakedCacheKey vanillaKey(Object o) {
|
private static ModelBakery.BakedCacheKey vanillaKey(Object o) {
|
||||||
return new ModelBakery.BakedCacheKey((ResourceLocation)o, BlockModelRotation.X0_Y0.getRotation(), false);
|
return new ModelBakery.BakedCacheKey((ResourceLocation)o, BlockModelRotation.X0_Y0.getRotation(), false);
|
||||||
}
|
}
|
||||||
|
|
@ -140,6 +135,14 @@ public class DynamicBakedModelProvider implements Map<ResourceLocation, BakedMod
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BakedModel getMissingModel() {
|
||||||
|
BakedModel m = missingModel;
|
||||||
|
if(m == null) {
|
||||||
|
m = missingModel = ((IExtendedModelBakery)bakery).bakeDefault(ModelBakery.MISSING_MODEL_LOCATION, BlockModelRotation.X0_Y0);
|
||||||
|
}
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BakedModel get(Object o) {
|
public BakedModel get(Object o) {
|
||||||
BakedModel model = permanentOverrides.getOrDefault(o, SENTINEL);
|
BakedModel model = permanentOverrides.getOrDefault(o, SENTINEL);
|
||||||
|
|
@ -148,14 +151,14 @@ public class DynamicBakedModelProvider implements Map<ResourceLocation, BakedMod
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
if(BAKE_SKIPPED_TOPLEVEL.contains((ResourceLocation)o))
|
if(BAKE_SKIPPED_TOPLEVEL.contains((ResourceLocation)o))
|
||||||
model = missingModel;
|
model = getMissingModel();
|
||||||
else
|
else
|
||||||
model = ((IExtendedModelBakery)bakery).bakeDefault((ResourceLocation)o, BlockModelRotation.X0_Y0);
|
model = ((IExtendedModelBakery)bakery).bakeDefault((ResourceLocation)o, BlockModelRotation.X0_Y0);
|
||||||
} catch(RuntimeException e) {
|
} catch(RuntimeException e) {
|
||||||
ModernFix.LOGGER.error("Exception baking {}: {}", o, e);
|
ModernFix.LOGGER.error("Exception baking {}: {}", o, e);
|
||||||
model = missingModel;
|
model = getMissingModel();
|
||||||
}
|
}
|
||||||
if(model == missingModel) {
|
if(model == getMissingModel()) {
|
||||||
// to correctly emulate the original map, we return null for missing models, unless they are top-level
|
// to correctly emulate the original map, we return null for missing models, unless they are top-level
|
||||||
model = isVanillaTopLevelModel((ResourceLocation)o) ? model : null;
|
model = isVanillaTopLevelModel((ResourceLocation)o) ? model : null;
|
||||||
permanentOverrides.put((ResourceLocation) o, model);
|
permanentOverrides.put((ResourceLocation) o, model);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package org.embeddedt.modernfix.forge.mixin.bugfix.entity_pose_stack;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||||
|
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(LivingEntityRenderer.class)
|
||||||
|
@ClientOnlyMixin
|
||||||
|
public class LivingEntityRendererMixin {
|
||||||
|
@Redirect(method = "render(Lnet/minecraft/world/entity/LivingEntity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/eventbus/api/IEventBus;post(Lnet/minecraftforge/eventbus/api/Event;)Z", ordinal = 0))
|
||||||
|
private boolean fireCheckingPoseStack(IEventBus instance, Event event) {
|
||||||
|
PoseStack stack = ((RenderLivingEvent)event).getPoseStack();
|
||||||
|
int size = ((PoseStackAccessor)stack).getPoseStack().size();
|
||||||
|
if (instance.post(event)) {
|
||||||
|
// Pop the stack if someone pushed it in the event
|
||||||
|
while (((PoseStackAccessor)stack).getPoseStack().size() > size) {
|
||||||
|
stack.popPose();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package org.embeddedt.modernfix.forge.mixin.bugfix.entity_pose_stack;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
||||||
|
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(PlayerRenderer.class)
|
||||||
|
@ClientOnlyMixin
|
||||||
|
public class PlayerRendererMixin {
|
||||||
|
@Redirect(method = "render(Lnet/minecraft/client/player/AbstractClientPlayer;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/eventbus/api/IEventBus;post(Lnet/minecraftforge/eventbus/api/Event;)Z", ordinal = 0))
|
||||||
|
private boolean fireCheckingPoseStack(IEventBus instance, Event event) {
|
||||||
|
PoseStack stack = ((RenderPlayerEvent)event).getPoseStack();
|
||||||
|
int size = ((PoseStackAccessor)stack).getPoseStack().size();
|
||||||
|
if (instance.post(event)) {
|
||||||
|
// Pop the stack if someone pushed it in the event
|
||||||
|
while (((PoseStackAccessor)stack).getPoseStack().size() > size) {
|
||||||
|
stack.popPose();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.embeddedt.modernfix.forge.mixin.bugfix.entity_pose_stack;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
import java.util.Deque;
|
||||||
|
|
||||||
|
@Mixin(PoseStack.class)
|
||||||
|
@ClientOnlyMixin
|
||||||
|
public interface PoseStackAccessor {
|
||||||
|
@Accessor
|
||||||
|
Deque<PoseStack.Pose> getPoseStack();
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package org.embeddedt.modernfix.forge.mixin.perf.forge_registry_alloc;
|
package org.embeddedt.modernfix.forge.mixin.perf.forge_registry_alloc;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
@ -14,9 +15,11 @@ import java.util.Map;
|
||||||
|
|
||||||
@Mixin(value = ForgeRegistry.class, remap = false)
|
@Mixin(value = ForgeRegistry.class, remap = false)
|
||||||
public abstract class ForgeRegistryMixin<V> {
|
public abstract class ForgeRegistryMixin<V> {
|
||||||
@Shadow @Final private Map<ResourceLocation, Holder.Reference<V>> delegatesByName;
|
// Replace the backing maps with fastutil maps for a bit more speed, since value->holder lookups in particular
|
||||||
|
// are a bottleneck in many areas (e.g. render type lookup)
|
||||||
|
@Shadow @Final private Map<ResourceLocation, Holder.Reference<V>> delegatesByName = new Object2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
@Shadow @Final private Map<V, Holder.Reference<V>> delegatesByValue;
|
@Shadow @Final private Map<V, Holder.Reference<V>> delegatesByValue = new Object2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author embeddedt
|
* @author embeddedt
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user