Skip to content

Commit

Permalink
Merge branch 'mc1.18/fabric/dev' into mc1.19/fabric/dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/resources/fabric.mod.json
  • Loading branch information
TropheusJ committed Apr 7, 2024
2 parents 0d63bb3 + 9e3e686 commit ac5db68
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 8 deletions.
1 change: 1 addition & 0 deletions FABRIC_CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Change logging starts below:
- fix basin tooltips not updating when removing fluid (#1411)
- fix outputs of draining recipes not being indexed (#1409)
- fix incorrect chances being shown on fan recipes (#1393)
- fix stress tooltips not being shown until entering singleplayer (#1265)
3 changes: 1 addition & 2 deletions src/main/java/com/simibubi/create/Create.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ public static void init() {
AllFluids.registerFluidInteractions();
// --

// fabric: registration not done yet, do it later
ServerLifecycleEvents.SERVER_STARTING.register(server -> AttachedRegistry.unwrapAll());
// fabric: AttachedRegistry.unwrapAll moved to RegistryMixin
AllAdvancements.register();
AllTriggers.register();
// });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,18 @@ public void emitBlockQuads(BlockAndTintGetter blockView, BlockState state, Block
}
}

// fabric: If it is the default state do not push transformations, will cause issues with GhostBlockRenderer
boolean shouldTransform = material != AllBlocks.COPYCAT_BASE.getDefaultState();

// fabric: need to change the default render material
context.pushTransform(MaterialFixer.create(material));
if (shouldTransform)
context.pushTransform(MaterialFixer.create(material));

emitBlockQuadsInner(blockView, state, pos, randomSupplier, context, material, cullFaceRemovalData, occlusionData);

// fabric: pop the material changer transform
context.popTransform();
if (shouldTransform)
context.popTransform();
}

protected abstract void emitBlockQuadsInner(BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier<RandomSource> randomSupplier, RenderContext context, BlockState material, CullFaceRemovalData cullFaceRemovalData, OcclusionData occlusionData);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.simibubi.create.foundation.mixin.fabric;

import java.util.concurrent.CompletableFuture;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

import net.minecraft.util.thread.BlockableEventLoop;

@Mixin(BlockableEventLoop.class)
public interface BlockableEventLoopAccessor {
@Invoker
CompletableFuture<Void> callSubmitAsync(Runnable task);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.simibubi.create.foundation.mixin.fabric;

import com.simibubi.create.foundation.utility.AttachedRegistry;

import net.minecraft.core.Registry;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Registry.class)
public class RegistryMixin {
@Inject(method = "freezeBuiltins", at = @At("TAIL"))
private static void unwrapAttached(CallbackInfo ci) {
AttachedRegistry.unwrapAll();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.simibubi.create.foundation.networking;

import java.util.concurrent.Executor;
import com.simibubi.create.foundation.mixin.fabric.BlockableEventLoopAccessor;

import org.jetbrains.annotations.Nullable;

Expand All @@ -15,6 +15,7 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.util.thread.BlockableEventLoop;

public abstract class SimplePacketBase implements C2SPacket, S2CPacket {

Expand Down Expand Up @@ -42,9 +43,16 @@ public enum NetworkDirection {
PLAY_TO_SERVER
}

public record Context(Executor exec, PacketListener listener, @Nullable ServerPlayer sender) {
public record Context(BlockableEventLoop<? extends Runnable> executor, PacketListener listener, @Nullable ServerPlayer sender) {
public void enqueueWork(Runnable runnable) {
exec().execute(runnable);
// Matches Forge's enqueueWork behavior.
// MC will sometimes defer tasks even if already on the right thread.
if (executor.isSameThread()) {
runnable.run();
} else {
// skip extra checks
((BlockableEventLoopAccessor) executor).callSubmitAsync(runnable);
}
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.jozufozu.flywheel.fabric.model.DefaultLayerFilteringBakedModel;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.content.decoration.copycat.CopycatModel;
import com.simibubi.create.foundation.placement.PlacementHelpers;
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/create.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"accessor.ServerLevelAccessor",
"accessor.SystemReportAccessor",
"fabric.AbstractMinecartMixin",
"fabric.BlockableEventLoopAccessor",
"fabric.EntityMixin",
"fabric.RegistryMixin",
"fabric.ServerGamePacketListenerImplAccessor",
"fabric.SortedArraySetAccessor",
"fabric.StructureUtilsMixin"
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@

"railways": "<1.5.3",
"create_interactive": "<=1.0.1-beta.2",
"create_jetpack": "<=3.4.1"
"create_jetpack": "<=3.4.1",
"garnished": "<=1.6.3",
"extendedbogeys": "<=0.4.5"
},

"custom": {
Expand Down

0 comments on commit ac5db68

Please sign in to comment.