Skip to content

Commit

Permalink
Port to 1.21.4 (#317)
Browse files Browse the repository at this point in the history
* Port to 1.21.4

* Return lod

* Return isBlockItem, update to rc3

* Remove transformation != null check

* Port neoforge part

* Update publish

* Maybe fix workflow

* Maybe fix workflow 2

* Maybe fix workflow 3

* 1.21.4
  • Loading branch information
1foxy2 authored Dec 3, 2024
1 parent e464d92 commit 0b77af7
Show file tree
Hide file tree
Showing 34 changed files with 577 additions and 573 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ jobs:
with:
files: neoforge/build/libs/!(*-@(dev|sources|api|javadoc)).jar
github-files: neoforge/build/libs/*-@(dev|sources|api|javadoc).jar
version-type: release
version-type: beta
game-versions: |
1.21.2
1.21.3
1.21.4
game-version-filter: releases
dependencies: |
cloth-config(required){modrinth:9s6osm5g}{curseforge:348521}#(ignore:github)
Expand Down Expand Up @@ -63,12 +62,10 @@ jobs:
github-files: fabric/build/libs/*-@(dev|sources|api|javadoc).jar
version-type: beta
game-versions: |
1.21.2
1.21.3
1.21.4
game-version-filter: releases
dependencies: |
cloth-config(required){modrinth:9s6osm5g}{curseforge:348521}#(ignore:github)
[email protected](incompatible){modrinth:AANobbMI}#(ignore:github)(ignore:curseforge)
modrinth-featured: true
modrinth-id: 51shyZVL
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
Expand Down
2 changes: 0 additions & 2 deletions buildSrc/src/main/groovy/multiloader-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ repositories {
filter {
includeGroup('org.parchmentmc.data')
includeGroup "maven.modrinth"
includeModule("net.neoforged", "testframework")
includeModule("net.neoforged", "neoforge")
}
}
maven { //AutoConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,10 @@ public interface BakedOpacity {
default boolean moreculling$canSetCullingShape() {
return false;
}

default boolean moreculling$isItem() {
return false;
}

default void moreculling$setIsItem() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,30 @@
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.Camera;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.renderer.entity.state.ItemFrameRenderState;
import net.minecraft.client.renderer.item.ItemStackRenderState;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Direction;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;

/**
* This interface allows you to call the MoreCulling methods used for item rendering.
* This gives you access to the custom MoreCulling rendering methods, in order to allow everyone to benefit from the
* performance boost that MoreCulling can offer.<br/>
* Use these methods over ones provided in {@link ItemRenderer}
* Use these methods over ones provided in {@link ItemStackRenderState}
*
* @since 0.8.0
*/

public interface ExtendedItemRenderer {
public interface ExtendedItemStackRenderState {

/**
* This will render a baked item model without a specific face. (Item Frame)
* This can be used to skip the face of an item that cannot be seen
*
* @since 0.25.0
*/
void moreculling$renderBakedItemModelWithoutFace(BakedModel model, ItemStack stack, int light, int overlay,
void moreculling$renderBakedItemModelWithoutFace(BakedModel model, int light, int overlay,
PoseStack poseStack, VertexConsumer vertices,
@Nullable Direction withoutFace);

Expand All @@ -38,7 +37,7 @@ public interface ExtendedItemRenderer {
*
* @since 0.25.0
*/
void moreculling$renderBakedItemModelForFace(BakedModel model, ItemStack stack, int light, int overlay,
void moreculling$renderBakedItemModelForFace(BakedModel model, int light, int overlay,
PoseStack poseStack, VertexConsumer vertices, Direction face);

/**
Expand All @@ -47,16 +46,17 @@ public interface ExtendedItemRenderer {
*
* @since 0.25.0
*/
void moreculling$renderBakedItemModelOnly3Faces(BakedModel model, ItemStack stack, int light, int overlay,
void moreculling$renderBakedItemModelOnly3Faces(BakedModel model, int light, int overlay,
PoseStack poseStack, VertexConsumer vertices,
Direction faceX, Direction faceY, Direction faceZ);


/**
* This will render an item as if it was in an item frame like MoreCulling, it will automatically include all of
* MoreCulling's optimizations.
*
* @since 0.25.0
*/
void moreculling$renderItemFrameItem(ItemStack stack, PoseStack poseStack, MultiBufferSource multiBufferSource,
void moreculling$renderItemFrameItem(PoseStack poseStack, MultiBufferSource multiBufferSource,
int light, ItemFrameRenderState frame, Camera camera);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.Model;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.SignRenderer;
import net.minecraft.client.renderer.blockentity.AbstractSignRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.StandingSignBlock;
Expand All @@ -23,7 +23,7 @@
import static ca.fxco.moreculling.utils.CullingUtils.shouldHideWallSignText;
import static ca.fxco.moreculling.utils.MathUtils.ONE_SIGN_ROTATION;

@Mixin(SignRenderer.class)
@Mixin(AbstractSignRenderer.class)
public class SignRenderer_textMixin {

@WrapWithCondition(
Expand All @@ -34,14 +34,14 @@ public class SignRenderer_textMixin {
"Lnet/minecraft/world/level/block/state/properties/WoodType;Lnet/minecraft/client/model/Model;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/blockentity/SignRenderer;renderSignText(" +
target = "Lnet/minecraft/client/renderer/blockentity/AbstractSignRenderer;renderSignText(" +
"Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/SignText;" +
"Lcom/mojang/blaze3d/vertex/PoseStack;" +
"Lnet/minecraft/client/renderer/MultiBufferSource;IIIZ)V",
ordinal = 0
)
)
private boolean moreculling$cullFrontSignText(SignRenderer renderer, BlockPos pos, SignText text,
private boolean moreculling$cullFrontSignText(AbstractSignRenderer renderer, BlockPos pos, SignText text,
PoseStack poseStack, MultiBufferSource mutliBufferSource,
int i, int j, int i2, boolean l,
@Local(argsOnly = true) BlockState state,
Expand All @@ -57,14 +57,14 @@ public class SignRenderer_textMixin {
"Lnet/minecraft/world/level/block/state/properties/WoodType;Lnet/minecraft/client/model/Model;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/blockentity/SignRenderer;renderSignText(" +
target = "Lnet/minecraft/client/renderer/blockentity/AbstractSignRenderer;renderSignText(" +
"Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/SignText;" +
"Lcom/mojang/blaze3d/vertex/PoseStack;" +
"Lnet/minecraft/client/renderer/MultiBufferSource;IIIZ)V",
ordinal = 1
)
)
private boolean moreculling$cullBackSignText(SignRenderer renderer, BlockPos pos, SignText text,
private boolean moreculling$cullBackSignText(AbstractSignRenderer renderer, BlockPos pos, SignText text,
PoseStack poseStack, MultiBufferSource mutliBufferSource,
int i, int j, int i2, boolean l,
@Local(argsOnly = true) BlockState state,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ca.fxco.moreculling.mixin.blocks.cullshape;

import ca.fxco.moreculling.api.block.MoreBlockCulling;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;

@Mixin(BaseTorchBlock.class)
public abstract class BaseTorchBlock_voxelMixin extends Block implements MoreBlockCulling {
@Unique
private static final VoxelShape moreculling$occlusionShape = Block.box(7.0, 0.0, 7.0, 9.0, 10.0, 9.0);

protected BaseTorchBlock_voxelMixin(Properties settings) {
super(settings);
}

@Override
public VoxelShape getOcclusionShape(BlockState state) {
return moreculling$occlusionShape;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ca.fxco.moreculling.MoreCulling;
import ca.fxco.moreculling.api.map.MapOpacity;
import ca.fxco.moreculling.api.renderers.ExtendedBlockModelRenderer;
import ca.fxco.moreculling.api.renderers.ExtendedItemRenderer;
import ca.fxco.moreculling.api.renderers.ExtendedItemStackRenderState;
import ca.fxco.moreculling.utils.CullingUtils;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
Expand All @@ -16,14 +16,13 @@
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.renderer.entity.state.ItemFrameRenderState;
import net.minecraft.client.renderer.item.ItemStackRenderState;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.MapItem;
import net.minecraft.world.level.saveddata.maps.MapId;
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
Expand All @@ -50,16 +49,14 @@ public abstract class ItemFrameRenderer_cullMixin<T extends ItemFrame> extends E
@Final
private BlockRenderDispatcher blockRenderer;

@Shadow
@Final
private ItemRenderer itemRenderer;
@Shadow @Final private MapRenderer mapRenderer;

@Shadow
protected abstract ModelResourceLocation getFrameModelResourceLoc(boolean isGlow, ItemStack stack);

@Shadow protected abstract int getLightVal(boolean par1, int par2, int par3);
private static ModelResourceLocation getFrameModelResourceLocation(ItemFrameRenderState itemFrameRenderState) {
return null;
}

@Shadow @Final private MapRenderer mapRenderer;
@Shadow protected abstract int getLightCoords(boolean bl, int i, int j);

protected ItemFrameRenderer_cullMixin(EntityRendererProvider.Context ctx) {
super(ctx);
Expand Down Expand Up @@ -107,9 +104,9 @@ protected ItemFrameRenderer_cullMixin(EntityRendererProvider.Context ctx) {

poseStack.mulPose(Axis.XP.rotationDegrees(xRot));
poseStack.mulPose(Axis.YP.rotationDegrees(yRot));
ItemStack itemStack = itemFrameState.itemStack;
ItemStackRenderState itemStackState = itemFrameState.item;
boolean skipFrontRender = false;
if (!itemStack.isEmpty()) {
if (!itemStackState.isEmpty()) {
poseStack.pushPose();
MapId mapIdComponent = itemFrameState.mapId;
if (mapIdComponent != null) {
Expand Down Expand Up @@ -137,24 +134,23 @@ protected ItemFrameRenderer_cullMixin(EntityRendererProvider.Context ctx) {
poseStack,
multiBufferSource,
true,
this.getLightVal(
this.getLightCoords(
itemFrameState.isGlowFrame,
LightTexture.FULL_SKY | 0xD2,
i
)
);
}
}
} else if (itemFrameState.itemModel != null) {
} else if (!itemStackState.isEmpty()) {
poseStack.translate(0.0, 0.0, itemFrameState.isInvisible ? 0.5 : 0.4375);
poseStack.mulPose(Axis.ZP.rotationDegrees(
(float) itemFrameState.rotation * 360.0f / 8.0f)
);
int l = this.getLightVal(itemFrameState.isGlowFrame, LightTexture.FULL_BRIGHT, i);
int l = this.getLightCoords(itemFrameState.isGlowFrame, LightTexture.FULL_BRIGHT, i);
poseStack.scale(0.5f, 0.5f, 0.5f);
// Use extended item renderer here
((ExtendedItemRenderer) this.itemRenderer).moreculling$renderItemFrameItem(
itemStack,
((ExtendedItemStackRenderState) itemStackState).moreculling$renderItemFrameItem(
poseStack,
multiBufferSource,
l,
Expand All @@ -166,7 +162,7 @@ protected ItemFrameRenderer_cullMixin(EntityRendererProvider.Context ctx) {
}
if (!itemFrameState.isInvisible) { // Render Item Frame block model
ModelManager modelManager = this.blockRenderer.getBlockModelShaper().getModelManager();
ModelResourceLocation modelResourceLocation = this.getFrameModelResourceLoc(itemFrameState.isGlowFrame, itemStack);
ModelResourceLocation modelResourceLocation = getFrameModelResourceLocation(itemFrameState);
poseStack.translate(-0.5, -0.5, -0.5);
var modelRenderer = (ExtendedBlockModelRenderer) this.blockRenderer.getModelRenderer();
if (CullingUtils.shouldCullBack(itemFrameState)) {
Expand Down

This file was deleted.

Loading

0 comments on commit 0b77af7

Please sign in to comment.