Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

DrOlive

Members
  • Posts

    44
  • Joined

  • Last visited

Everything posted by DrOlive

  1. I still don't understand how to make it so when a player receives the packet, it changes their mode to hidden
  2. The list of which players are hiding/ not hiding that the server keeps
  3. So where would I make the list, and where should I make the packet that gets sent to all the players? In one of my proxies?
  4. Well I decided I'm making a block that when you right click it, it changes the mode to hidden Block class: package drolive.nonametags; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.relauncher.Side; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.world.World; public class NoNameTagsHideBlock extends Block { public static int cancelPre = 0; public NoNameTagsHideBlock(int id){ super(id, Material.iron); setUnlocalizedName("hideBlock"); func_111022_d("nonametags.hideBlock"); setCreativeTab(CreativeTabs.tabBlock); } @Override public boolean onBlockActivated(World world, int bx, int by, int bz, EntityPlayer playerEntity, int unknown, float px, float py, float pz){ if(cancelPre == 0){ cancelPre = cancelPre + 1; } else if(cancelPre == 1){ cancelPre = cancelPre + 1; } else if(cancelPre == 2){ cancelPre = cancelPre - 2; } ByteArrayOutputStream bos = new ByteArrayOutputStream(4); DataOutputStream outputStream = new DataOutputStream(bos); try { outputStream.writeInt(cancelPre); } catch (Exception ex) { ex.printStackTrace(); } Packet250CustomPayload packet = new Packet250CustomPayload(); packet.channel = "NoNameTagsCancel"; packet.data = bos.toByteArray(); packet.length = bos.size(); Side side = FMLCommonHandler.instance().getEffectiveSide(); if(side == Side.SERVER){ EntityPlayerMP player = (EntityPlayerMP) playerEntity; PacketDispatcher.sendPacketToAllPlayers(packet); } else if(side == Side.CLIENT){ EntityClientPlayerMP player = (EntityClientPlayerMP) playerEntity; } else{ } return false; } } Main class(I didn't bother to take the key binding registries out): package drolive.nonametags; import java.util.EnumSet; import org.lwjgl.input.Keyboard; import net.minecraft.block.Block; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.TickType; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; @Mod(modid="NoNameTags", name="NoNameTags", version="0.0.1") @NetworkMod(clientSideRequired=true, serverSideRequired=false, channels = {"NoNameTagsCancel"}, packetHandler = PacketHandler.class) public class NoNameTags { public static final Block hideBlock = new NoNameTagsHideBlock(3500); @Instance("NoNameTags") public static NoNameTags instance; @SidedProxy(clientSide="drolive.nonametags.client.ClientProxy", serverSide="drolive.nonametags.CommonProxy") public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { GameRegistry.registerBlock(hideBlock, "hideBlock"); LanguageRegistry.addName(hideBlock, "Hide Block"); } @EventHandler public void load(FMLInitializationEvent event) { proxy.registerRenderers(); KeyBinding[] key = {new KeyBinding("Hide", Keyboard.KEY_H)}; boolean[] repeat = {false}; KeyBindingRegistry.registerKeyBinding(new NoNameTagsKeyBind(key, repeat)); MinecraftForge.EVENT_BUS.register(new NoNameTagsKeyBindHide()); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } Packet Handler class: package drolive.nonametags; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player; public class PacketHandler implements IPacketHandler { @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player){ if(packet.channel.equals("NoNameTagsCancel")){ handleCancelPre(packet); } } private void handleCancelPre(Packet250CustomPayload packet){ DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); int cancelPre; try{ cancelPre = inputStream.readInt(); } catch(IOException e){ e.printStackTrace(); return; } System.out.println("Cancel Pre = " + cancelPre); } } And here's the code for cancelling the event: @ForgeSubscribe(receiveCanceled=true) public void Pre(Specials.Pre event){ if(cancelPre == 1 || cancelPre == 2){ event.setCanceled(true); event.isCanceled(); }
  5. Ok so I'm new to packets (Never really needed them before) and I made it so it reads the int when I send it, but how do I make it cancel the event? I tried putting my cancel event in my packet handler, but it gave me the error, "void is an invalid type for the variable Pre". I'm making it so if the int cancelPre == 0, then it uncancels, and if it equals 1, it cancels.
  6. So do you think I could do it like the packet would send an int to everyone and depending on the int(0 or 1) it would change their "mode"?
  7. Ok thanks I'll do this later today
  8. Is there a way I could make it so if one player uses it, it cancels the event for all the players, including himself?
  9. I'll just have to work with it I guess
  10. I got the Pre event to cancel, but it just removes everyone else's name from the person who used it's view
  11. Does somebody know the event that renders your own nametag?
  12. Well I got it to cancel the event by using isCanceled(), but it turns out that cancelling Specials.Pre only makes everyone else's names disappear, not the player's who used the command... How would I make it so only the player's disappears from everyone else's view?
  13. I did just what you said but when I press the key in game, nothing happens, it wont even print a text. I also tried using it like this, but still no luck: if(NoNameTagsKeyBind.cancelPre == true && event.entity instanceof EntityPlayer) Is this where I'm supposed to put the code? package drolive.nonametags; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.src.ModLoader; import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.client.event.RenderLivingEvent.Specials; import net.minecraftforge.event.Event; import net.minecraftforge.event.ForgeSubscribe; public class NoNameTagsKeyBindHide { @ForgeSubscribe(receiveCanceled=true) public void Pre(Specials.Pre event){ if(event.entity instanceof EntityPlayer){ event.setCanceled(true); }
  14. Nevermind it doesn't stop repeating without makeItStop... Also I tried it in a LAN world and it said "You are now hiding!" but it didn't remove the name tag, know why? Main Class: package drolive.nonametags; import java.util.EnumSet; import org.lwjgl.input.Keyboard; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.TickType; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; @Mod(modid="NoNameTags", name="NoNameTags", version="0.0.1") @NetworkMod(clientSideRequired=false, serverSideRequired=false) public class NoNameTags { @Instance("NoNameTags") public static NoNameTags instance; @SidedProxy(clientSide="drolive.nonametags.client.ClientProxy", serverSide="drolive.nonametags.CommonProxy") public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { } @EventHandler public void load(FMLInitializationEvent event) { proxy.registerRenderers(); KeyBinding[] key = {new KeyBinding("Hide", Keyboard.KEY_H)}; boolean[] repeat = {false}; KeyBindingRegistry.registerKeyBinding(new NoNameTagsKeyBind(key, repeat)); MinecraftForge.EVENT_BUS.register(new NoNameTagsKeyBindHide()); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } Key Bind class: package drolive.nonametags; import java.util.EnumSet; import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.client.event.RenderLivingEvent.Specials; import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; import cpw.mods.fml.common.TickType; class NoNameTagsKeyBind extends KeyHandler { private EnumSet tickTypes = EnumSet.of(TickType.CLIENT); public static boolean cancelPre; public NoNameTagsKeyBind(KeyBinding[] keyBindings, boolean[] repeatings) { super(keyBindings, repeatings); } @Override public String getLabel() { return "Hide"; } @Override public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { if(tickEnd){ cancelPre = !cancelPre; } } @Override public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) { } @Override public EnumSet<TickType> ticks() { return tickTypes; } } KeyBindHide class: package drolive.nonametags; import net.minecraft.src.ModLoader; import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.client.event.RenderLivingEvent.Specials; import net.minecraftforge.event.Event; import net.minecraftforge.event.ForgeSubscribe; public class NoNameTagsKeyBindHide { public int makeItStop = 0; @ForgeSubscribe(receiveCanceled=true) public void Pre(Specials.Pre event){ if (NoNameTagsKeyBind.cancelPre == true && makeItStop == 1){ event.setCanceled(true); ModLoader.getMinecraftInstance().thePlayer.addChatMessage("You are now hiding!"); makeItStop = makeItStop - 1; } else if (NoNameTagsKeyBind.cancelPre == false && makeItStop == 0) { event.setCanceled(false); ModLoader.getMinecraftInstance().thePlayer.addChatMessage("You are not hiding!"); makeItStop = makeItStop + 1; } } }
  15. Yeah I know I just noticed that... can't believe I never realized it! And I also got it to stop repeating, thanks so much!
  16. Does anybody know why it's not working?
  17. I tried all this and it still repeats if I dont use makeItStop. And it still wont work in game.
  18. Yes I know I was just trying to make sense of what you said before. Is the problem that it's not constantly checking if cancelPre is true or false?
  19. Am I supposed to call the boolean in a different way?
  20. Yeah I registered the event and everything, but when I load a world it says "You are not hiding!" and it never says anything else no matter how many times I press h. I feel like my NoNameTagsKeyBindHide class isn't checking if cancelPre changes, but how would I do that? My main class: package drolive.nonametags; import java.util.EnumSet; import org.lwjgl.input.Keyboard; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.TickType; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; @Mod(modid="NoNameTags", name="NoNameTags", version="0.0.1") @NetworkMod(clientSideRequired=false, serverSideRequired=false) public class NoNameTags { @Instance("NoNameTags") public static NoNameTags instance; @SidedProxy(clientSide="drolive.nonametags.client.ClientProxy", serverSide="drolive.nonametags.CommonProxy") public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { } @EventHandler public void load(FMLInitializationEvent event) { proxy.registerRenderers(); KeyBinding[] key = {new KeyBinding("Hide", Keyboard.KEY_H)}; boolean[] repeat = {true}; KeyBindingRegistry.registerKeyBinding(new NoNameTagsKeyBind(key, repeat)); MinecraftForge.EVENT_BUS.register(new NoNameTagsKeyBindHide()); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } My keybind class: package drolive.nonametags; import java.util.EnumSet; import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.client.event.RenderLivingEvent.Specials; import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; import cpw.mods.fml.common.TickType; class NoNameTagsKeyBind extends KeyHandler { private EnumSet tickTypes = EnumSet.of(TickType.CLIENT); public static boolean cancelPre = false; public NoNameTagsKeyBind(KeyBinding[] keyBindings, boolean[] repeatings) { super(keyBindings, repeatings); } @Override public String getLabel() { return "Hide"; } @Override public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { cancelPre = (!cancelPre); } @Override public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) { } @Override public EnumSet<TickType> ticks() { return null; } } My keybind hide class: package drolive.nonametags; import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.client.event.RenderLivingEvent.Specials; import net.minecraftforge.event.Event; import net.minecraftforge.event.ForgeSubscribe; public class NoNameTagsKeyBindHide { public int makeItStop = 0; @ForgeSubscribe(receiveCanceled=true) public void Pre(Specials.Pre event){ if (NoNameTagsKeyBind.cancelPre == true && makeItStop == 1){ event.setCanceled(true); System.out.println("You are now hiding!"); makeItStop = makeItStop - 1; } else if (NoNameTagsKeyBind.cancelPre == false && makeItStop == 0) { event.setCanceled(false); System.out.println("You are not hiding!"); makeItStop = makeItStop + 1; } } } Note: I added the int makeItStop because before when I would load a world, it would spam the console with never ending "You are not hiding!"
  21. That should be mcp/src/minecraft/assets/mobdrops/textures/armor, but close enough Oh haha didn't even notice I did that
  22. This might be what you're looking for: http://www.minecraftforum.net/topic/1886370-forge16x-mazs-tutorials-working-custom-sounds-w-random-sound-from-soundpool-190713/
  23. You're sure your armour textures are in: mcp/src/assets/minecraft/mobdrops/textures/armor? Also all of those folders MUST be in lowercase!
  24. Oh and also here is my main class: package drolive.nonametags; import org.lwjgl.input.Keyboard; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.client.settings.KeyBinding; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; @Mod(modid="NoNameTags", name="NoNameTags", version="0.0.1") @NetworkMod(clientSideRequired=false, serverSideRequired=false) public class NoNameTags { @Instance("NoNameTags") public static NoNameTags instance; @SidedProxy(clientSide="drolive.nonametags.client.ClientProxy", serverSide="drolive.nonametags.CommonProxy") public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { } @EventHandler public void load(FMLInitializationEvent event) { proxy.registerRenderers(); KeyBinding[] key = {new KeyBinding("Hide", Keyboard.KEY_H)}; boolean[] repeat = {false}; KeyBindingRegistry.registerKeyBinding(new NoNameTagsKeyBind(key, repeat)); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.