Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.