Jump to content

AnalogWeapon

Members
  • Posts

    3
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

AnalogWeapon's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. That's what's sort of funny: I had that article bookmarked, and after talking here, I went back to it and dove in. It wasn't until I was pretty far through it that I realized coolAlias was the author. Haha. Now that I'm starting to get IExtendedEntityProperties going, I can see that it's definitely the best way to go for what I'm working on.
  2. Thanks so much for your time and help. I will explore IExtendedEntityProperties more. That is something I came across in my searching as a possible area to explore. I didn't show enough of my code in regard to the preInit() method. In my main mod class, I have: @SidedProxy(clientSide="net.analogweapon.donotwant.ClientOnlyProxy", serverSide="net.analogweapon.donotwant.DedicatedServerProxy") public static CommonProxy proxy; And that preInit() method is in ClientOnlyProxy.class: public class ClientOnlyProxy extends CommonProxy { public void preInit() { super.preInit(); DoNotWant.instance.unwanted = new Unwanted(); MinecraftForge.EVENT_BUS.register(new EntityItemPickup()); FMLCommonHandler.instance().bus().register(new KeyInputHandler()); KeyBindings.init(); } ... So I think that means the entityItemPickup event I'm subscribing to is on the client side? That's what I assumed, so that is why I'm confused about the output of Minecraft.getMinecraft().thePlayer.getUniqueID() in the that event: It is always the UUID of the player hosting the game, even when triggered by a guest player. (I'm testing by building the mod and loading in two clients, logging in with a different account on each, opening to LAN from one, and joining with the other). public class EntityItemPickup { protected Minecraft mc = Minecraft.getMinecraft(); @SubscribeEvent public void entityItemPickup(EntityItemPickupEvent event) { System.out.println(mc.thePlayer.getUniqueID()); } } This is where I'm still a little unclear: I read a lot about code that is "running on the server" vs code that is "running on the client". How can I tell which context I'm in? Is it that any code that is initiated from the client side proxy is running on the client only?
  3. I'm still learning and having difficulty understanding the client / server relationship. I don't expect someone to solve this problem for me but rather just point me in the right direction. My goal is to learn. Thank you for your patience and I apologize in advance for being long-winded and/or daft! The basic concept of the mod I'm working on (To teach myself) is that the player can look at a list of all entity items in the game and mark any of them. When the player encounters that item on the ground, s/he will not pick it up if it is marked. I've got it working in single player, but when I go to test in in multiplayer, it isn't doing what I want. The player that started the server is the "master", so that all players in the game are prevented from picking up the blocks that the "master" player has marked. The unwanted items are stored as an ArrayList of the type UniqueIdentifier. That ArrayList is just defined in my base mod class: @Mod(modid = DoNotWant.MODID, version = DoNotWant.VERSION) public class DoNotWant { public static final String MODID = "donotwant"; public static final String VERSION = "0.1"; public ArrayList unwanted; ... In the client side preInit(): public void preInit() { super.preInit(); DoNotWant.instance.unwanted = new ArrayList(); MinecraftForge.EVENT_BUS.register(new EntityItemPickup()); FMLCommonHandler.instance().bus().register(new KeyInputHandler()); KeyBindings.init(); } I then have a GUI implemented from the base class thusly: @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == GuiBlockManager.GUI_ID) { return new GuiBlockManager(); } return null; } From that GUI, when the player clicks a button representing a particular block, I get the block's unique identifier and add it to the ArrayList: DoNotWant.instance.unwanted.add(item.getUniqueIdentifier()); And finally I subscribe to the entityItemPickupEvent: private UniqueIdentifier ident; protected Minecraft mc = Minecraft.getMinecraft(); @SubscribeEvent public void entityItemPickup(EntityItemPickupEvent event) { ident = GameRegistry.findUniqueIdentifierFor(event.item.getEntityItem().getItem()); if (DoNotWant.instance.unwanted.indexOf(ident) != -1) { event.setCanceled(true); } } Is there another place I can define the ArrayList so that each client has a unique instance of it? I have a feeling it isn't that simple. I considered keeping track of the unwanted items in an ArrayList where each player was a key, and the value was a list of UniqueIdentifiers for that player, but I'm not sure if that is the way I should do it. When I call mc.thePlayer.getUniqueID() within the entityItemPickup event handler, I always get the UUID of the "master" player, even when the event is triggered from the guest player's client. What's up with that?
×
×
  • Create New...

Important Information

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