Skip to content

Commit

Permalink
Untested fix for interacting with certain things
Browse files Browse the repository at this point in the history
  • Loading branch information
Roadhog360 committed Oct 29, 2024
1 parent 257e3b2 commit 9d45b0b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
Expand All @@ -47,6 +51,7 @@ public enum Blocks {

THAUMCRAFT_ORE("Thaumcraft", "blockCustomOre"),
THAUMCRAFT_AIRY("Thaumcraft", "blockAiry"),
THAUMCRAFT_TABLE("Thaumcraft", "blockTable"),

BOP_GEM_ORE("BiomesOPlenty", "gemOre"),

Expand Down
16 changes: 15 additions & 1 deletion src/main/java/ganymedes01/etfuturum/spectator/SpectatorMode.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -23,18 +26,21 @@
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;
import net.minecraftforge.event.entity.player.*;
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<Block> SPECTATOR_INTERACT_BLACKLIST = Sets.newHashSet();
protected static final Map<EntityPlayer, Entity> 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!
Expand All @@ -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) {
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit 9d45b0b

Please sign in to comment.