Jump to content

pacguy

Members
  • Posts

    17
  • Joined

  • Last visited

Converted

  • Gender
    Female

Recent Profile Visitors

1967 profile views

pacguy's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I've run into an awkward issue, and I'm not sure how to move forward. I have a storage item, that can hold other items. They can be added and removed by opening a container window, accessed by right clicking the storage item. The problem I'm trying to solve is that once the container is open, the player can drop the storage item on the ground, which allows the player to access the container even without the item. That makes no sense and causes undefined behavior, so it definitely needs fixing. I tried to use ItemTossEvent to detect when the item is dropped, and close the container when it's called, like so: @SubscribeEvent public void onTossedItem(ItemTossEvent event) { if(event.getEntityItem().getItem().getItem() instanceof MyItem & event.getPlayer().openContainer instanceof MyContainer) { event.getPlayer().closeScreen(); } } This does work in some circumstances; if you press Q on the item slot with the correct item in it, the code works as intended. However, if you try to drag and drop an item off screen, things get messy! Closing the screen calls Container.onContainerClosed, which drops the itemstack in the players hand, which triggers the ItemTossEvent, which calls Container.onContainerClosed, so on and so forth until a StackOverflowException shuts down the recursion. How do I pull this off without getting getting stuck in a recursive loop? My immediate ideas are hacky, and would break in the event that the player presses Q on the item...
  2. Today, my internet went down, and I was unable to work on my mod because early on, it tries to contact a server and fails without an internet connection. Circumstance is setup in such a way that I'll have to have my internet down for an extended period of time in the near future, and modding is one of the few things holding my sanity together right now... Why do I need an internet connection to build and run a forge mod, and how do I make it possible to work offline? Apologies if there are major grammatical errors, I'm currently on mobile. Anrld unfortunately, before anyone brings it up, a mobilr hotspot isn't going to be feasible, as much as I'd like it to br...
  3. Thanks for the suggestion! It was a little rocky at first because a lot of important stuff was still obfuscated, but I figured it out :3
  4. I want to make sets of armor that can raise or lower the players movement speed. The goal is for each armor piece to increase or decrease the players speed, and to allow the player to mix and match them to get different speeds. For a rough example, a helmet that slows you down by 1, a chest plate that slows you down by 3, and leggings that speed you up by 4 should equate to normal speed, while boots that slow or speed you up would affect your final speed. I'm hoping for more then that as well (hopefully flight and some other stuff), but I'm starting with speed. Of course, speed and slowness potion effects are a thing, but I want to avoid them because they're a messy workaround that can screw up other things the player is trying to do, overriding the potions system. I'm making a mod here, not a datapack. And they don't offer particularly fine control anyways. The next thing I stumbled on was player.abilities, which exposes a couple of player features that could prove useful! Thing is, I can't quite work with it properly. Having each armor piece modify the speed value instead of set it means that it needs to be reset every tick to avoid having the value simply grow or shrink forever, so I have an onPlayerTick event that runs event.player.abilities.setWalkSpeed(0.1F); to ensure that doesn't happen. I run this in the custom ArmorItems' onArmorTick function to modify the players speed: switch(armorSlot) { case HEAD: playerAbilities.setWalkSpeed(playerAbilities.getWalkSpeed() * 0.8F); break; case CHEST: playerAbilities.setWalkSpeed(playerAbilities.getWalkSpeed() * 0.5F); break; case LEGS: playerAbilities.setWalkSpeed(playerAbilities.getWalkSpeed() * 2F * 1.25F * 1.25F); break; case FEET: playerAbilities.setWalkSpeed(playerAbilities.getWalkSpeed() * 0.8F); break; Now what I have sort of works; if you open a world while wearing the armor, you start walking at the correct speed depending on what your wearing. But it never updates until you close and open the world again. The code is definitely running, logging confirms that onPlayerTick and onArmorTick are running and that player.abilties.getWalkSpeed() outputs what I'd expect it to. But it never seems to do anything in game. I tried running the suspiciously named "player.sendPlayerAbilities()" after all the changes in each function and that had no noticeable effect. I tried making all the code only run on the logical server, and that appeared to do nothing. I've toggled back and forth with having onPlayerTick run at the start or end of the tick phase. Haven't really discovered any difference. While looking up stuff on how I should detect armor removal properly, the implementations I stumbled across used onPlayerTick, since there is no event for armor inventory changes, but they made the assumption that only one player exists, which I'd obviously want to avoid. Unfortunately, I couldn't think up a solution that worked for multiple players though... So I just had it set the speed every player tick. While I doubt it's the problem (the speed will often get stuck at a higher or lower speed value if you started the world while wearing armor, even if you take all the armor off and let onPlayerTick setWalkSpeed() to 0.1 for long periods of time), I was worried having the speed be set constantly multiple times per frame might be causing problems somehow. I tried to look up some more stuff related to player.abilities, only to stumble on this library which says that mods that use the feature are infamous for having compatibility issues, which makes perfect sense, especially given how I'm trying to use it; I'm overwriting it every frame! And if something else decided to mess with player speed, it likely wouldn't play well with my multipliers at all... So is there a better way to do this? Am I barking up the wrong tree? Or am I just missing something? If I've learned anything, minecraft and forge offer a lot of potential ways to do things, and the obvious one isn't always the right way of doing things...
  5. I believe I used "Open Projects From File System...". I tried using "import" instead, it appears to have done the job properly! Thanks for the help!
  6. I made a mod or two for 1.12, and I've decided to jump the gun and start a new one from scratch in 1.16.3. However, things aren't quite as I expected them to be, and I'm genuinely unsure if these things are normal and I'm just used to 1.12 modding, or if there's a genuine problem on my end. I ran "gradlew genEclipseRuns" a second time to be sure that didn't mess up, but it finished successfully, and there were no notable changes. Here's the "about" info for the version of Eclipse I'm using, if that helps: https://pastebin.com/SJq52DWL For starters, Eclipse immediately flags the example mod as error filled due to "org.apache.logging.log4j.LogManager" not resolving properly. It goes over my head (I don't know a lot about Javas' various ultitiy libraries like this), and a lot of possible solutions I stumbled upon suggest downloading other jar files and adding them to Eclipse, which feels... fishy, for lack of a better word. I have AdoptOpenJDK as my JDK, and I updated it to the most recent release (jdk-8.0.265.01-hotspot), but it had no notable changes. How should I approach this? Also, Eclipse no longer has access to Minecrafts' decompiled source code! It seems to have reference files in place instead, which would be fine, but Eclipse is no longer able to fill in the names and parameters of routines and constructors anymore, nor can it properly detect which imports to use for them (tbf, it wasn't perfect in 1.12, but it asks every time now). I am a little worried that the LogManager import being broken might be messing with this feature a bit though, but I have no way of knowing for sure until that is resolved. It was nice to be able to reference minecrafts' code for things that were poorly documented, so I hope this change isn't intentional/permenant... As far as I can tell, all of this is on the IDEs' end. gradlew is able to build a perfectly functional mod with no complaints whatsoever.
  7. I've tried World.checklight() and World.markChunkDirty(), they seem to update the lighting properly, but only sometimes?
  8. Thanks for the suggestions thus far! The ghost block issue seems to be gone now, but lighting still doesn't update unfortunately...
  9. Odd... I've tried that before. Tried it again just now, nothing happened. The main teleporter block emits light and is always placed last after all the others have been placed, so I don't see why it wouldn't light everything.
  10. Which routine do I run to start a block update? I've been sniffing around for one, but haven't found much. world.scheduleBlockUpdate looked like it'd do it, but clearly not... That seperate array idea is a good one! I'll look into implementing that later.
  11. I'm creating a block which, when activated, teleports the player to another dimension and swaps the nearby terrain between the two. To accomplish the latter, I've got a custom teleporter class that overrides placeInPortal with modified code to swap around blockstates in both dimensions (ignoring indestructible blocks like bedrock of course, and blocks with TileEntities because I can't seem to swap TileEntities properly). It also has some special code to deal with the item slots for the teleporter block itself. It works for the most part, but has some issues: Sometimes, Certain blocks, like grass and torches, break before they can be swapped properly. Occasionally, some of the swapped blocks turn into ghost blocks on the client, needing a block update or a right click to appear as they should (or a block placed where they are, if the ghost block is air). Lighting is never updated; transporting a bunch of exposed glowstone still results in the area being completely dark (block light level 0, only surfaces that are supposed to emit light themselves are visible at all) if it isn't exposed to the sky. The only way I've found to work around it is to manually place a light source as the player, which fixes everything. How can I tackle these issues? Should I be doing this in a different way? The solutions I've tried thus far haven't done anything (you can see part of what I've been trying thus far in the calls for "world.markBlocksDirtyVertical" and "world.scheduleBlockUpdate".
  12. I was able to find a fix on my own! Turns out, it appears the way it does because of these lines earlier in the vanilla code: GlStateManager.disableAlpha(); GlStateManager.enableBlend(); the blend feature caused all the images to appear transparent relative to each other, making it seem like they always overlapped. running disableBlend(), enableAlpha, then modifying the images to use transparency did the trick! Everything now renders based on the order it was drawn like expected :3 Posting this for reference, in case someone has a similar issue.
  13. I recently got a custom SkyRenderer working by copying the vanilla overworld code, and have been figuring out how it works. I created a third celestial object using the same rendering code used for the sun and moon, and for the most part, it functions perfectly: GlStateManager.enableTexture2D(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.pushMatrix(); float f16 = 1.0F - world.getRainStrength(partialTicks); GlStateManager.color(1.0F, 1.0F, 1.0F, f16); GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); float f17 = 30.0F; //size of the sun? default is 30.0F this.renderEngine.bindTexture(SUN_TEXTURES); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferbuilder.pos((double)(-f17), 100.0D, (double)(-f17)).tex(0.0D, 0.0D).endVertex(); bufferbuilder.pos((double)f17, 100.0D, (double)(-f17)).tex(1.0D, 0.0D).endVertex(); bufferbuilder.pos((double)f17, 100.0D, (double)f17).tex(1.0D, 1.0D).endVertex(); bufferbuilder.pos((double)(-f17), 100.0D, (double)f17).tex(0.0D, 1.0D).endVertex(); tessellator.draw(); f17 = 20.0F; this.renderEngine.bindTexture(MOON_PHASES_TEXTURES); int k1 = world.getMoonPhase(); int i2 = k1 % 4; int k2 = k1 / 4 % 2; float f22 = (float)(i2 + 0) / 4.0F; float f23 = (float)(k2 + 0) / 2.0F; float f24 = (float)(i2 + 1) / 4.0F; float f14 = (float)(k2 + 1) / 2.0F; bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferbuilder.pos((double)(-f17), -100.0D, (double)f17).tex((double)f24, (double)f14).endVertex(); bufferbuilder.pos((double)f17, -100.0D, (double)f17).tex((double)f22, (double)f14).endVertex(); bufferbuilder.pos((double)f17, -100.0D, (double)(-f17)).tex((double)f22, (double)f23).endVertex(); bufferbuilder.pos((double)(-f17), -100.0D, (double)(-f17)).tex((double)f24, (double)f23).endVertex(); tessellator.draw(); GlStateManager.rotate(-world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); //reverse rotation for celestial angle GlStateManager.rotate(-80, 1.0F, 0.0F, 0.0F);//rotate drawing pad to horizon GlStateManager.rotate(75, 0.0F, 1.0F, 0.0F);//rotate drawing pad to sideways //custom third celestial object float jupSize = 65.0F; //size of the sun? default is 30.0F this.renderEngine.bindTexture(JUPITER_TEXTURES); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferbuilder.pos((double)(-jupSize), 100.0D, (double)(-jupSize)).tex(0.0D, 0.0D).endVertex(); bufferbuilder.pos((double)jupSize, 100.0D, (double)(-jupSize)).tex(1.0D, 0.0D).endVertex(); bufferbuilder.pos((double)jupSize, 100.0D, (double)jupSize).tex(1.0D, 1.0D).endVertex(); bufferbuilder.pos((double)(-jupSize), 100.0D, (double)jupSize).tex(0.0D, 1.0D).endVertex(); tessellator.draw(); GlStateManager.rotate(-75, 0.0F, 1.0F, 0.0F);//rotate back upright GlStateManager.rotate(80, 1.0F, 0.0F, 0.0F);//rotate drawing pad back to default position for vanilla celestial objects GlStateManager.disableTexture2D(); This creates a third visible 2d texture that always appears slanted on the horizon, which is perfect. The only issue is, I want the sun to render behind it. I tried drawing the third object both before and after the sun is drawn, but either way, the sun always appears on top of it, rather then behind it. How could I force the third image to overlap the sun? I'm new to working with minecrafts' rendering code, and I haven't been able to find any helpful resources for it. EDIT: The moon overlaps it too... EDIT2: I've figured out that the second argument in bufferbuilder.pos(#,#,#) controls depth, but it still doesn't seem to help the draw issue; textures behind other textures still render over for some reason.
  14. I have a custom dimension that I'm trying to create a custom day/night cycle for. My plan is to compensate for the vanilla day night cycle (I tried using the doDayNightCycle game rule, but that affected the overworld...), and then increment time about 4 times slower then normal by setting it during a WorldTickEvent. This is what I have so far: @SubscribeEvent public static void WorldTickEvent(WorldTickEvent event) { if(event.world.isRemote) { return; //if on client, fail } //are we in ice dimension? if(event.world.provider.getDimension() == ModDimensions.TEST_DIM_ID) { //if so, take manual control of this worlds time progression. iceDimensionTimeProgression += 1; //increment external delay timer by 1 //if 4 ticks have passed... //if(iceDimensionTimeProgression == 4) { //reset time progression variable iceDimensionTimeProgression = 0; //update world time by 1 (4x slower then normal) event.world.setWorldTime(event.world.getWorldTime() + 5L); System.out.println("world time updated in ice dimension, time is " + event.world.getWorldTime()); System.out.println("World is " + event.world.getClass().getName() + ", world provider is " + event.world.provider.getClass().getName()); //} } } I apologize in advance for the dirty commented out if statement and redundant iceDimensionTimeProgression variable. They work as intended, but I have them disabled to make troubleshooting easier. My problem is that setWorldTime never does anything. I've tried to set it to static test numbers, but they always have no effect. If the current time starts as 1842 for example, and I try calling "event.world.setWorldTime(69)", the world time will remain at 1842. The only way I'm even able to influence it at all (other then the doDayNightCycle gamerule) is via the in game command "time set #"! As far as I can tell, the in game command and the code responsible for the vanilla day night cycle use this routine as well, on both the client and server sides, so I'm not sure why it wouldn't work... Here's a typical log output from this routine, with doDayNightCycle set to false to make debugging simpler: [13:11:42] [Server thread/INFO] [STDOUT]: [pacca.firstmod.CommonProxy:WorldTickEvent:138]: world time updated in ice dimension, time is 1491 [13:11:42] [Server thread/INFO] [STDOUT]: [pacca.firstmod.CommonProxy:WorldTickEvent:139]: World is net.minecraft.world.WorldServerMulti, world provider is pacca.firstmod.dimension.TestWorldProvider [13:11:42] [Server thread/INFO] [STDOUT]: [pacca.firstmod.CommonProxy:WorldTickEvent:138]: world time updated in ice dimension, time is 1491 [13:11:42] [Server thread/INFO] [STDOUT]: [pacca.firstmod.CommonProxy:WorldTickEvent:139]: World is net.minecraft.world.WorldServerMulti, world provider is pacca.firstmod.dimension.TestWorldProvider [13:11:42] [Server thread/INFO] [STDOUT]: [pacca.firstmod.CommonProxy:WorldTickEvent:138]: world time updated in ice dimension, time is 1491 [13:11:42] [Server thread/INFO] [STDOUT]: [pacca.firstmod.CommonProxy:WorldTickEvent:139]: World is net.minecraft.world.WorldServerMulti, world provider is pacca.firstmod.dimension.TestWorldProvider [13:11:42] [Server thread/INFO] [STDOUT]: [pacca.firstmod.CommonProxy:WorldTickEvent:138]: world time updated in ice dimension, time is 1491 [13:11:42] [Server thread/INFO] [STDOUT]: [pacca.firstmod.CommonProxy:WorldTickEvent:139]: World is net.minecraft.world.WorldServerMulti, world provider is pacca.firstmod.dimension.TestWorldProvider [13:11:42] [Server thread/INFO] [STDOUT]: [pacca.firstmod.CommonProxy:WorldTickEvent:138]: world time updated in ice dimension, time is 1491 [13:11:42] [Server thread/INFO] [STDOUT]: [pacca.firstmod.CommonProxy:WorldTickEvent:139]: World is net.minecraft.world.WorldServerMulti, world provider is pacca.firstmod.dimension.TestWorldProvider [13:11:42] [Server thread/INFO] [STDOUT]: [pacca.firstmod.CommonProxy:WorldTickEvent:138]: world time updated in ice dimension, time is 1491 [13:11:42] [Server thread/INFO] [STDOUT]: [pacca.firstmod.CommonProxy:WorldTickEvent:139]: World is net.minecraft.world.WorldServerMulti, world provider is pacca.firstmod.dimension.TestWorldProvider note that getWorldTime() clearly functions as intended, but the world time is never set to getWorldTime()+5 as the routine is supposed to do. Am I missing something?
  15. Ah, I guess that's alright. I'll try to copy the vanilla code into a custom SkyRenderer class and see what I can do. Like I said in the OP, I do understand java, I have a fair amount of experience in it even if I am a bit rusty. It's the minecraft engine I don't understand.
×
×
  • Create New...

Important Information

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