From 9d45b0bf07feed30d2dedebb0efae7dbdc7c044f Mon Sep 17 00:00:00 2001 From: roadhog360 Date: Tue, 29 Oct 2024 13:40:56 -0500 Subject: [PATCH] Untested fix for interacting with certain things --- .../etfuturum/compat/ExternalContent.java | 5 +++++ .../etfuturum/spectator/SpectatorMode.java | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/ganymedes01/etfuturum/compat/ExternalContent.java b/src/main/java/ganymedes01/etfuturum/compat/ExternalContent.java index 5fca982f..a32bd13c 100644 --- a/src/main/java/ganymedes01/etfuturum/compat/ExternalContent.java +++ b/src/main/java/ganymedes01/etfuturum/compat/ExternalContent.java @@ -10,6 +10,8 @@ public class ExternalContent { public enum Blocks { + GREGTECH_MACHINE("Gregtech", "gt.blockmachines"), + CFB_CAMPFIRE("campfirebackport", "campfire"), CFB_CAMPFIRE_BASE("campfirebackport", "campfire_base"), CFB_SOUL_CAMPFIRE("campfirebackport", "soul_campfire"), @@ -27,6 +29,8 @@ public enum Blocks { TCON_MULTIBRICK("TConstruct", "decoration.multibrick"), TCON_MULTIBRICK_FANCY("TConstruct", "decoration.multibrickfancy"), TCON_METAL("TConstruct", "MetalBlock"), + TCON_SMELTERY("TConstruct", "Smeltery"), + TCON_SEARED_BLOCK("TConstruct", "SearedBlock"), NATURA_HEAT_SAND("Natura", "heatsand"), NATURA_TAINTED_SOIL("Natura", "soil.tainted"), @@ -47,6 +51,7 @@ public enum Blocks { THAUMCRAFT_ORE("Thaumcraft", "blockCustomOre"), THAUMCRAFT_AIRY("Thaumcraft", "blockAiry"), + THAUMCRAFT_TABLE("Thaumcraft", "blockTable"), BOP_GEM_ORE("BiomesOPlenty", "gemOre"), diff --git a/src/main/java/ganymedes01/etfuturum/spectator/SpectatorMode.java b/src/main/java/ganymedes01/etfuturum/spectator/SpectatorMode.java index fd5e0af2..bc4ad692 100644 --- a/src/main/java/ganymedes01/etfuturum/spectator/SpectatorMode.java +++ b/src/main/java/ganymedes01/etfuturum/spectator/SpectatorMode.java @@ -1,13 +1,16 @@ package ganymedes01.etfuturum.spectator; +import com.google.common.collect.Sets; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.relauncher.Side; +import ganymedes01.etfuturum.compat.ExternalContent; import ganymedes01.etfuturum.configuration.configs.ConfigMixins; import ganymedes01.etfuturum.core.utils.helpers.SafeEnumHelperClient; import ganymedes01.etfuturum.entities.EntityNewBoatWithChest; +import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.resources.I18n; @@ -23,6 +26,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityEnderChest; +import net.minecraft.world.WorldServer; import net.minecraft.world.WorldSettings; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.entity.item.ItemTossEvent; @@ -30,11 +34,13 @@ import net.minecraftforge.event.world.BlockEvent; import java.util.Map; +import java.util.Set; import java.util.WeakHashMap; public class SpectatorMode { public static final SpectatorMode INSTANCE = new SpectatorMode(); public static final IEntitySelector EXCEPT_SPECTATING; + public static final Set SPECTATOR_INTERACT_BLACKLIST = Sets.newHashSet(); protected static final Map SPECTATING_ENTITIES = new WeakHashMap<>(); //TODO: DO NOT MAKE THIS A LAMBDA! INTELLIJ SUGGESTS IT BUT FOR SOME REASON IT CAUSES AN INITIALIZER EXCEPTION SPECIFICALLY IN THE LIVE GAME AND NOT IN DEV! @@ -55,8 +61,14 @@ protected SpectatorMode() { public static WorldSettings.GameType SPECTATOR_GAMETYPE = null; public static void init() { - if (ConfigMixins.enableSpectatorMode) + if (ConfigMixins.enableSpectatorMode) { SPECTATOR_GAMETYPE = SafeEnumHelperClient.addGameType("spectator", 3, "Spectator"); + } + + SPECTATOR_INTERACT_BLACKLIST.add(ExternalContent.Blocks.GREGTECH_MACHINE.get()); + SPECTATOR_INTERACT_BLACKLIST.add(ExternalContent.Blocks.TCON_SEARED_BLOCK.get()); + SPECTATOR_INTERACT_BLACKLIST.add(ExternalContent.Blocks.TCON_SMELTERY.get()); + SPECTATOR_INTERACT_BLACKLIST.add(ExternalContent.Blocks.THAUMCRAFT_TABLE.get()); } public static boolean isSpectator(EntityPlayer player) { @@ -83,6 +95,8 @@ public void onInteract(PlayerInteractEvent event) { TileEntity te = event.world.getTileEntity(event.x, event.y, event.z); if (!canSpectatorSelect(te)) { event.setCanceled(true); + } else if(SPECTATOR_INTERACT_BLACKLIST.contains(event.world.getBlock(event.x, event.y, event.z))) { + event.setCanceled(true); } } }