Skip to content

Commit

Permalink
fix: more anti-schizo issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Nov 30, 2024
1 parent 5ef4b4a commit 971f7f7
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 28 deletions.
15 changes: 15 additions & 0 deletions src/main/java/gregtechfoodoption/GTFOEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public void onRender(RenderGameOverlayEvent event) {
}
}



@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
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;
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;
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<NetworkPlayerInfo> 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<NetworkPlayerInfo> 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;
});
}
}

This file was deleted.

3 changes: 1 addition & 2 deletions src/main/resources/mixins.gregtechfoodoption.early.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"compatibilityLevel": "JAVA_8",
"mixins": [],
"client": [
"GuiPlayerTabOverlayMixin",
"RenderManagerMixin"
"GuiPlayerTabOverlayMixin"
],
"server": []
}

0 comments on commit 971f7f7

Please sign in to comment.