Posted December 20, 201410 yr I was wondering how to hide a mob from the player (client-side). I don't mean giving it an invisibility effect, but I mean preventing the player from rendering it in the first place. I have some code below which is supposed to hide pigs when the player presses M, but doesn't do anything at all: [spoiler=Hidden]Main Class: package draconwolver.main; import net.minecraft.client.settings.KeyBinding; import org.lwjgl.input.Keyboard; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLPreInitializationEvent; @Mod(modid = Mod.ID, name = Mod.NAME, version = Mod.VERSION) public class Mod { public static final String ID = "mod"; public static final String NAME = "Mod"; public static final String VERSION = "1.7.10-1.0"; public static KeyBinding key; @EventHandler public static void PreLoad(FMLPreInitializationEvent PreEvent) { key = new KeyBinding("Mod", Keyboard.KEY_M, "key.categories.misc"); ClientRegistry.registerKeyBinding(key); FMLCommonHandler.instance().bus().register(new KeyInputHandler()); } } Event Class: package draconwolver.main; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.client.event.RenderLivingEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class KeyInputHandler { private static KeyBinding key = Mod.key; private static boolean bool = false; @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { if(key.isPressed()) bool = !bool; } @SubscribeEvent public void onRenderLiving(RenderLivingEvent.Pre event) { if(bool && event.entity instanceof EntityPig) { event.setCanceled(true); Minecraft.getMinecraft().thePlayer.sendChatMessage("It works!"); } } } All help is appreciated, thank you!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.