Skip to content

Commit

Permalink
feat: port fabric side
Browse files Browse the repository at this point in the history
  • Loading branch information
bconlon1 committed Dec 21, 2024
1 parent 5f06b40 commit ad38e57
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21.1 2024-12-01T16:57:54.430361 Cumulus/Pack Metadata
df2cdb8ffc69d6ccce673baf9fbb986751dd2ff1 pack.mcmeta
// 1.21.3 2024-12-21T10:50:42.9270876 Cumulus/Pack Metadata
911e45306939be3e6c4f3bd08e4fcc229a142b33 pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21.1 2024-12-01T16:57:54.4293215 Cumulus/Language (en_us)
// 1.21.3 2024-12-21T10:50:42.9260874 Cumulus/Language (en_us)
b698ad6fb052eaa41b9335a7feb9bac53529c4db assets\cumulus_menus\lang\en_us.json
2 changes: 1 addition & 1 deletion fabric/src/main/generated/pack.mcmeta
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"description": {
"translate": "pack.cumulus_menus.mod.description"
},
"pack_format": 34
"pack_format": 42
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
import net.minecraft.world.entity.Entity;

public class WorldPreviewListener {
Expand Down Expand Up @@ -69,8 +70,8 @@ public static void onRenderPlayer(PlayerRenderer renderer, CancellableCallback c
* @see WorldPreviewHooks#shouldHideEntity(Entity)
* @see WorldPreviewHooks#adjustShadow(EntityRenderer, boolean)
*/
public static void onRenderEntity(Entity entity, EntityRenderer<?> renderer, CancellableCallback callback) {
boolean hide = WorldPreviewHooks.shouldHideEntity(entity);
public static void onRenderEntity(LivingEntityRenderState renderState, EntityRenderer<?, ?> renderer, float partialTick, CancellableCallback callback) {
boolean hide = WorldPreviewHooks.shouldHideEntity(renderer, renderState, partialTick);
if (hide) {
callback.setCanceled(true);
}
Expand All @@ -85,6 +86,6 @@ public static void initEvents() {
WorldRenderEvents.LAST.register(context -> onRenderLevelLast());
ClientTickEvents.END_CLIENT_TICK.register(client -> WorldPreviewListener.onClientTick());
PlayerRenderEvents.BEFORE_RENDER.register((player, renderer, partialTick, poseStack, multiBufferSource, packedLight, callback) -> WorldPreviewListener.onRenderPlayer(renderer, callback));
LivingEntityRenderEvents.BEFORE_RENDER.register((livingEntity, renderer, partialTick, poseStack, multiBufferSource, packedLight, callback) -> onRenderEntity(livingEntity, renderer, callback));
LivingEntityRenderEvents.BEFORE_RENDER.register((entityRenderState, renderer, partialTick, poseStack, multiBufferSource, packedLight, callback) -> onRenderEntity(entityRenderState, renderer, partialTick, callback));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
import net.minecraft.world.entity.LivingEntity;

public class LivingEntityRenderEvents {
public static final Event<PreMain> BEFORE_RENDER = EventFactory.createArrayBacked(PreMain.class, invokers -> (livingEntity, renderer, partialTick, poseStack, multiBufferSource, packedLight, callback) -> {
for (var invoker : invokers) invoker.beforeRendering(livingEntity, renderer, partialTick, poseStack, multiBufferSource, packedLight, callback);
public static final Event<PreMain> BEFORE_RENDER = EventFactory.createArrayBacked(PreMain.class, invokers -> (entityRenderState, renderer, partialTick, poseStack, multiBufferSource, packedLight, callback) -> {
for (var invoker : invokers) invoker.beforeRendering(entityRenderState, renderer, partialTick, poseStack, multiBufferSource, packedLight, callback);
});

public interface PreMain {
void beforeRendering(LivingEntity livingEntity, LivingEntityRenderer<LivingEntity, ? extends EntityModel<LivingEntity>> renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, CancellableCallback callback);
void beforeRendering(LivingEntityRenderState entityRenderState, LivingEntityRenderer<LivingEntity, ? extends LivingEntityRenderState, ? extends EntityModel<? super LivingEntityRenderState>> renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, CancellableCallback callback);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void addItemStack(Supplier<ItemStack> key, String name) {

@Override
public void add(ItemStack key, String name) {
builderInstance.add(key.getDescriptionId(), name);
builderInstance.add(key.getItem().getDescriptionId(), name);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,30 @@
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
import net.minecraft.world.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(LivingEntityRenderer.class)
public abstract class LivingEntityRendererMixin<T extends LivingEntity, M extends EntityModel<T>> extends EntityRenderer<T> {
public abstract class LivingEntityRendererMixin<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> extends EntityRenderer<T, S> {
protected LivingEntityRendererMixin(EntityRendererProvider.Context context) {
super(context);
}

@WrapMethod(method = "render(Lnet/minecraft/world/entity/LivingEntity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V")
private void render(T entity, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight, Operation<Void> original) {
@WrapMethod(method = "render(Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V")
private void render(S entityRenderState, PoseStack poseStack, MultiBufferSource buffer, int packedLight, Operation<Void> original) {
var callback = new CancellableCallbackImpl();

LivingEntityRenderEvents.BEFORE_RENDER.invoker().beforeRendering(entity, (LivingEntityRenderer<LivingEntity, ?>) (Object) this, partialTicks, poseStack, buffer, packedLight, callback);
LivingEntityRenderEvents.BEFORE_RENDER.invoker().beforeRendering(entityRenderState, (LivingEntityRenderer<LivingEntity, LivingEntityRenderState, ?>) (Object) this, Minecraft.getInstance().getDeltaTracker().getGameTimeDeltaPartialTick(true), poseStack, buffer, packedLight, callback);

if (callback.isCanceled()) return;

original.call(entity, entityYaw, partialTicks, poseStack, buffer, packedLight);
original.call(entityRenderState, poseStack, buffer, packedLight);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21.1 2024-10-25T14:43:36.3142406 Pack Metadata
df2cdb8ffc69d6ccce673baf9fbb986751dd2ff1 pack.mcmeta
// 1.21.3 2024-12-21T10:49:52.5635634 Pack Metadata
911e45306939be3e6c4f3bd08e4fcc229a142b33 pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21.1 2024-12-01T16:58:54.0269104 Languages: en_us for mod: cumulus_menus
// 1.21.3 2024-12-21T10:49:52.5145659 Languages: en_us for mod: cumulus_menus
b698ad6fb052eaa41b9335a7feb9bac53529c4db assets/cumulus_menus/lang/en_us.json
2 changes: 1 addition & 1 deletion neoforge/src/generated/resources/pack.mcmeta
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"description": {
"translate": "pack.cumulus_menus.mod.description"
},
"pack_format": 34
"pack_format": 42
}
}

0 comments on commit ad38e57

Please sign in to comment.