Jump to content

coolAlias

Members
  • Posts

    2805
  • Joined

  • Last visited

Everything posted by coolAlias

  1. If you've made custom furnaces before, then you should be able to do it. Think of it like this: vanilla furnace already requires 2 items to smelt, fuel and ore. All you need to do is add an extra slot to the container and update the tile entity canSmelt, smeltItem, etc. logic to take the extra slot into account. As for the recipes, look at how vanilla furnace smelting recipes are set up, in a HashMap with a List of Integers as the key to return an ItemStack. The key (list of integers) stores both the id and metadata value of the 'input' ItemStack, but since it's a List, there's nothing stopping you from storing 2 or more ItemStack's worth of information in there. You just need to update the logic and methods to handle it. If you need a more concrete example, take a look here: http://www.minecraftforum.net/topic/1961477-multi-inputoutput-furnace-with-variable-input-recipes/ Be forewarned I don't cover the basics of furnaces there; for that I recommend you check out courses.vswe.se which covers many things about tile entities and other stuff.
  2. I believe setItemInUse and onPlayerStoppedUsing both require you to give the item a max use duration: // this is the vanilla method, override to return 1 or higher public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 0; } I know I've had some unexpected behavior before from not overriding it, so it may be worth a try.
  3. You don't need a Forge Event for updating your entity every tick, that's what the Entity's own onUpdate method is for. Simply override that in your custom Entity class instead of using an Event. I suggested EntityJoinWorldEvent as a way to acquire the initial target only, not for updating the position What kind of bounding box glitches are you getting?
  4. Why not have a look at what I did to add an owner to summoned creatures such as skeletons: https://github.com/coolAlias/ArcaneLegacy/blob/master/src/entity/summons/SummonSkeleton.java There are also several AI examples that involve referencing the owner. The code is probably far from perfect, but it works.
  5. This is code I've used, mostly borrowed from Draco and slightly modified, with drawTexturedModalRect (not the method you're using, I realize) that works for getting transparency: GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_ALPHA_TEST); drawTexturedModalRect(xPos, yPos, 0, 0, 56, 9); Be sure you re-enable or disable whatever you disabled/enabled when you're finished. I don't know much about openGL, so there is probably a better / more efficient way of doing it, and it again it isn't the method you're looking for but maybe you can use drawTexturedModalRect instead. Good luck!
  6. Sorry, but I think they understand very well. Try reading http://stackoverflow.com/questions/3415781/what-exactly-does-static-mean-when-declaring-global-variables-in-java and use google prolifically to find other resources to help you. There is lots of useful information for people of all levels of coding experience available at http://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html. The other possibility is that you didn't import the class containing the static field you want to access, which could account for its 'invisibility'.
  7. Yep, Draco's right about that. Why not just check if instanceof EntityPlayer and cast to that? You don't need a specifically sided version for this.
  8. First, when using Events make sure to use the most specific Event you can find, as using classes higher up on the hierarchy will call EVERY child event, and TONS of events extend EntityEvent. Why not use EntityJoinWorldEvent to check if the entity is your custom arrow? As for the homing, my advice would be to look at how Ghast fireballs work - the code in there is set up perfectly for a homing type effect.
  9. I typically use the EntityJoinWorldEvent to send a packet syncing extended properties, as you can't sync during the entity constructing phase of the process.
  10. @Draco, one can always modify a counter in a different class on an Item right click, it doesn't have to be in the Item/ItemStack itself, but yeah, the poster's intent isn't very clear, so... @deadrecon98 - diesieben07 showed you code he has made that works for saving data to the world, you just need to modify it to suit your needs. Add a method to your extension of the WorldSavedData class to call from item right click that increments a counter in it and marks it dirty, or whatever else you feel like modifying. You know all the basics of Java, right, so you should be good to go with the information you have. Otherwise, could you explain exactly in the most specific way possible what you are trying to do?
  11. Yeah, what Draco said. If you're requiring your item to right click on the entity, it's pretty simple.
  12. You could use world.removeEntity(entityToRemove) if you can find the entity from your item method. There are several ways to do so, one of which that is easy is to spawn a projectile on right click, then when the projectile impacts check if it's a living entity and remove it like above. Extending EntityThrowable and setting the gravity adjustment to 0 is an easy one.
  13. targetTasks.taskEntries.clear() will clear all entries in targetTasks. BUT, the removeTask method should work, so the problem is elsewhere. Try removing all of the oddly-named fields from your code. You really shouldn't need them for anything, since whatever they are for should be dealt with in the super class.
  14. TGG - thanks for the ideas, I'll try checking for the movement keys and send a packet, see how that works. Draco - What do you mean motionX/Y/Z is no longer used? It's still in the code from what I can see (1.6.4). I did try using moveForward/Strafing like you suggested instead of the motion values, but they are still zero on the server, just like motion. Nice idea though.
  15. I was trying to do something when the player is moving only to find that player.motionX/Y/Z always seem to be zero on the server. I'm using the following method from within LivingUpdateEvent: public static boolean isPlayerMoving(EntityPlayer player) { player.addChatMessage("Side == client? " + player.worldObj.isRemote); // always prints zero on server side; correct values displayed client side player.addChatMessage("Player motionX " + player.motionX + ", motionZ " + player.motionZ); return player.motionX != 0 || player.motionZ != 0; } I looked through NetServerHandler where it handles movement packets, and it uses player.motionX/Y/Z to calculate some things there, suggesting they shouldn't be zero even on the server; I suspect they get reset to zero sometime after the packet is handled, but I can't seem to find where. EDIT: Looks like it happens in Entity's moveEntity method, which is called directly during the handling of the movement packet. Anyone know a way I can detect if the player is in motion while on the server side?
  16. Ok, so the EntityAIAttackOnCollide task is successfully removed, but the target task EntityAINearestAttackableTarget is not being removed even though it is in the same block of code. I don't know why that would be, but I can think of two options for you: 1. Look through the removeTask code and see if there is something that would prevent your target task from being removed successfully, then adjust your code to fix it. 2. Use 'this.targetTasks.clear()' instead, as I'm guessing you don't have any other target tasks anyway. If none of that works, then I'd suggest figuring out what all of those field_7088x fields are for; perhaps the boolean type field is the same as isTamed and it's always set to false? Why on earth would you name fields like that in a class you built yourself anyway?
  17. Thanks for the ideas TGG. Yeah, with 1.7's network code changes on the way, I think I'll hold off my battle with the network code until then, although your idea is intriguing. I may give it a shot anyway if I run out of other projects and still haven't thought of a better method. Thanks again for the well-thought out response.
  18. There are several similar situations I'm trying to resolve, all of which involve the player interacting with a Gui and me wanting to get the results of that to modify data in the player. I haven't seen any Forge Events for these, but each one involves sending a packet to the server to relay the information, so I was wondering if it was possible somehow to intercept that packet and get the information, or if that's just a totally whack idea. Here's what I'm trying to do: 1. Check when a player enchants an item of any kind using the vanilla enchantment table. 2. Check when a player signs a book 3. Check when a player completes a transaction with a villager 4. Check when a player brews a potion, i.e. takes it from the stand (the PotionBrewedEvent is not designed for this particular scenario, as far as I can tell) The reason I was thinking of intercepting the packet is because the only other idea I could think of would be to check every tick whether any of these gui screens / containers were open and try to get the information by comparing some initial values (such as player xp / level) vs. the values when the screen closes, but that seems like an extremely inefficient / messy way to go about it. Hopefully I'm just overlooking something obvious... any ideas or alternatives are more than welcome. Thanks!
  19. Wow, that was an awesome explanation! Thank you for the insights GotoLink. That makes a lot of sense and only increases my appreciation for this fine piece of code. Events make modding so much easier
  20. I don't personally play with mods, so I haven't run across this myself, but while coding some event stuff a question occurred to me, and I apologize if it isn't very clear. If multiple mods or even one mod with multiple event handlers handling the same event, what happens? I assume that's where the priority level comes in, but what if they are all the same priority? What happens if one of the handlers cancels the event? Would it follow that if your handler has the possibility of canceling the event, you should give it high priority, whereas if your handler needs to be sure the event is going to happen it should have the lowest possible priority? An example: Two hypothetical mods both use LivingDeathEvent at default priority. Mod 1 wants to prevent the player from dying due to a death ward ability and cancels the event, while mod 2 uses the event to transform the player into a vampire and subsequently respawn normally (as a vampire). How is order determined in such a case, and is there anything we can do as modders to minimize potential impacts from this sort of scenario (if there are indeed any impacts)? Thanks for reading, coolAlias
  21. Basically, yes, but it all depends on what else is going on in your Entity methods. Please post your entire Entity code, as well as explain what specifically isn't working. Is the Entity still attacking players? Still following random players? The more specific you are, the easier it is to pinpoint the problem. I would recommend printing some information to the console when reading from NBT so you can see if there is an owner, what the owner's name is, and any other information you think might be relevant. This will help you troubleshoot.
  22. You can't set this particular AI in the constructor and expect it to work - there is no owner at this point as the entity has not yet been read from NBT. Do you understand that? You can do it in the constructor when constructing a NEW entity after the world is loaded by passing in a valid EntityPlayer object, but otherwise you need to access the methods when reading from NBT. Here's what I use for summoned creatures, but you have to understand what I wrote in my previous post about setting AI from within a method such as setOwner or setTamed for it to work: @Override public final void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { super.readEntityFromNBT(par1NBTTagCompound); String s = par1NBTTagCompound.getString("Owner"); if (s.length() > 0) { this.setOwner(s); this.setTamed(true); } this.aiSit.setSitting(par1NBTTagCompound.getBoolean("Sitting")); this.setSitting(par1NBTTagCompound.getBoolean("Sitting")); this.setLifespan(par1NBTTagCompound.getInteger("Lifespan")); } // Here's an example of how I set the AI whenever the owner changes - so this automatically updates the // AI even for the constructor, as I call this method rather than setting things manually /** * Sets owner's name and adds AI to follow owner */ public final void setOwner(String par1Str) { this.dataWatcher.updateObject(17, par1Str); if (par1Str.length() > 0) this.tasks.addTask(4, new EntityAIFollowSummoner(this, this.getOwner(), 1.0D, 10.0F, 2.0F)); }
  23. What debugging steps have you taken? Have you checked that you are really removing the AI for finding the nearest player? Are you sure that the chicken is still tamed when you restart the world? How about during the constructor stage, is the chicken 'tamed' while it is loading from the constructor, or does the tamed status only kick in after that stage? That's my bet: the chicken's constructor is called first, at which point it hasn't loaded the value of 'isTamed' from NBT, so you add the AI for attacking the nearest player, then the NBT loads and it's set to tamed and loses the ability to do damage, but retains its AI. What I'd do is override the setTamed method and put all the code changing the AI in there, then use that method when loading from NBT (which is done in the super, since you're not saving anything extra), so you'll have to override that method as well to call your setTamed if it's not already set up that way.
  24. I haven't seen that particular error before; did you edit the base Container class or any other base classes? Usually the cause of shift-clicking problems is improper implementation of the 'transferStackInSlot' method. See http://www.minecraftforum.net/topic/1919622-custom-container-how-to-properly-override-shift-clicking/ for more information on how to properly override it.
  25. Does this occur when you play your mod with the real Minecraft launcher, or only in Eclipse? If it's happening only when you run your mod from Eclipse, that would be because the username changes each time you restart the Eclipse client, so the chicken is 'tamed' but can't find its owner.
×
×
  • Create New...

Important Information

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