Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

PlayPrey

Members
  • Posts

    39
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    Norway
  • Personal Text
    Achievement enthusiast.

Recent Profile Visitors

1174 profile views

PlayPrey's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  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?
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.