Jump to content

PlayPrey

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by PlayPrey

  1. Hey, guess what? Got it working- it was surprisingly simple. I saw in the PlayerPredicate class how one finds an advancement via a ResourceLocation and I stole the grant advancement code from AdvancementCommand- and it worked just fine. Advancements get granted via code as well now. Thank you. However, before I dig myself a hole that I can't get out of, I don't think so, currently this is my code. It isn't clean yet but thats OK for now. @SubscribeEvent public void onDeath(LivingDeathEvent event) { ResourceLocation rl = new ResourceLocation("advancementextreme", "slayer/zombie/5zombie"); if(event.getSource().getTrueSource() instanceof ServerPlayerEntity) { ServerPlayerEntity spe = (ServerPlayerEntity)event.getSource().getTrueSource(); PlayerAdvancements pa = spe.getAdvancements(); AdvancementManager am = spe.getServer().getAdvancementManager(); Advancement test = am.getAdvancement(rl); applyToAdvancement(spe, test); } } protected boolean applyToAdvancement(ServerPlayerEntity player, Advancement advancementIn) { AdvancementProgress advancementprogress = player.getAdvancements().getProgress(advancementIn); if (advancementprogress.isDone()) { return false; } else { for(String s : advancementprogress.getRemaningCriteria()) { player.getAdvancements().grantCriterion(advancementIn, s); } return true; } } I am doing an instanceof check but no World#isRemote check,- I'll have to look into that. Thank you both a ton so far
  2. OK, so what I might be realizing here, is that instead of keeping track of myself,- it should keep track of every player. (I feel like this means the host must have the mod installed and the mod won't work on servers, like the old achievement system did- but that's fine for now.) So.. What I have learned, is that my thought process was wrong. Advancements are server-side and shouldn't be messed with client-side. I have currently successfully retrieved the ServerPlayerEntity of who's killing by simply using ServerPlayerEntity spe = (ServerPlayerEntity)event.getSource().getTrueSource(); And it works fine. I guess I could store the players in a list to keep track of things in. We're making progress Next task is to try and find a advancement I have made in a json file,- I don't have time right now to try out different things- but I'll throw out a question real quick: Do you recommend reading every single advancement in the game and matching names or something, or do you know a way to straight up get a advancement like: Advancement advancement = Advancement.getFromID("modid:folder1/jsonfilename"); I know this code doesn't exist, but if you know of a similar method? I feel like I am close to my goal, that is if the AdvancementCommand way works as it should.
  3. I am aware of this, but I still want a way to find _me_ out of these players. I remember you or someone else mentioning finding players using Uuid,- can I somehow get my own Uuid- then check that upon the list of players to find me?
  4. By current I simply mean yourself. In the same way as "Minecraft.player" returns yourself, but I want to get the ServerPlayerEntity version. If I am playing on a server with 100 players, I still only want myself to be affected. I hope that made it more clear? The reason I need the server version of myself is because Advancements seems to be completely server-side driven.
  5. I'd like to point out, it's purely for testing purposes but I am running the code on every EntityDeath from a; @SubscribeEvent public void onDeath(LivingDeathEvent event) { if(sp == null) sp = mc.player; mp = sp.getServer().getPlayerList().getPlayerByUsername("Dev"); } This has no intention of staying in a final product. The mc variable gets assigned to from the mods initializer as mc = Minecraft.getInstance(); The variables are stored in the class itself.
  6. It certainly does, however I am missing out on something simple again. The AdvancementCommand way requires the ServerPlayerEntity,- and I have to admit I struggle getting the current player as an ServerPlayerEntity. Just to test I did something like sp = mc.player; ServerPlayerEntity mp = sp.getServer().getPlayerList().getPlayerByUsername("Dev"); Considering the debug player name is Dev I thought it might work. I know one shouldn't do getPlayerByUsername but end goal here was just to see a working result, before optimizing it. However this code just returns null + throws a NullPointerException. So in short, how do I get the _current_ player as an ServerPlayerEntity? This mod has no intention of having any multiplayer functions,- so the mod itself doesn't require knowing anything about other players. However Minecraft is basically a server run game now so it's probably unavoidable.
  7. So good news, the events always worked- it's just the logging part that didn't. Tested with something else, like teleporting/hurting/etc the player and it all triggered fine. Now, I do wish there was a simple way of granting an advancement from a string value (as ID). For example: player.getAdvancement("mod:folder/jsonfile") but sadly that method doesn't exist. Does anyone know of a way like that? Or is the best way to actually create a new Criterion and reference to that from the json files? I looked into the built in triggers in the game and got a little stuck, because a lot of the functions in them have names like "p_230241_2" all over them. That just makes me confused. But if that's the way I am willing to at least give it a shot. Just don't want to go about it the completely wrong way from the get go. Thanks so far.
  8. For some reason it doesn't work with or without the @SubscribeEvent Also, I apologize- I don't know why I felt the need to assure people "knew" about my past "experience". I guess I thought it would help people when they knew more about who they were dealing with.
  9. So I added the loop, and it still didn't show up at all in the log. This is odd, the example mod did come with logging in the other methods (which I removed) and they worked fine. @SubscribeEvent public void setup(final FMLCommonSetupEvent event) { for(int i = 0; i < 1000; i++) { LOGGER.info("Common SETUP"); } }
  10. This is not going to be pretty, brace yourself. I saw that I am adding the listener (From the forge example), but that didn't work- so I tried adding subscribe event,- which didn't work because it was a private method. This is the latest attempt at a... log message.... package no.pcservicetbg.advancementextreme; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.stream.Collectors; // The value here should match an entry in the META-INF/mods.toml file @Mod("advancementextreme") public class AdvancementExtreme { // Directly reference a log4j logger. private static final Logger LOGGER = LogManager.getLogger(); public AdvancementExtreme() { // Register the setup method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); // Register the enqueueIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC); // Register the processIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC); // Register the doClientStuff method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent public void setup(final FMLCommonSetupEvent event) { LOGGER.info("Common SETUP"); } private void doClientStuff(final FMLClientSetupEvent event) { } private void enqueueIMC(final InterModEnqueueEvent event) { } private void processIMC(final InterModProcessEvent event) { // some example code to receive and process InterModComms from other mods } // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { // do something when the server starts } // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD // Event bus for receiving Registry Events) @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) { // register a new block here LOGGER.info("HELLO from Register Block"); } } }
  11. Did you attempt to restart Intellij just to check if it worked or not? Mine had about the same log as yours and did add the required configurations to IntelliJ to test the mod.
  12. Thank you, what you're saying does make sense- however it's been 5 years since I worked with stat tracking and things have changed. In addition to that it's been a while since I worked with Java + Forge ( I normally code C# applications ). You don't have to of course, but would you be willing to aid me with some slight tea-spoon styled assistance? Just to test I added LOGGER.info("Common setup"); into the private void setup(final FMLCommonSetupEvent event) In my head this would trigger after the mod has loaded, or during? However it never logged my text into the console. It's kinda embarrassing to be in this early beginner stages again, hehe.
  13. Greetings, I am attempting to update an old mod of mine, which added a lot of achievements. I thought I would start with the simple stuff, namely adding the milestone styled advancements first. However it turns out triggering an advancement after for example killing 5 zombies is more difficult than expected. It appears easy if all the entities for the advancement are different, but I tried the option that obviously wouldn't work- adding 5x of the zombie kill trigger criterion. As expected the advancement is still triggered after killing just one. As far as I know it is not possible to read from the stats easily from the JSON files. I'll admit, i'm a few years behind with this new system of doing things- but I have managed the simple normal things in advancements. I have been googling about, and it is possible to use custom triggers,- but the tutorial I found said "copy and paste this code"- which didn't work,- and had no documentation to explain things. Does anyone here have experience with triggering advancements with a quantity requirement? It would be a nice detail if I could use the counter that's visible on some advancements (like discover all biomes).
  14. Well I had forgotten to enable ticking on the block... Now to figure out the following error:
  15. Greetings,- I am trying to have my block "emulate" being so hot it sets nearby wooden structure on fire. I have looked trough BlockFire and BlockLiquid in attempt to figure out how it's done, but to no success. Am I looking in the right classes even?
  16. Thank you.. I thought I had looked trough the log properly but I somehow missed the most important line, it now works.
  17. So I changed things up so my class extends ItemBlock, which when I think about it was a obvious fix, this required a logical parameter "Block". I can now place my block around using my itemBlock for it, thank you However now I need to fixed the Model rendering for it when it's held. Main Mod File: ModItems: BasicOreItem: SPOILER edition of the error log: And Pastebin version: https://pastebin.com/yS1SzPL7 Also thank you jeffryfisher, Ill look into that as soon as I got them up and going
  18. Greetings, I am having some issues getting as much as a basic block working,- so I just need someone to point me in the right direction. I register the block itself using the following: Main Mod File: ModBlocks: BasicOre: ModItems: BasicOreItem: I know this won't work as the item has no connection the the block itself ever in the code, how do I do that the proper way? Also the item shows up just like a screenshot I used for a earlier problem. (It's for an item, but it has the exact same look but with different text) I've tried to understand the tutorials & documentation but I struggle with it so I bet the solution is the easiest thing ever. Thank you for reading. Oh and heres the JSON file at assets/ppextreme/blockstates/silverore.json:
  19. That solved that. Thank you. I bet i'll run into issues when trying to render tools and blocks but that will be a problem for later. Thanks again
  20. Alright slap me in the head with a fish would ya,- been trying to figure out ModelLoader for a few hours now and now that you arrived and basically said nothing "helpful" I got it working, so thank you! I guess However,- it's too late for me to keep working on it today,- would you mind telling me how to rotate the item so it's pointing the correct direction? Like a normal item? None of the changes I do for the item's JSON seem to do anything (except for locating the texture file). One of my JSON files in it's current state:
  21. Hello good sir's and possibly madams even though I doubt that. I have not been modding this game for a long time, so I am still learning how to register new things properly,- I don't quite get the documentation Forge has and I am honestly about to lose motivation about the entire thing. I have managed to successfully have the item itself be added ingame, with a proper name from the lang file and all,- however it has the wrong model and texture. (no texture) Can someone teach me with examples how one does this these days? I found one tutorial showing something about assigning the item with a model renderer, however when I did that I got the item's texture (pink and black) in the middle of the screen, with the text "item.name#inventory" in blue. I lose motivation quick so I hope someone is willing to explain better than the documentation does.
  22. Hello! I made a lamp for minecraft, custom model made in techne and everything. However, I can't seem to get the icon for it to work. I'm not 100% sure what file is the cause, be it the render- tilentity or the block itself, but heres what I got in the block's files: Block http://pastebin.com/zj1j93J1 Render http://pastebin.com/awQkgc3T ClientProxy http://pastebin.com/UAJsPsLv TileEntity simply extends the standard TileEntity class.
  23. The idea is to require the player to open a specific chest in a world and then unlock a achievement- opening a different one would not unlock the achievement. This isnt important, but I though it could be fun to require the player to open the first crafted chest.
  24. Hello, I want to save a block that has been crafted so the mod will remember that block. I tried to do: public static Block theChest; (inside a onCraft event) theChest = e.crafting.GetItem() This obviously gives the error that block cant be converted to an item. I am having trouble converting the GetItem into a GetBlock kind of thing, I cant find a way to use 'getItemFromBlock' for it.
  25. Thank you! It now works flawlessly Also; diesieben07 ; I tried to say I had NOT touched Java since 2012 - So stuff is a little difficult to begin with. Im sorry about this.
×
×
  • Create New...

Important Information

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