-
Posts
444 -
Joined
-
Last visited
Everything posted by brandon3055
-
if(!world.isRemote) { if(stack.stackTagCompound.getBoolean("Mode")) { ArcaneArtificing.snw.sendToServer(new MessageBreakBlock(1)); } else { ArcaneArtificing.snw.sendToServer(new MessageBreakBlock(0)); } } It looks like you are trying to send a packet from the server to the server perhaps that is the problem?
-
That looks ok assuming BetterThings.GravityChestplate is correct. Add System.out.println("event.player.getEquipmentInSlot(3) != null && event.player.getEquipmentInSlot(3).getItem() == BetterThings.GravityChestplate") after if (event.phase != TickEvent.Phase.START || event.player.worldObj.isRemote) return; That should spamm your console with ether true or false and it should change when you equip/unequip the chest plate. If it dosnt print anything then you havent registered the event handler properly.
-
oops my bad it is .getItem() i am not very good at remembering methods outside my workspace. Edit: add a println to each side of the if statment to see if it is detecting that you are wearing the item. Also have you registered the event handler? and to the correct buss? (FMLCommonHandler.instance().bus()) if BetterThings is where you keep the instance of the item then that is correct (BTW field names should start with a lowercase)
-
Oh you mean public static Map<EntityPlayer, Boolean> playersWithFlight = new WeakHashMap<EntityPlayer, Boolean>(); @SubscribeEvent public void onEntityUpdate(PlayerTickEvent event) { if (event.phase != START || event.player.worldObj.isRemote) return; if (/*Check if player has chestplate*/) { String ownerName = player.getDisplayName(); playersWithFlight.put(player, true); player.capabilities.allowFlying = true; } else { String ownerName = player.getDisplayName(); if (!playersWithFlight.containsKey(player)) { playersWithFlight.put(player, false); } if (playersWithFlight.get(player)) { playersWithFlight.put(player, false); if (!player.capabilities.isCreativeMode) { player.capabilities.allowFlying = false; player.capabilities.isFlying = false; player.sendPlayerAbilities(); } } } }
-
Thanks for the tip i didnt really consider the memory leak a problem because even if there were say 100 players in the list that are nolonger in game i didnt think that would use a noticable amount of memory. "would be to use the EntityPlayer as a key directly and then use a WeakHashMap" Im not exactly sure what you mean by that but i will try to figure it out. @skullcrusher1005 if (player.getEquipmentInSlot(3) != null && player.getEquipmentInSlot(3).item() == yourItem) //Thats the chestplate item its self not a stack containing the chestplate item
-
Entity moving after setting motion to zero
brandon3055 replied to charsmud's topic in Modder Support
I think you just need to set entity.velocityChanged to true when you set the motion to 0. -
Or you can use something like this public static Map<String, Boolean> playersWithFlight = new HashMap<String, Boolean>(); @SubscribeEvent public void onEntityUpdate(PlayerTickEvent event) { if (event.phase != START || event.player.worldObj.isRemote) return; if (/*Check if player has chestplate*/) { String ownerName = player.getDisplayName(); playersWithFlight.put(ownerName, true); player.capabilities.allowFlying = true; } else { String ownerName = player.getDisplayName(); if (!playersWithFlight.containsKey(ownerName)) { playersWithFlight.put(ownerName, false); } if (playersWithFlight.get(ownerName)) { playersWithFlight.put(ownerName, false); if (!player.capabilities.isCreativeMode) { player.capabilities.allowFlying = false; player.capabilities.isFlying = false; player.sendPlayerAbilities(); } } } }
-
Was just putting it out there. I agree its best not to take short cuts but in my opinion simpler is always better but as you are doing this as a learning experience that dosnt really matter. PS: You could still do it without the potion effect by simply checking if the player has the item in their inventory however you would only have one timer available so you wouldn't be able to have a timer for both the flight and cool down before reactivation unless you use the item damage for both.
-
I would just like to offer a simple alternative to this hole problem. Step 1:Create a potion effect that gives flight (simple) Step 2:Use item to apply effect (very simple) Done! No IEEP, NBT or packet handling required! You can use the effect duration as the flight trimmer and if you want a cool down before it can be applied again you can simply use the item damage.
-
[1.7.2][SOLVED]Trying to get the current item held by the player
brandon3055 replied to Crax's topic in Modder Support
Show your KeyBindings class. Edit: portalGunMod.player is null you need to ether get the player when the key input event is fired or add the following method to your portalGunMod class and use it to get the player. public static EntityClientPlayerMP getClientPlayer(){ return Minecraft.getMinecraft().thePlayer; } Regarding your current setup im not sure exactly how it works but i think the player field is being initialized during the mod construction faze during which time the player dose not exist. The player dosnt exist until you log into the world. Also if you were to store the player in a field such as that i believe it would become null the next time the player dies (but im not sure about that) Edit 2: A good way to track down a problem like that is to add some println's to find out what is null and where things go wrong . Also "java.lang.NullPointerException: Unexpected error" Is telling you that a value is null. "at com.crax.portalgunmod.KeyInputHandler.onKeyInput(KeyInputHandler.java:20)" Is telling you the class and line on which the error occurred. Usually you can click on it and it will take you to the error then you just have to figure out what you did wrong. -
I have an item that is both a mining tool and a weapon and i would like it to accept both tool and sword enchants. After looking through the enchantment code it looks like in order for this to work my item would have to extend both ItemTool and ItemSword which as far as i know is impossible so i was just wondering if anyone here knows a way around this problem? Im guessing it may be possible using reflection but i dont know enough about reflection to figure it out.
-
First of all you cant store those values in the item class they need to be stored as nbt any values in the item class will be the same for every instance of that item. Also I think you need to update player.capabilities.allowFlying and player.capabilities.isFlying on both the client and the server. and last of all make sure flight is enabled on the server.
-
Thats understandable but fyi you dont actually need to have ANY other RF mods installed to use the rf api because you keep a local copy of the api in your mod.
-
Perhaps you could use a multiblock approach? where one block is the master (probably the first placed) and and all other tiles are given the masters location when they are placed.
-
Im not sure if its an "agreed upon standard" but thats how it works in every mod i know.
-
Thanks for your input! With all that in mind i think i will set the limit to 100 which should be plenty for most people. I save pitch and yaw because i want it to place the player in the exact spot facing the same direction as when the location was recorded (similar to a mystcraft link book) "Name" is the name of the destination that can be set by the player not the name of the player so i dont need to worry about UUID.
-
Quick question about how much nbt is to much to store on an item. I am currently creating an item that stores sets of coordinates and allows a player to teleport to those coordinates. I would like it to be able to store as many sets of coordinates as possible but i dont know many is too many (if / when it will start to influence performance) Each coordinate is an NBTTagCompound that consists of. -Name (String) -X (double) -Y (double) -Z (double) -Dimension (int) -Pitch (float) -Yaw (float) -WP (boolean) And all of those compounds are stored in an NBTTagList. So with that information can anyone tell me how many sets of coordinates i should allow the item to store?
-
What exactly is a memory leak and how do i fix it?
brandon3055 replied to brandon3055's topic in Modder Support
I ment i dont want to have to re write my mod to use a different system. But after looking at Diesieben's tutorial it looks like the packet classes are very similar to the ones i am currently using so hopefully i wont have to change much to switch to the new system. Thanks for your help. -
What exactly is a memory leak and how do i fix it?
brandon3055 replied to brandon3055's topic in Modder Support
I am not using the Diesieben07's system the system i am using is very similar to this tutorial. http://www.minecraftforge.net/wiki/Netty_Packet_Handling I did some checking and that system is still used by CofhCore and Tinkerers Construct so it cant be that bad can it? The difference with the version i am using is it uses an interface instead of the abstract packet. Is there any reason i cant keep using this system? because i really dont want to have to re write my entire packet system again.