Jump to content

[1.7.10] Hiding Living Entities


Draconwolver

Recommended Posts

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!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.