Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fake level for JEI #10304

Open
wants to merge 6 commits into
base: version/main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mappingsVersion=1.20.1

dataGeneratorsVersion=1.19.3-0.1.54-ALPHA
blockUI_version=1.20.1-1.0.139-BETA
structurize_version=1.20.1-1.0.740-BETA
structurize_version=1.20.1-1.0.759-snapshot
domumOrnamentumVersion=1.20.1-1.0.184-BETA
multiPistonVersion=1.20-1.2.30-ALPHA

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public static List<Animal> createAnimals(@NotNull final Level level)
final Entity entity = entityType.create(level);
if (entity instanceof Animal animal)
{
animal.setLevel(null);
animals.add(animal);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,11 @@ public void draw(@NotNull final IGenericRecipe recipe,
final float yaw = animalTimer.getValue();
final float headYaw = (float) Math.atan((animal_cx - mouseX) / 40.0F) * 40.0F + yaw;
final float pitch = (float) Math.atan((animal_cy - offsetY - mouseY) / 40.0F) * 20.0F;
animal.setLevel(FAKE_LEVEL);
Lighting.setupForFlatItems();
UiRenderMacros.drawEntity(stack.pose(), animal_cx, animal_by - offsetY, scale, headYaw, yaw, pitch, animal);
Lighting.setupFor3DItems();
animal.setLevel(null);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.minecolonies.core.compatibility.jei;

import com.ldtteam.structurize.client.fakelevel.SingleBlockFakeLevel;
import net.minecraft.client.Minecraft;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why onlyin? dont think we should use that in 1.21

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paranoia, mostly. Since it's using client-only classes it must not be loaded in the server jar. Though that should be the case even without this, it seems safer to make it explicit.

public class JeiFakeLevel extends SingleBlockFakeLevel
{
public JeiFakeLevel()
{
super(null);
prepare(Blocks.AIR.defaultBlockState(), null, null);
}

@Override
public Level realLevel()
{
return Minecraft.getInstance().level;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
*/
public abstract class JobBasedRecipeCategory<T> implements IRecipeCategory<T>
{
protected static final JeiFakeLevel FAKE_LEVEL = new JeiFakeLevel();
protected static final ResourceLocation TEXTURE = new ResourceLocation(Constants.MOD_ID, "textures/gui/jei_recipe.png");
@NotNull protected final IJob<?> job;
@NotNull private final RecipeType<T> type;
Expand Down Expand Up @@ -300,7 +301,7 @@ public InfoBlock(final String text, final String tip, final Rect2i bounds)
@NotNull
private static EntityCitizen createCitizenWithJob(@NotNull final IJob<?> job)
{
final EntityCitizen citizen = new EntityCitizen(ModEntities.CITIZEN, Minecraft.getInstance().level);
final EntityCitizen citizen = new EntityCitizen(ModEntities.CITIZEN, FAKE_LEVEL);
citizen.setFemale(citizen.getRandom().nextBoolean());
citizen.setTextureId(citizen.getRandom().nextInt(255));
citizen.getEntityData().set(EntityCitizen.DATA_TEXTURE_SUFFIX, CitizenData.SUFFIXES.get(citizen.getRandom().nextInt(CitizenData.SUFFIXES.size())));
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public net.minecraft.client.multiplayer.ClientAdvancements f_104390_ # advanceme
public net.minecraft.world.level.block.DoorBlock m_245755_(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Z)V # playSound

public net.minecraft.world.entity.Entity f_19816_ # eyeHeight
public net.minecraft.world.entity.Entity m_284535_(Lnet/minecraft/world/level/Level;)V # setLevel
Nightenom marked this conversation as resolved.
Show resolved Hide resolved

# vbo draw
public com.mojang.blaze3d.vertex.BufferUploader m_85763_(Ljava/nio/ByteBuffer;ILcom/mojang/blaze3d/vertex/VertexFormat;I)V # draw
Expand Down