From 971f7f7b10cc773db78fb1184a086d785bd214ea Mon Sep 17 00:00:00 2001 From: bruberu <80226372+bruberu@users.noreply.github.com> Date: Fri, 29 Nov 2024 19:43:45 -0600 Subject: [PATCH] fix: more anti-schizo issues --- .../gregtechfoodoption/GTFOEventHandler.java | 15 ++++++++++++ .../appleskin/GTFOAppleCoreIsolation.java | 14 +++++++++++ .../appleskin/GTFOMetaHUDOverlay.java | 2 ++ .../early/GuiPlayerTabOverlayMixin.java | 18 ++++++++++++--- .../mixins/early/RenderManagerMixin.java | 23 ------------------- .../mixins.gregtechfoodoption.early.json | 3 +-- 6 files changed, 47 insertions(+), 28 deletions(-) create mode 100644 src/main/java/gregtechfoodoption/integration/appleskin/GTFOAppleCoreIsolation.java delete mode 100644 src/main/java/gregtechfoodoption/mixins/early/RenderManagerMixin.java diff --git a/src/main/java/gregtechfoodoption/GTFOEventHandler.java b/src/main/java/gregtechfoodoption/GTFOEventHandler.java index cb58abf4..8c4e1a40 100644 --- a/src/main/java/gregtechfoodoption/GTFOEventHandler.java +++ b/src/main/java/gregtechfoodoption/GTFOEventHandler.java @@ -13,6 +13,7 @@ import gregtechfoodoption.network.PacketAppleCoreFoodDivisorUpdate; import gregtechfoodoption.potion.*; import gregtechfoodoption.utils.GTFODamageSources; +import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntitySnowman; import net.minecraft.entity.player.EntityPlayer; @@ -29,6 +30,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.WorldServer; +import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.living.PotionColorCalculationEvent; @@ -41,6 +43,8 @@ import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import java.util.HashMap; import java.util.HashSet; @@ -262,4 +266,15 @@ public static void handleBerryGrowth(BlockEvent.CropGrowEvent.Pre event) { event.setResult(GTValues.RNG.nextInt(bush.getGrowthSlowdown(event.getWorld(), event.getPos(), event.getState())) == 0 ? Event.Result.ALLOW : Event.Result.DENY); } } + + @SubscribeEvent + @SideOnly(Side.CLIENT) + public static void handlePlayerRender(RenderPlayerEvent.Pre event) { + EntityPlayer player = event.getEntityPlayer(); + + if (!player.isUser() && Minecraft.getMinecraft().player.isPotionActive(AntiSchizoPotion.INSTANCE)) { + event.setCanceled(true); + Minecraft.getMinecraft().getRenderManager().setRenderShadow(false); + } + } } \ No newline at end of file diff --git a/src/main/java/gregtechfoodoption/integration/appleskin/GTFOAppleCoreIsolation.java b/src/main/java/gregtechfoodoption/integration/appleskin/GTFOAppleCoreIsolation.java new file mode 100644 index 00000000..ad635d93 --- /dev/null +++ b/src/main/java/gregtechfoodoption/integration/appleskin/GTFOAppleCoreIsolation.java @@ -0,0 +1,14 @@ +package gregtechfoodoption.integration.appleskin; + +import net.minecraft.item.ItemStack; +import squeek.appleskin.helpers.FoodHelper; + +public class GTFOAppleCoreIsolation { + public static boolean isFood(ItemStack stackInHand) { + return GTFOMetaFoodHelper.isFood(stackInHand); + } + + public static FoodHelper.BasicFoodValues getDefaultFoodValues(ItemStack stackInHand) { + return GTFOMetaFoodHelper.getDefaultFoodValues(stackInHand); + } +} diff --git a/src/main/java/gregtechfoodoption/integration/appleskin/GTFOMetaHUDOverlay.java b/src/main/java/gregtechfoodoption/integration/appleskin/GTFOMetaHUDOverlay.java index 06bc54f9..cd0a71c4 100644 --- a/src/main/java/gregtechfoodoption/integration/appleskin/GTFOMetaHUDOverlay.java +++ b/src/main/java/gregtechfoodoption/integration/appleskin/GTFOMetaHUDOverlay.java @@ -85,6 +85,8 @@ public void onRender(RenderGameOverlayEvent event) { } } + + @SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent event) { diff --git a/src/main/java/gregtechfoodoption/mixins/early/GuiPlayerTabOverlayMixin.java b/src/main/java/gregtechfoodoption/mixins/early/GuiPlayerTabOverlayMixin.java index 2e6b1dc1..9e63518d 100644 --- a/src/main/java/gregtechfoodoption/mixins/early/GuiPlayerTabOverlayMixin.java +++ b/src/main/java/gregtechfoodoption/mixins/early/GuiPlayerTabOverlayMixin.java @@ -1,8 +1,11 @@ package gregtechfoodoption.mixins.early; import com.llamalad7.mixinextras.sugar.Local; +import gregtechfoodoption.potion.AntiSchizoPotion; +import gregtechfoodoption.utils.GTFOLog; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiPlayerTabOverlay; +import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.Scoreboard; @@ -10,13 +13,22 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.util.List; @Mixin(value = GuiPlayerTabOverlay.class, priority = 500, remap = false) public class GuiPlayerTabOverlayMixin { - @Inject(method = "renderPlayerlist", at = @At(value = "INVOKE_ASSIGN", target = "Lcom/google/common/collect/Ordering;sortedCopy(Ljava/lang/Iterable;)Ljava/util/List;")) - public void youAreAllAlone(int width, Scoreboard scoreboardIn, ScoreObjective scoreObjectiveIn, CallbackInfo ci, @Local List list) { - list.removeIf(playerInfo -> !playerInfo.getGameProfile().getId().equals(Minecraft.getMinecraft().player.getPersistentID())); + @Inject(method = "renderPlayerlist", at = @At(value = "INVOKE_ASSIGN", target = "Lcom/google/common/collect/Ordering;sortedCopy(Ljava/lang/Iterable;)Ljava/util/List;"), locals = LocalCapture.CAPTURE_FAILHARD) + public void youAreAllAlone(int width, Scoreboard scoreboardIn, ScoreObjective scoreObjectiveIn, CallbackInfo ci, NetHandlerPlayClient nethandlerplayclient, @Local List list) { + if (!Minecraft.getMinecraft().player.isPotionActive(AntiSchizoPotion.INSTANCE)) { + return; + } + list.removeIf(playerInfo -> { + if (!playerInfo.getGameProfile().getName().equals(Minecraft.getMinecraft().player.getName())) { + return true; + } + return false; + }); } } diff --git a/src/main/java/gregtechfoodoption/mixins/early/RenderManagerMixin.java b/src/main/java/gregtechfoodoption/mixins/early/RenderManagerMixin.java deleted file mode 100644 index 9150f049..00000000 --- a/src/main/java/gregtechfoodoption/mixins/early/RenderManagerMixin.java +++ /dev/null @@ -1,23 +0,0 @@ -package gregtechfoodoption.mixins.early; - -import gregtechfoodoption.potion.AntiSchizoPotion; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.passive.EntityPig; -import net.minecraft.entity.player.EntityPlayer; -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(value = RenderManager.class, priority = 500, remap = false) -public class RenderManagerMixin { - @Inject(method = "renderEntity", at = @At("HEAD"), cancellable = true) - public void removePlayerRender(Entity entityIn, double x, double y, double z, float yaw, float partialTicks, boolean mojangBrainFart, CallbackInfo ci) { - EntityPlayer player = Minecraft.getMinecraft().player; - if (player != null && player.isPotionActive(AntiSchizoPotion.INSTANCE) && entityIn instanceof EntityPlayer && !entityIn.isEntityEqual(player)) { - ci.cancel(); - } - } -} diff --git a/src/main/resources/mixins.gregtechfoodoption.early.json b/src/main/resources/mixins.gregtechfoodoption.early.json index 37fb5961..58ab0411 100644 --- a/src/main/resources/mixins.gregtechfoodoption.early.json +++ b/src/main/resources/mixins.gregtechfoodoption.early.json @@ -6,8 +6,7 @@ "compatibilityLevel": "JAVA_8", "mixins": [], "client": [ - "GuiPlayerTabOverlayMixin", - "RenderManagerMixin" + "GuiPlayerTabOverlayMixin" ], "server": [] }