Jump to content

HalestormXV

Forge Modder
  • Posts

    328
  • Joined

  • Last visited

Everything posted by HalestormXV

  1. I resolved it. Thank you. I was misunderstanding the read and the write buffers and was using an older method of actually registering/creating the serializer. All is well now. Thanks again.
  2. Getting a bit of an issue with what appears to be a Malformed packet? I ported over this recipe from my 1.15.2 mod to 1.16.4 and it works flawlessly in Singleplayer. Second you try and get onto the Dedicated/SMP world though its a ClientDisconnect with the below debug. I know from the past that this generally means a malformed packet or the read and write of the serializes are out of sync etc. In 1.15.2 I was able to leave the write blank. Apparently that is not the case in 1.16.4? So in an effort to keep this in sync as you can see the resource location is in the reader and then the writer just writes the ResourceLocation but I am still getting this problem. Hopefully someone can let me know what I am doing wrong here. Its just kinda frustrating because I am having a hard time finding some examples that extend the SpecialRecipe class let alone allow you to Dye the items. Appreciate it. https://pastebin.com/mc7wjbQ9 - Debug https://pastebin.com/f2t2tpns - PouchRecipe and Serilzier
  3. I am legitimately laughing out loud right now, but not the "haha" funny laugh. More like that wow seriously, your kidding nervous laugh. Basically......I rewrote the entire class/whole system from the ground up last night, it has more functionality now and works in Multiplayer Environment, but from what you just said....all I had to do was move a couple of lines. Lmfao *FACEPALM to the umpteenth degree* Well as always I thank you. And I appreciate the info. Maybe I'll reuse this for an incredibly basic somewhat "non-flexible" machine that is only meant to do incredibly basic single item operations.
  4. You are correct. As terrifying as that is, that method has resolved the issue. However obviously as you state that is not viable as that contains well quite literally everything from recipes to structure gen to tags. So the question now is, what in a data folder could cause that issue. EDIT: After some meticulous removal and debugging it would seem the issue is within custom recipes. Thankfully I only have one custom recipe and this is the root of the problem. As soon as you remove that custom recipe directory you can log into Multiplayer and everything works flawlessly again. I can't understand why that error would be appearing only when attempting to log into the Multiplayer environment though. For reference I followed this: https://www.youtube.com/watch?v=Ri0Mqv_FXA4 And here are all the classes that were made/used following this Tutorial. https://pastebin.com/TbCtDS2T - Init https://pastebin.com/3VapXLey - Serializer https://pastebin.com/dkd4gsVa - DustRecipe https://pastebin.com/G3N5Ynsb - Interface
  5. I know this is somewhat of an older thread however I was wondering if this was ever resolved as i am getting this EXACT same error. It is kind of strange actually that it is literally the same. Here is my latest: https://hastebin.com/oyebubawit.sql Here is my debug: https://hastebin.com/dehohefudo.md (only took the bottom piece of it where the actual Frozen state happened) As for the reproduction - it is identical to above. It works flawlessly on Singleplayer. Only in the multiplayer environment does this occur. To be honest I wouldn't even know where to look for something like this? I mean are byte issues generally in networking and packet handling? Yes I can show the code as messy as it may currently be if this has indeed not actually been resolved and is still out and about. But I wouldnt even know which sections of the code would cause this to show.
  6. That actually makes it clear. I haven't seen Lazy before until about 3 weeks ago when I stepped back into the Modding world. I also haven't worked with Minecraft modding since 1.12.2 and it was very brief. Prior to that it was only 1.7.10. Also I don't code with Java normally so that works against me, only when working on Minecraft Mods am I utilizing Java so it is somewhat "unfamiliar" to me after not working with it for such a period of time, so when I see something like "Lazy" i get all Huh o_O. But that explanation does make sense so I thank you.
  7. Just giving this a bump as I solved it. @Draco18s thanks for the pointers and tips. I see why they were trying to cast to each other. My Provider, for each Capability never actually checked to ensure that the Capability was in fact the Capability it has to cast to. I am guessing it has something to do with Lazy (i am very new to Lazy to be quite honest so it doesnt surprise me that my error was in there). For reference I built my Capability system similar to how McJty built his in the tutorial videos for 1.15.2 and also took bigger aspects like registration and what not from TheGreyGhost. After looking at TheGreyGhosts capability code as a whole (https://github.com/TheGreyGhost/MinecraftByExample/tree/1-15-2-working/src/main/java/minecraftbyexample/mbe65_capability) I see that he actually enforces a check in his providers, the step I missed above. Which would make sense why when one was disabled it wouldn't conflict because there wasn't anything to conflict with when setting up the getCapability. My question now, because as I have repeatedly said, I am not just in it for answers, i want to actually learn the workings of it because that makes you a better coder and helps enhance your coding knowledge, is WHY that check is needed? If these are entirely separate classes that don't even reference/link to each other, why does that check still need to be made. Does it in fact have to do with how Lazy works?
  8. private void setup(final FMLCommonSetupEvent event) { //CapabilityEntityLocation.register(); <---Disabled to make sure that they work when one is disabled and the other is enabled CapabilityEntityExplosium.register(); ***** ComposterBlock.registerCompostable(0.7f, BlockInitDeferred.ARCANUM_LEAVES.get()); DeferredWorkQueue.runLater(StructureGen::generateStructures); registerEntityWorldSpawns(ModEntityTypes.MOOPLE_ENTITY.get(), 89, 2, 4, BiomeInit.THE_MYSTIC_HILLS.get()); registerEntityWorldSpawns(ModEntityTypes.NOVICE_CULTIST.get(), 72, 1, 4, BiomeInit.THE_LARVEN_FLATS.get(), BiomeInit.THE_MYSTIC_HILLS.get()); PotionInit.addBrewingRecipes(); MinecraftForge.EVENT_BUS.register(CapabilityRegistration.class); ******** MinecraftForge.EVENT_BUS.addListener(WatchfulEyeBreakEvent::breakUnderWatch); MinecraftForge.EVENT_BUS.addListener(ChangedMagicTools::unequippedMagicTool); MinecraftForge.EVENT_BUS.register(CapabilityEventHandler.class); } Segment of Main ^ public class CapabilityRegistration { private static final ResourceLocation ENTITY_LOCATION_CAPABILITY = new ResourceLocation(MysteriumMain.MOD_ID, "locdata"); private static final ResourceLocation ENTITY_EXPLOSIUM_CAPABILITY = new ResourceLocation(MysteriumMain.MOD_ID, "count"); @SubscribeEvent public static void attachCapability(AttachCapabilitiesEvent<Entity> event){ Entity entity = event.getObject(); if (entity instanceof LivingEntity) { //event.addCapability(ENTITY_LOCATION_CAPABILITY, new EntityLocationProvider()); event.addCapability(ENTITY_EXPLOSIUM_CAPABILITY, new EntityExplosiumProvider()); } } } CapabilityRegistration/Attachment ^ public class CapabilityEntityLocation { @CapabilityInject(IEntityLocation.class) public static Capability<IEntityLocation> ENTITY_LOCATION_CAPABILITY = null; public static void register() { CapabilityManager.INSTANCE.register(IEntityLocation.class, new Storage(), DefaultEntityLocation::new); } public static class Storage implements Capability.IStorage<IEntityLocation> { @Nullable @Override public INBT writeNBT(Capability<IEntityLocation> capability, IEntityLocation instance, Direction side) { CompoundNBT tag = new CompoundNBT(); tag.putDouble("xLoc", instance.getX()); tag.putDouble("yLoc", instance.getY()); tag.putDouble("zLoc", instance.getZ()); tag.putInt("dimID", instance.getDimId()); return tag; } @Override public void readNBT(Capability<IEntityLocation> capability, IEntityLocation instance, Direction side, INBT nbt) { double xLoc = ((CompoundNBT) nbt).getDouble("xLoc"); double yLoc = ((CompoundNBT) nbt).getDouble("yLoc"); double zLoc = ((CompoundNBT) nbt).getDouble("zLoc"); int dimID = ((CompoundNBT) nbt).getInt("dimID"); instance.setX(xLoc); instance.setY(yLoc); instance.setZ(zLoc); instance.setDim(dimID); } } } Initializing and Injecting the LocationCapability ^ (currently disabled in main) public class CapabilityEntityExplosium { @CapabilityInject(IEntityExplosium.class) public static Capability<IEntityExplosium> ENTITY_EXPLOSIUM_CAPABILITY = null; public static void register() { CapabilityManager.INSTANCE.register(IEntityExplosium.class, new Storage(), DefaultEntityExplosium::new); } public static class Storage implements Capability.IStorage<IEntityExplosium> { @Nullable @Override public INBT writeNBT(Capability<IEntityExplosium> capability, IEntityExplosium instance, Direction side) { CompoundNBT tag = new CompoundNBT(); tag.putInt("count", instance.getCount()); return tag; } @Override public void readNBT(Capability<IEntityExplosium> capability, IEntityExplosium instance, Direction side, INBT nbt) { int count = ((CompoundNBT) nbt).getInt("count"); instance.setCount(count); } } } Initlizing and Injecting the Explosium one ^ (currently is working with the disabling of the location one)
  9. The crash seems to be occurring somewhere in my (now) CapabilityEvent Handler. It is being triggered (the crash) when an Entity either getsAttacked or onDeath. For whatever reason my two capabilities seem to be conflicting. My ExplosiumCapability which is the only one that uses the attacked and onDeath, and my Location capability. The location capability is registered first in the MainClass, I took it off the Event_Bus.addListener like Draco suggested, and simply just now call a .register(CapabilityRegistration.class) it didn't make a difference. For whatever reason whichever capability is registered first (now the location one) tries to cast itself to the capability registered second (now the explosium one) . My confusion is why. They in no way reference each other. the attack and the onDeath events don't even look for let alone pull data from anything except the Explosium capability as it should be. I know the code is somewhat correct, because if I disable the Explosium capability the Location one works just fine and does everything it is supposed to do. And if I disable the location capability the Explosium one works just fine and doesnt crash or anything and does exactly what it is supposed to. Which leads me back to my original point which is something is getting messed up perhaps when they registered?
  10. Okay that can be done, so I just converted to the the above as you said. Everything is still working fine and my two capabilities are now registered in a CapabilityRegistration class and there is now a single CapabilityEventHandler class (so far with only onDeath subscribed to and onAttack subscribed to) but I am still getting the same error where it seems that the first capability to register is trying to cast to the other and as stated above, they dont even so much as reference each other anywhere in my code. And I am using the event to pull the data and check ifPresent. And as you will see below the Location Capability isn't even mentioned in here nor is it referenced. public class CapabilityEventHandler { @SubscribeEvent public void onDeathEvent(LivingDeathEvent event) { Entity entity = event.getEntity(); entity.getCapability(CapabilityEntityExplosium.ENTITY_EXPLOSIUM_CAPABILITY).ifPresent(h -> { int count = h.getCount(); if (count > 0) { entity.getEntityWorld().createExplosion(entity, entity.getPosX(), entity.getPosY(), entity.getPosZ(), count * .3f + 1.0f, Explosion.Mode.DESTROY); } }); } @SubscribeEvent public void onAttackEvent(AttackEntityEvent event) { Entity attacker = event.getEntity(); if (attacker instanceof PlayerEntity){ PlayerEntity player = (PlayerEntity) attacker; ItemStack stack = player.getHeldItemMainhand(); if (stack.getItem() == ItemInitDeferred.EXPLOSIUM_DUST.get()) { Entity target = event.getTarget(); target.getCapability(CapabilityEntityExplosium.ENTITY_EXPLOSIUM_CAPABILITY).ifPresent(handle -> { int count = handle.getCount() + 1; if (count < 9) { handle.setCount(count); player.sendStatusMessage(new TranslationTextComponent("message.increase_count", Integer.toString(count)), true); stack.shrink(1); player.setHeldItem(Hand.MAIN_HAND, stack); event.setCanceled(true); target.getEntityWorld().addParticle(ParticleTypes.FIREWORK, target.getPosX(), target.getPosY() + 1, target.getPosZ(), 0.0, 0.0, 0.0); }else{ player.sendStatusMessage(new TranslationTextComponent("message.at_max_count", Integer.toString(count-1)), true); event.setCanceled(true); } }); } } } }
  11. So here is a relatively dumb question I am sure. I have multiple capabilities. 3 at the moment but only 2 are actually registered and being used the 3rd is completely disabled and not even registered as I am still working on it. When the time comes I want to Register correctly. As it is set-up now, each capability has an event handler (the stupid part that is probably wrong). In each capabilities' EventHandler has the particular effects that I want that Capability to work with. So the AttachingEvent, an onDeath, and onAttack etc. However, I am noticing conflicts. I am getting crashes and it would seem that one Capability is trying to cast to another Capability despite there being ZERO like absolute ZERO reference to it anywhere in my code. This tells me that I am likely being foolish, and there should only be one Event handler that attaches all the capabilities at once and therefore only one MinecraftForge.EVENT_BUS.addListener(CAPABILITY HANDLER CLASS HERE::onAttachCapabilitiesEvent); MinecraftForge.EVENT_BUS.addListener(CAPABILITY HANDLER CLASS HERE::onAttackEvent); etc., etc. Here is the crash report. The reason why I know it isn't in that EffectRemeberance class is because once I disable my Explosium capability that for whatever reason is trying to cast itself everywhere the code works just fine, perfectly actually, (even my debug messages) and there is no issue. So this tells me I am doing something wrong when registering, and the only thing that "looks" off to me is all the separate registering I am doing and separate event handlers. If you need to see the Main where all the registering is happening here it is. It is currently a mess because I haven't cleaned and optimized it just yet: https://pastebin.com/YWKvtbdK
  12. Brain freeze - yeah I should have thought of that. I was incredibly frustrated and totally forgot. Turns out that was exactly the issue and diesieben07 (Sorry if this tags you, it kinda just did it automatically) was spot on. 100% right and corrected the problem. So i thank you. But perhaps this is a stupid question but why? Is setPos not actually being called? I mean i know it is part of ChunkPrimer which is why I used it in the first place being that this particular Block & TE are part of one of my structures that already generate in the world or is Primer's functionality just totally going over my head and is it just infact a "setup" the chunk itself type of class?
  13. Please someone punch me. Rather than make a new thread as this issue is still the same I think it better and more proper to simply make the post in the same thread. So after the discussion above I understand that this feat need be accomplished via TileEntity.. Not a problem.. I also get that it will use the getEntitiesWithinAABB, since a number of forum searches show a great many of these types of rather simple tasks like checking players around the TileEntity in say a 16 block radius. Mine flat out fails. I am getting a null pointer exception right when my code attempts to do the getEntities. I am CERTAIN it is completely obvious and my general rusty-ness and newness to 1.15.2 is the cause coupled with working on the same piece of code for WAY to long. So please can anyone take a look at this and knock some sense into me as to what I am doing wrong? Specifically line 57 is where the null pointer occurs. https://pastebin.com/fcnEAzkk As an aside, my TileEntity works if i take out the AABB code line and utilize the code starting on line 76 but that is not the proper way to do it and it is essentially an eternal debuff with that method as opposed to a range/radius dependent debuff.
  14. Alright thanks for the running start. I will give it a go. Appreciate it.
  15. Understood, yes as I am browsing the TileEntity class I see it'll need to implement Tickable and will be able to essentially take care of everything. As for gathering players in the area of the TileEntity is there an "effective/preferred/proper" way to do that or pretty much how the Elder Guardian does it would be best? Essentially a: TECreate -> newAxisAligned for the radius/cuboid -> Tick, get all entities in the AxisAligned -> filter the players -> apply the effect to the players, repeat (minus the TECreate and new Axis of course)
  16. Another general question. No real code to go with it just yet. Is it plausible to have a block that Ticks, and it checks the area around it for players, getPos X+16, Y+16 Z+16, X2-16, Y2-16, Z2-16 (Or perhaps there is a better way to check around a particular position? Vecs maybe? I haven't done too much with them just yet as i only just picked up 1.15.2 a few days ago after some time off) etc. And if a player enters within that range it will apply a PotionEffect (or even a vanilla effect like MiningFatigue) and then a listener will cancel a breakEvent so long as the player is afflicted with that effect (and some other criteria so it doesn't happen ALL the time a blockBreak occurs) The objective is to have a central block that is generated with some structures and if the player is within the "field" of that block they cannot break any blocks within that field thus protecting the structure. Think Elder Guardian but on a Block Level instead of an Entity Level. OR perhaps the way it should be done if a Block shouldn't/can't achieve this is via a TileEntity that is applied/attached to the Block on creation?
  17. Noted. Alright thanks for the info.
  18. If indeed Background music (i.e. Creative mode music, survival mode music, "Overworld" (you know like the "calm1", "hal2" music etc.) is indeed part of the ambience then it would seem a ClientTickEvent still is indeed the way to go about it to accomplish that effect. I'm not in front of the code atm but I imagine there is a way to check if a sound is playing and if so stop it and then start a new one? As I imagine that would be the most effective way to handle that?
  19. So this is more of a General Question as opposed to a "problem." I made my Dimension, I made my Biome(s), everything works its wonderful. I want to spice up the Dimension abit and add my own music to it. I read something that 1.15.2 "didn't yet" implement that. It was a completely random source, and who knows how long ago it was. So I am curious to know if some type of method exists to set custom music to your entire Dimension. Or perhaps it is done on the Biome level with the builder? Any guidance/example/shove in the right direction is helpful. I imagine it isn't done with a ClientTickEvent anymore.
  20. Alright so just flatMap on that one then okay. But now how would i check each of those lists, it wouldnt be normal list iteration right? For example index 0 in that map would be a list that contains A,B,C,D and index 1 in that map would be a list that contains 1, 2, 3, 4. So how would I check and pull out the valus from each of those lists? Or would it simply be just normal list iteration? What I am trying to acheive is the following. There is an item that has 4 slots. Based on the items within those 4 slots and the order that those items are in, that weapon is charged with a different ability. For instance in the example above you will notice that blastStrike is new ItemStack(ItemInit.ITEM_RUNE, 2, FIRE_RUNE.getMeta()), new ItemStack(ItemInit.ITEM_RUNE, 1, EARTH_RUNE.getMeta()), new ItemStack(ItemInit.ITEM_RUNE, 1, AIR_RUNE.getMeta()) Those are the requirements for blastStrike. So if a player has those items placed in the correct slots in the correct order their weapon will have a chance to inflict blastStrike on hit. My goal is to rather than create an independent check for every single ability to store all the requirments in the lists, like above, into a masterList and then simply just go through the masterList and see if what is currently in the weapon slots matches an entry in that master list.
  21. I knew i had this post somewhere. Just giving it a bump instead of making a whole new post.
  22. So I have some Lists that have multiple different ItemStacks in it. I am curious as to what the best way of taking all these Lists and compiling them into one MasterList so that I can iterate through it without having to use each List's getter methods. If anyone has some examples or samples of where they may have or how to do this I'd appreciate it. The current code works fine, but the current code uses each Lists's getter method and checks agains that which for now is okay, but once more combinations start ariving have to check multiple getter methods would be rather troublesome. Here is the code: https://hastebin.com/howesativu.java I have been looking into flat but I have never used it, am unfamilar with it and am not sure if that would cause problems. Hence why any examples, samples, or whatever would be most helpful if indeed flat is the best way to do this. Or if there is a much simpler and better way to accomplish this. EDIT I created the MasterList of the Lists. You can see the code segment here: /**THIS IS GOING TO BE THE LIST of LISTS CODE SO THAT WE DONT NEED TO CREATE A CHECK FOR EVERY COMBINATION List<List<ItemStack>> masterList = Stream .of( new RuneBlade_AbilityCosts().getBlastStrikeI(), new RuneBlade_AbilityCosts().getBlastStrikeII(), new RuneBlade_AbilityCosts().getWeaknessStrikeI(), new RuneBlade_AbilityCosts().getWeaknessStrikeII() ).collect(Collectors.toList()); List<ItemStack> flat = masterList.stream().flatMap(List::stream).collect(Collectors.toList()); **/ So that seems like it is the best way to create a MasterList of all those Lists. Here is the full updated code: https://hastebin.com/eyohexicaz.java Anyone care to illustrate or show how one would be able to cycle through that MasterList (flat) and pull out each individual list (or perhaps it is a sublist?) and check against it namely in my checkRunebladeReagents method? As you may be able to to see in the method I started attempting to do it but then commented it out because I was breaking stuff. I'm not really looking for just answers, I am more looking for examples or samples/explanations that I can work off of and learn how to manipulate lists within a list. Although if you do have sample code to share I'd love to have a look at that also.
  23. There is a mod that releases its source code that ignores grass. Maybe look into the mods source. https://minecraft.curseforge.com/projects/swingthroughgrass
  24. I quite literally just did this the othe day. Feel free to take a look at the code. What it does is generate two numbers and stores them. It coverts one of the number to the string value which acts as the key (since that works for my uses) and then it simply stores the whole set in a tag list. https://hastebin.com/netoleheya.cpp You can ignore the commented HashMap as I used that originally to make sure that no values were getting lost and calculated incorrectly. I commented it out but just forgot to remove it from the code base. Feel free to take an edit as you need for your uses.
  25. Im imagining ReflectionHelper.getPrivateField would likely be the route to go with this? I've never actually utilized the reflection helper before nor can I Really find any documentation on it.
×
×
  • Create New...

Important Information

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