Skip to content

Commit

Permalink
port(1.21.4): Begin initial port to 21.4
Browse files Browse the repository at this point in the history
This is more or less a direct port of what existed to 21.4, fixing mixins
as appropriate. There are a few bugs that need to be looked into before
any real release:
- The options menu does not properly listen to mouse input
- Framerate limits are not yet implemented
- Probably a whole lot of other bugs
  • Loading branch information
FiniteReality committed Dec 5, 2024
1 parent f8240c7 commit d3a8135
Show file tree
Hide file tree
Showing 67 changed files with 401 additions and 677 deletions.
26 changes: 13 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx2G

kotlin.code.style=official

# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.21.1
parchment_version=2024.06.23-1.21
fabric_version=0.100.1+1.21
fabric_loader_version=0.15.11
minecraft_version=1.21.4
parchment_version=2024.11.17-1.21.1
fabric_version=0.110.5+1.21.4
fabric_loader_version=0.16.9

embeddium.fabric_mode=false

Expand All @@ -17,21 +17,21 @@ embeddium.fabric_mode=false
archives_base_name = embeddium


forge_version=21.1.61
forge_version=21.4.5-beta

codechicken_fileid=4382729
codechicken_fileid=5826640
ie_fileid=1.20.4-10.0.1-pre.163

base_mc_version_commit=0263cc2ffd33599aa90d5b226242035459e45ee7

use_phi=false
# find neoform version for your Minecraft version here: https://projects.neoforged.net/neoforged/neoform
neoform_version=20240605.103358
neoform_version=20241203.161809

asm_version=9.5
mixin_version=0.13.4+mixin.0.8.5
eventbus_version=7.2.0
mixin_extras_version=0.3.5
asm_version=9.7
mixin_version=0.15.2+mixin.0.8.7
eventbus_version=8.0.2
mixin_extras_version=0.4.1
apache_maven_artifact_version=3.8.5
spi_version=9.0.2
modlauncher_version=11.0.2
modlauncher_version=11.0.4
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public TestBlock() {
}

@Override
public VoxelShape getOcclusionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos) {
public VoxelShape getOcclusionShape(BlockState pState) {
return Shapes.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Difficulty;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.LevelSettings;
Expand Down Expand Up @@ -66,7 +67,7 @@ public class TestRegistry {

public static final DeferredHolder<Block, TestBlock> TEST_BLOCK = BLOCKS.register("test_block", TestBlock::new);
public static final DeferredHolder<Block, NotAnAirBlock> NOT_AN_AIR_BLOCK = BLOCKS.register("not_an_air_block", NotAnAirBlock::new);
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<?>> TEST_BLOCK_ENTITY = BLOCK_ENTITIES.register("test_block_entity", () -> BlockEntityType.Builder.of(TestBlockEntity::new, TEST_BLOCK.get()).build(null));
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<?>> TEST_BLOCK_ENTITY = BLOCK_ENTITIES.register("test_block_entity", () -> new BlockEntityType<>(TestBlockEntity::new, TEST_BLOCK.get()));

public static final ResourceLocation EMPTY_TEMPLATE = ResourceLocation.fromNamespaceAndPath(EmbeddiumConstants.MODID, "empty_structure");
public static final String EMPTY_TEMPLATE_STR = EMPTY_TEMPLATE.toString();
Expand All @@ -93,7 +94,7 @@ public static void registerPayloads(final RegisterPayloadHandlersEvent event) {

private static void registerModelForAllStates(ModelEvent.ModifyBakingResult event, Block block, BakedModel model) {
for(BlockState state : block.getStateDefinition().getPossibleStates()) {
event.getModels().put(BlockModelShaper.stateToModelLocation(state), model);
event.getBakingResult().blockStateModels().put(BlockModelShaper.stateToModelLocation(state), model);
}
}

Expand All @@ -102,8 +103,8 @@ private static void registerModelForAllStates(ModelEvent.ModifyBakingResult even
*/
@SubscribeEvent
public static void onBakingModify(ModelEvent.ModifyBakingResult event) {
registerModelForAllStates(event, TEST_BLOCK.get(), new TestModel(event.getModels().get(ModelBakery.MISSING_MODEL_VARIANT)));
registerModelForAllStates(event, NOT_AN_AIR_BLOCK.get(), new InstrumentingModelWrapper<>(event.getModels().get(BlockModelShaper.stateToModelLocation(Blocks.STONE.defaultBlockState()))));
registerModelForAllStates(event, TEST_BLOCK.get(), new TestModel(event.getBakingResult().missingModel()));
registerModelForAllStates(event, NOT_AN_AIR_BLOCK.get(), new InstrumentingModelWrapper<>(event.getBakingResult().blockStateModels().get(BlockModelShaper.stateToModelLocation(Blocks.STONE.defaultBlockState()))));
}

static class GameEvents {
Expand Down Expand Up @@ -132,9 +133,9 @@ public static void onScreenInit(ScreenEvent.Init.Post event) {
var messageScreen = new GenericMessageScreen(Component.literal("Bootstrapping gametests..."));
mc.forceSetScreen(messageScreen);
String levelName = "embeddium-test-" + UUID.randomUUID();
LevelSettings settings = new LevelSettings(levelName, GameType.CREATIVE, false, Difficulty.PEACEFUL, true, new GameRules(), WorldDataConfiguration.DEFAULT);
LevelSettings settings = new LevelSettings(levelName, GameType.CREATIVE, false, Difficulty.PEACEFUL, true, new GameRules(FeatureFlagSet.of()), WorldDataConfiguration.DEFAULT);
mc.createWorldOpenFlows().createFreshLevel(settings.levelName(), settings, new WorldOptions(1024, false, false), registry -> {
return registry.registryOrThrow(Registries.WORLD_PRESET).getHolderOrThrow(WorldPresets.FLAT).value().createWorldDimensions();
return registry.lookupOrThrow(Registries.WORLD_PRESET).getOrThrow(WorldPresets.FLAT).value().createWorldDimensions();
}, messageScreen);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.DelegateBakedModel;
import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.client.model.BakedModelWrapper;
import net.neoforged.neoforge.client.model.data.ModelData;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class InstrumentingModelWrapper<T extends BakedModel> extends BakedModelWrapper<T> {
public class InstrumentingModelWrapper<T extends BakedModel> extends DelegateBakedModel {
private volatile boolean hasBeenCalled;

public InstrumentingModelWrapper(T originalModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.DelegateBakedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.client.model.BakedModelWrapper;
import net.neoforged.neoforge.client.model.data.ModelData;
import net.neoforged.neoforge.client.model.data.ModelProperty;
import org.embeddedt.embeddium.impl.gametest.content.TestBlockEntity;
Expand All @@ -18,7 +18,7 @@
import java.util.List;
import java.util.Objects;

public class TestModel extends BakedModelWrapper<BakedModel> {
public class TestModel extends DelegateBakedModel {
public static final ModelProperty<Object> TEST_MODEL_PROPERTY = new ModelProperty<>();
public static final Object TEST_MODEL_VALUE = new Object();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.server.packs.metadata.MetadataSectionSerializer;
import net.minecraft.server.packs.metadata.MetadataSectionType;

import java.util.List;
Expand All @@ -18,6 +17,5 @@ public record SodiumResourcePackMetadata(List<String> ignoredShaders) {
.forGetter(SodiumResourcePackMetadata::ignoredShaders))
.apply(instance, SodiumResourcePackMetadata::new)
);
public static final MetadataSectionType<SodiumResourcePackMetadata> SERIALIZER =
MetadataSectionType.fromCodec("sodium", CODEC);
public static final MetadataSectionType<SodiumResourcePackMetadata> SERIALIZER = new MetadataSectionType<>("sodium", CODEC);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.platform.Window;
import net.minecraft.ChatFormatting;
import net.minecraft.server.level.ParticleStatus;
import net.neoforged.fml.ModList;
import net.neoforged.neoforge.common.NeoForgeConfig;
import org.embeddedt.embeddium.api.options.structure.OptionFlag;
Expand Down Expand Up @@ -31,11 +32,15 @@
import org.embeddedt.embeddium.impl.render.ShaderModBridge;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GLCapabilities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

public class EmbeddiumGameOptionPages {
private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddiumGameOptionPages.class);

private static final EmbeddiumOptionsStorage sodiumOpts = new EmbeddiumOptionsStorage();
private static final MinecraftOptionsStorage vanillaOpts = MinecraftOptionsStorage.INSTANCE;

Expand Down Expand Up @@ -127,7 +132,8 @@ public static OptionPage general() {
.setControl(option -> new SliderControl(option, 10, 260, 10, ControlValueFormatter.fpsLimit()))
.setBinding((opts, value) -> {
opts.framerateLimit().set(value);
Minecraft.getInstance().getWindow().setFramerateLimit(value);
LOGGER.warn("getWindow().setFramerateLimit(...) Not Yet Implemented");
//Minecraft.getInstance().getWindow().setFramerateLimit(value);
}, opts -> opts.framerateLimit().get())
.build())
.build());
Expand Down Expand Up @@ -191,7 +197,7 @@ public static OptionPage quality() {
if (Minecraft.useShaderTransparency()) {
RenderTarget framebuffer = Minecraft.getInstance().levelRenderer.getCloudsTarget();
if (framebuffer != null) {
framebuffer.clear(Minecraft.ON_OSX);
framebuffer.clear();
}
}
}, opts -> opts.cloudStatus().get())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.Multimap;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.Style;
import org.embeddedt.embeddium.impl.Embeddium;
Expand Down Expand Up @@ -299,17 +300,17 @@ public void renderBackground(GuiGraphics gfx, int mouseX, int mouseY, float part
super.renderBackground(gfx, mouseX, mouseY, partialTick);

// Render watermarks
gfx.setColor(ColorARGB.unpackRed(DefaultColors.ELEMENT_ACTIVATED) / 255f, ColorARGB.unpackGreen(DefaultColors.ELEMENT_ACTIVATED) / 255f, ColorARGB.unpackBlue(DefaultColors.ELEMENT_ACTIVATED) / 255f, 0.8F);
//gfx.setColor(ColorARGB.unpackRed(DefaultColors.ELEMENT_ACTIVATED) / 255f, ColorARGB.unpackGreen(DefaultColors.ELEMENT_ACTIVATED) / 255f, ColorARGB.unpackBlue(DefaultColors.ELEMENT_ACTIVATED) / 255f, 0.8F);
RenderSystem.disableDepthTest();
RenderSystem.depthMask(false);
RenderSystem.enableBlend();
RenderSystem.blendFunc(770, 1);
gfx.blit(LOGO_LOCATION, this.logoDim.x(), this.logoDim.y(), this.logoDim.width(), this.logoDim.height(), 0.0F, 0.0F, LOGO_SIZE, LOGO_SIZE, LOGO_SIZE, LOGO_SIZE);
gfx.blit(RenderType::guiTextured, LOGO_LOCATION, this.logoDim.x(), this.logoDim.y(), this.logoDim.width(), this.logoDim.height(), 0, 0, LOGO_SIZE, LOGO_SIZE, LOGO_SIZE, LOGO_SIZE);
RenderSystem.defaultBlendFunc();
RenderSystem.disableBlend();
RenderSystem.depthMask(true);
RenderSystem.enableDepthTest();
gfx.setColor(1.0F, 1.0F, 1.0F, 1.0F);
//gfx.setColor(1.0F, 1.0F, 1.0F, 1.0F);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void onChanged(String newText) {
}
}

Minecraft.getInstance().tell(() -> this.mainScreen.rebuildUI());
Minecraft.getInstance().schedule(() -> this.mainScreen.rebuildUI());
}

void erase(int offset) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.embeddedt.embeddium.impl.gui.frame.tab;

import com.mojang.blaze3d.platform.NativeImage;
import net.minecraft.client.renderer.RenderType;
import org.embeddedt.embeddium.impl.Embeddium;
import org.embeddedt.embeddium.impl.gui.widgets.FlatButtonWidget;
import org.embeddedt.embeddium.api.math.Dim2i;
Expand Down Expand Up @@ -81,6 +82,6 @@ public void render(GuiGraphics drawContext, int mouseX, int mouseY, float delta)
ResourceLocation icon = Objects.requireNonNullElse(this.logoTexture, FALLBACK_LOCATION);
int fontHeight = Minecraft.getInstance().font.lineHeight;
int imgY = this.dim.getCenterY() - (fontHeight / 2);
drawContext.blit(icon, this.dim.x() + 5, imgY, 0.0f, 0.0f, fontHeight, fontHeight, fontHeight, fontHeight);
drawContext.blit(RenderType::guiTextured, icon, this.dim.x() + 5, imgY, 0.0f, 0.0f, fontHeight, fontHeight, fontHeight, fontHeight);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void init() {
}

@Override
protected void renderBlurredBackground(float f) {
protected void renderBlurredBackground() {
// Disable the blur
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.embeddedt.embeddium.impl.mixin.core;

import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue;
import net.minecraft.util.profiling.Profiler;
import org.embeddedt.embeddium.impl.Embeddium;
import org.embeddedt.embeddium.impl.gui.screen.ConfigCorruptedScreen;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -41,7 +42,7 @@ private void postInit(GameConfig args, CallbackInfo ci) {
*/
@Inject(method = "runTick", at = @At("HEAD"))
private void preRender(boolean tick, CallbackInfo ci) {
ProfilerFiller profiler = Minecraft.getInstance().getProfiler();
ProfilerFiller profiler = Profiler.get();
profiler.push("wait_for_gpu");

while (this.fences.size() > Embeddium.options().advanced.cpuRenderAheadLimit) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.embeddedt.embeddium.impl.mixin.core.collections;

import com.google.common.collect.ImmutableList;
import net.minecraft.util.RandomSource;
import net.minecraft.util.random.WeightedEntry;
import net.minecraft.util.random.WeightedRandomList;
import org.embeddedt.embeddium.impl.util.collections.WeightedRandomListExtended;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;

import java.util.List;

@Mixin(WeightedRandomList.class)
public class WeightedRandomListMixin<E extends WeightedEntry> implements WeightedRandomListExtended<E> {
@Shadow
@Final
private ImmutableList<E> items;

@Shadow
@Final
private int totalWeight;

@Override
@Nullable
public E embeddium$getRandomItem(RandomSource random) {
return getAt(this.items, random.nextInt(this.totalWeight));
}

@Unique
private static <T extends WeightedEntry> T getAt(List<T> pool, int totalWeight) {
int i = 0;
int len = pool.size();
T weighted;
do {
if (i >= len) {
return null;
}

weighted = pool.get(i++);
totalWeight -= weighted.getWeight().asInt();
} while (totalWeight >= 0);
return weighted;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class SimpleBakedModelBuilderMixin {
@ModifyArg(method = { "addCulledFace", "addUnculledFace" }, at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", remap = false), require = 0)
private Object setVanillaShadingFlag(Object quad) {
BakedQuadView view = (BakedQuadView)quad;
view.setFlags(view.getFlags() | ModelQuadFlags.IS_VANILLA_SHADED);
view.addFlags(ModelQuadFlags.IS_VANILLA_SHADED);
return quad;
}
}

This file was deleted.

Loading

0 comments on commit d3a8135

Please sign in to comment.