Jump to content

hugo_the_dwarf

Members
  • Posts

    334
  • Joined

  • Last visited

Everything posted by hugo_the_dwarf

  1. in your event you are attaching it twice Also which do you mean it doesn't work? Your player.hasCapability() returning false? or stuck with default values? If it's the default values you will need to create packets (for at least save and reload world) to update the client with the saved server values. if (ent instanceof EntityPlayer) e.addCapability(CapabilityMagicProvider.KEY, new CapabilityMagicProvider(ent)); e.addCapability(CapabilityMagicProvider.KEY, new CapabilityMagicProvider(ent)); You can remove the second one, as it looks like you copied my event, and mine was so if it was a living entity add attributes, if it's a player add the player extra capability. Also what does your CapabilityMagic look like.
  2. https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/ or you can view my code in my repo in my sig. My Attach Capabilities Event
  3. Did you attach the capability correctly?
  4. Try using mc.fontRendererObj instead of your own defined one.
  5. where are you actaully "drawing" anything in that event? You can look at how I do it, however it's a bit hacky as I had thrown it together years ago. EventPlayerOverlayGui.java
  6. Can store the information in the item being held, or the player via Capability, or as an NBT on the item but Capabilities are more recommended. I normally use the "RenderGameOverlayEvent" for handling "overlays"
  7. Yeah making a new food is not that hard, everyone has said extend ItemFood or what have you, just like if I wanted to make a new sword. I can just extend itemSword, axe or pick itemTool? hoe itemHoe? just have to extend the correct base.
  8. That looks like a really old version, as latest versions of forge is using blockStates. Did you "register" your event?
  9. Altho the way I mentioned in the topic you posted is to override or cancel the default GUI/trading and then open my own. It seems Da9L may be looking to just "add" to the default villager trading options. I've managed to track a location down to "net.minecraftforge.fml.common.registry.VillagerRegistry.class" but other than that, I'm not sure "how" to just add to the default trading. EDIT: Oh wow re-reading that thread I posted in, I also gave the wrong suggestion of just stopping the default trading interface and using a custom one. Oops.
  10. Normally I think others have built a "Consumer" and "Provider" system where they use transports (wires) to connect them. Seems like you're using each wire or "pipe" to store power per instance (or piece of wire) when you should more or less have Batteries, Generators, Relays, etc simply "look" for Consumers that they can reach via wires, and give them power. And if possible save a map of the network (Power generator can reach a light, and a grinder) issue comes now of when the wires are disrupted or changed or something else is added to the network. If you find that your power system as it is now, can kill 4-5 frames aka show visible lag, from going through the process of using power you may wish to space out when things happen across multiple ticks, remember 20 MC ticks is 1 second. If power transfer can move about 5-10 blocks per tick, you can have your power move 100-200 blocks a second. I guess some things to keep in mind is: When should the network (connections) be remapped (what should trigger it, does it need to be per tick?) Does power need to be in each wire, or just a controller. Can or should power be able to loop amongst itself? (closed loop of wire)
  11. Well Lambda that's true, however not enough leads for Skullmassarce to work with, only half. So following Lambda's advice see some tutorials on making items and registering them (and configuring the JSONs for the textures and whatnot) once you have that done, you will want to look at some vanilla code aka like Lambda mentioned the bow (for the right-click to shoot function) Then once you have the "gun" functioning with "ammo" which at this point will act like the bow (consume ammo from the inventory) now it sounds like you want a "reload" aka extra ammo in inventory but gun can be loaded and shoot as long as it is loaded. If that is the case you will have to look into capabilities (so you can store extra data) after once that is all setup it will be looking into other things (key presses for force reload, if they can reload, auto reload if gun is empty and ammo is ready) EDIT: but it depends on how you WANT it to work, you could have the ammo just have durability and have them limited to stackSize of "1" and the durability is the ammo in the mag/clip. But the effects of that would more or less be no reload (just burn through the clips, classic and 2016 DOOM anyone?)
  12. Create a Capability, CapabilityData, and a CapbilityProvider. You then attach it to players or all entities if you wish. You can make an additional handler, but if you store the needed information in the capability you can simply access it wherever you need be. Say like in an update event event.getEntity().getCapability(YourCapabilityHere,null).aFieldOrMethodInsideYourCapability; Feel free to dig around my code which is in my sig to get an idea of how I've implemented capabilities. Most packages are named to contain things that make sense. So comms would be all my packets and proxies.
  13. as mentioned above it could be a TE or a Capability for the player. Once the sounds plays, it enables a state to be set that says "perform my logic after x amount of ticks" which MC 20 ticks is about 1 sec RL time. If you want delays you will have to setup your own counter system. As mentioned before Thread.Sleep() is a no no.
  14. Interesting, I'll keep those in mind. However I'm more or less interested in "If the Mob can attack, in any way" which by the looks of it checking the targetTasks list is the best way. If the mob cannot attack I don't need to add my custom stats to them and they can safely ignore any new of my new damage calculations. Which by the way some of your mobs gave me quite the surprise as some of them attack twice (normal hit, and a unblock-able hit) this made me go "How did that one hit me, when I have a Def Rating of 337?" but helped me cover more bases of what can and will attack and when to apply new calculations.
  15. couldn't you mimic how normal crops work, but combine it with logic like sugercane/reeds? Age age reaches max, grow a top part, which then also must reach max age?
  16. Thanks these give me somewhere to look, and something to look out for. Guess I have some fun ahead of me
  17. So I'm working on professions for my mod, and one of them is a blacksmith (crafts better gear, repairs, upgrades, and salvages items/gear) Naturally above I mention Salvage which will be one of the skills. I want to be able to take a wooden shovel and dismantle it, with chances of returning each item used to make it 33% to return wood plank (no way to find the meta for what type default to oak) 33% per stick (2 sticks) and any other item (that is craftable) like crafting benches, boats, clock, redstone torches, etc. The logic of how i'll handle some things will differ but that's my concern. I'm wondering how I can get the recipe and then make my "dismantle logic" I've asked about smelting recipes because I have another profession "Miner" and breaking blocks that "drop" items other than themself will drop more (coal ore, emerald ore, lapiz ore, redstone ore, etc) however I'd like to be able to check the block (does it drop itself? no bonus, does the block drop items, yes. Can those items be used to remake this block again (IE Glowstone) no bonus) More or less I'd like to be able to ensure that block cannot be recrafted, and placed again to break it again. This would be such things like smooth stone (doesn't drop itself, but drops cobble (unless silk touch, silktouch automatically never gives a bonus)) you can smelt cobble to smooth, naturally no extra cobble should be given. TL;DR How do I get a recipe for an item, be it crafting or smelting from the item?
  18. Well somehow it managed to work, but I have changed it to use .equals() now, which naturally still works. I have a bit of conversions now where I've compared with == instead of .equals (for strings at any rate)
  19. Thanks, altho I'll stick with this hack "ageProp.getAllowedValues().size() - 1" for now, hopefully no other modders decide it has to be any different for their crops.
  20. Thanks you two, and Dracos a special thank you I was trying to figure out how to get the bloody MAXAGE value, I had this before your posted (and was about to post asking how the heck) age = e.getState().getValue(ageProp).MAX_VALUE; which naturally gave me the largest number an Integer can hold, definitely not the Max I was looking for I'm also curious since my code once I finished it looks almost identical to yours, except for how we use the loop I used: int age = -1; int maxAge = -1; for (IProperty<?> p : e.getState().getPropertyNames()) { if (p.getName().toLowerCase() == "age") { if (p instanceof PropertyInteger) { PropertyInteger ageProp = (PropertyInteger) p; age = e.getState().getValue(ageProp).intValue(); maxAge = ageProp.getAllowedValues().size() - 1; } } } Is your way of looping faster? or more or less the same (Iterator with While, mine is foreach). Thinking about it, when I find that info I need to "break;" out of my loop, no point in looking any deeper if I found what I want.
  21. How would I get a property on a block that I know is going to be there, aka the AGE property. I've noticed anything with BlockCrops uses min 0 max 7 but things like nether wart, and beets are min 0 max 3. What I'd like to do is check to see if a block has the AGE property, then get the current value, and max value. and compare the two If(currentAge == maxAge) I'm modding in professions so if the player is a farmer/lumberjack you will get more drops per harvest-able block broken. I need the age so players won't be able to exploit farming materials where the item is the seed (Potato, Carrot, N-Wart, etc) by just planting and breaking it at AGE 0 and getting more (so checking to see if it's a BlockCrop or BlockBush is not enough) currently I have int age = e.getState().getValue(BlockCrops.AGE).intValue(); int maxAge = e.getState().getValue(BlockCrops.AGE).MAX_VALUE; Less of course that will work for any block that decided to register a Property with the name of "age"
  22. Oh derp, I got confused with Just add a "!" to the front if (!worldIn.isAirBlock(pos.up())){} isAirBlock returns a boolean so you can use "!" to check for false
  23. you're comparing a blockstate to a block. add ..... != Blocks.AIR.getDefaultState() or you can get the block from world.getBlockState(positionNumber).getBlock() so: world.getBlockState(positionNumber) != Blocks.AIR.getDefaultState() or world.getBlockState(positionNumber).getBlock() != Blocks.AIR EDIT: I take this is something to do with 1.11? as in 1.10.2 there still is a worldObj.isAirBlock(pos);
  24. actually playerextra would, I've named each one for what the capability attaches too. itemextra for items, mobextra for mobs (or entities that are non-player and hostile), and playerextra (for players) there is "attribute" which is a generic capability So inside "htd.rot.capability.playerextra" you will see 3 files CapPlayerExtra (read over it, and change what you need to) CapPlayerExtraData (this is where you will store your data, so methods and variables can be removed except writeData() and readData() that is for NBT saving and writing.) ^^^ This above file is where you will have your array or list of ItemStack (items that you want) CapPlayerExtraProvider (read over it, and change what you need to) after you have those all setup in your main mod class call the "register" method from your capability (I doubt you will leave it named as CapPlayerExtra) in the preInit event. (I have a CapabilityManager but all that does is just group the registers so I can keep my main class clean) Once you have them registered "htd.rot.events#EventAddCapabilities" will show you have to attach them to entities. Mainly you will want to look at the event "public void onAddCapabilitiesEntity(AttachCapabilitiesEvent<Entity> e)" Now don't try to access anything from the object in this event just add the capability and move on (because capability attachment happens before the object is even fully constructed so most fields if not all of them will be null) Now that you have that to look at, you will need packets. I do my packets in a strange way, so referencing them would most likely be a bad idea and probably just be confusing. But you will want to include a method or value in your Capability so when you update it server-side (adding or removing or altering an Item) you will want to tell it to fire a packet off to update the player client-side so that once they are in sync and any GUIs used to show that data show correctly. looking at https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/ just to make sure there wasn't some sort of container business that would make syncing items easier, there appears to be not. Bit lengthy but hope that helps you a bit.
×
×
  • Create New...

Important Information

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