update to latest MCEF, fix a potential rendering crash for the event that MCEF doesn't initalize properly

This commit is contained in:
GiantLuigi4 2023-10-19 00:21:03 -04:00
parent 92d5da727e
commit 2a2d3077f4
4 changed files with 17 additions and 18 deletions

View File

@ -73,6 +73,7 @@ repositories{
}
flatDir { dirs 'libs' }
maven { url 'https://mcef-download.cinemamod.com/repository/releases' }
maven { url = uri('https://mcef-download.cinemamod.com/repositories/releases') }
}
dependencies {
@ -83,10 +84,14 @@ dependencies {
// implementation fg.deobf("curse.maven:SU-370704:4485052")
// implementation fg.deobf("curse.maven:spark-361579:4381167")
implementation fg.deobf("flatdir.lib:mcef:2.x")
// implementation fg.deobf("flatdir.lib:mcef:2.x")
// implementation fg.deobf("flatdir.lib:smallerunits:2.1.3")
// compileOnly fg.deobf("curse.maven:vivecraft-667903:4409427")
implementation fg.deobf("com.cinemamod:mcef-forge:2.0.1-1.20.1") {
transitive = false
}
}
sourceSets {

View File

@ -4,6 +4,7 @@
package net.montoyo.wd;
import com.cinemamod.mcef.MCEF;
import com.mojang.authlib.GameProfile;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceKey;
@ -30,21 +31,20 @@ public class SharedProxy {
}
public void init() {
// MinecraftForge.EVENT_BUS.addListener(this::onCefInit);
onCefInit();
MCEF.scheduleForInit((cef) -> onCefInit());
}
public void postInit() {
}
public void onCefInit(/*CefInitEvent event*/) {
}
@Deprecated(forRemoval = true)
public Level getWorld(ResourceKey<Level> dim) {
return getServer().getLevel(dim);
}
public BlockGetter getWorld(NetworkEvent.Context context) {
if (context.getSender() != null) return context.getSender().level();
return null;

View File

@ -108,11 +108,6 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
INSTANCE = this;
}
// public static void blit(PoseStack p_93229_, int p_93230_, int p_93231_, int p_93232_, int p_93233_, int p_93234_, int p_93235_, int offset) {
// Gui.blit(p_93229_, p_93230_, p_93231_, offset, (float) p_93232_, (float) p_93233_, p_93234_, p_93235_, 256, 256);
// }
// public static void renderCrosshair(Options options, int screenWidth, int screenHeight, int offset, PoseStack poseStack, CallbackInfo ci) {
public static void renderCrosshair(Options options, int screenWidth, int screenHeight, int offset, GuiGraphics poseStack, CallbackInfo ci) {
ItemStack stack = Minecraft.getInstance().player.getItemInHand(InteractionHand.MAIN_HAND);
ItemStack stack1 = Minecraft.getInstance().player.getItemInHand(InteractionHand.OFF_HAND);
@ -263,6 +258,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
public void preInit() {
super.preInit();
mc = Minecraft.getInstance();
MinecraftForge.EVENT_BUS.register(this);
}
@Override
@ -272,7 +268,8 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
@Override
public void onCefInit(/*CefInitEvent event*/) {
MinecraftForge.EVENT_BUS.register(this);
minePadRenderer = new MinePadRenderer();
laserPointerRenderer = new LaserPointerRenderer();
if (!MCEF.isInitialized()) return;
@ -285,11 +282,9 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
);
// jsDispatcher = new JSQueryDispatcher(this);
minePadRenderer = new MinePadRenderer();
laserPointerRenderer = new LaserPointerRenderer();
MCEF.getClient().addDisplayHandler(this);
// mcef.registerJSQueryHandler(this);
findAdvancementToProgressField();
}

View File

@ -6,7 +6,7 @@ package net.montoyo.wd.entity;
import com.cinemamod.mcef.MCEF;
import com.cinemamod.mcef.MCEFBrowser;
import com.cinemamod.mcef.MCEFCursorChangeListener;
import com.cinemamod.mcef.listeners.MCEFCursorChangeListener;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
@ -20,7 +20,6 @@ import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;