Jump to content

Alex_Wells

Members
  • Posts

    22
  • Joined

  • Last visited

Posts posted by Alex_Wells

  1. Oh, I get it now. In dev env, mod classes are compiled and added directly to classpath, meaning the classes are known to the runtime when FMLLoader instantiates LanguageLoader. After that, additional languages are only loaded for mods with

    FMLModType

    of LANGPROVIDER.

     

    That eliminates the issue, also making it simpler for the dev because they no longer need to specify Forgelin as a dependency.

  2. Hey. So I needed Forgelin to update (kotlin language provider mod) to 1.13 and didn't want to wait, so that's what I did: https://github.com/autaut03/Forgelin/tree/1.13-rewrite

     

    Basically, to load IModLanguageLoader, Forge utilizes SerivceLoader, which scans META-INF/services for files with name of specified interface. This is how FMLJavaModLanguageLoader is loaded (the one Forge mod provides), and so I did the exact same thing. When run in IDE, or by a gradle in Forgelin project, it works good. I know that because Forgelin itself is written in Kotlin and wouldn't work without kotlinfml language loaded, plus there's a bunch of debug statements in the log.

     

    However, when built and placed into mods/ folder of a normal Forge client, it fails to find requested mod loader. I'll be thankful for any kind of help/information.

     

    Also, in case this is needed, here's a built jar: https://drive.google.com/file/d/1cXkSHTV9ZeJfMB3pXapXdykrBWuun3V-/view?usp=sharing

    Obviously, I'm not asking anyone to run it, but it's here for the reference.

  3. On 12/4/2017 at 1:33 AM, LexManos said:

    I'm looking into ways to deal with upgrading worlds for 1.13. But honestly, it's not looking good. Vanilla's flattening code is... bad... at least for modded entries. We'll see if we can figure things out. But most likely, due to modders not providing data, and the way Vanilla code is written 1.12 worlds won't be 1.13 compatible. HOWEVER, as for your specific request. You'd want to do data fixers.

    May I ask why is Forge even trying to keep worlds compatible between such major rewrites? I understand why Vanilla does that (because they have full control over their game and they have limited amount of stuff to do), but mods will probably be incompatible anyway, at least when Mojang decides to refactor and rewrite that much code... so why bother? I myself have never successfully migrated a single modded world between versions, because mods always change versions, they always remove and add lots of stuff, many mods just don't update at all, others replace them..

  4. I unded up debugging half of rendering code to find out what's the problem. Still not sure, but.. really? It got null while trying to find an exact same object (well, maybe not the same object, but with same properties, which shouldn't happen at all to my understanding of blockstates):

    er98AGA.png

    So there's nothing wrong with my assets, rather it is with my code or Forge. I doubt it is the latter, so.. could anyone please explain what the hell is happening?

  5. Hey there. So I created a block, a blockstate for it, then two models and three textures. For itemBlock, and another item from the mod I used ModelLoader to manually set their model locations - so they are both shown correctly in inventories. However, when placed in the world, it has a missing texture (purple-black). Here's the block I'm talking about: https://github.com/autaut03/roomery/blob/master/src/main/java/net/alexwells/roomery/block/RoomHolderBlock.java

    It's blockstate: https://github.com/autaut03/roomery/blob/master/src/main/resources/assets/roomery/blockstates/room_holder.json

    Main model: https://github.com/autaut03/roomery/blob/master/src/main/resources/assets/roomery/models/block/room_holder.json

    And textures: https://github.com/autaut03/roomery/tree/master/src/main/resources/assets/roomery/textures/blocks
     

    I must have missed something in the documentation, but I can't get this to work. There are no errors or warning in the log. What could be the reason for that? Thanks regardless.

    PS: model was taken from vanilla observer, and modified for my needs.

    PS2: screenshot:

    n9q4NMa.jpg

  6. Just now, diesieben07 said:

    BS. Combat overhaul will not be part of 1.14. Also, no, this does not mean they are reverting to the pre-1.9 combat.

    It will. It was confirmed by Mojang in someone's twitter. And yes, I know that they won't revert it how it was, but at least they will actually listen to the PVP community, not just vanilla.

  7. On 7/20/2018 at 3:41 AM, DaemonUmbra said:

    To be honest this is the issue I'm seeing here, this is not directed solely at you, but you are the most recent case.

     

    1.7.10 and 1.8.9 are old versions and should not be used for active development, your excuse that "I've seen others use 1.8.9" is the core of a cycle that keeps these ancient versions in a zombie-like state. People see others developing for these versions and assume that they are still valid versions to use, resulting in users ignoring recent versions in favor of using old versions that may be lacking features and/or security improvements that come from later versions.

     

    Imagine you had developed a game and after discovering and fixing a horrendous security issue in your game you then learned that people playing your game refused to update past the version just prior to the fix, then complained about the bug while insisting you continue to support that version of the game.

     

    As long as people continue to use the excuse of "They are doing it so it must be ok" old versions and the bugs in them will continue to haunt users of those versions as well as those they demand assistance from.

    The only reason people use 1.8.9 is because all major servers use 1.7 or 1.8 due to the PVP part of the game. Until Mojang rolls back 1.9 changes, people trying to code 1.8 won't stop coming =/

  8. Just now, diesieben07 said:

    Especially not if you don't know what you are doing.

    And yes, your approach to this shows that you absolutely do not know what you are doing. Don't go around replacing entire methods.

    At first I just wanted to replace couple instructions with my own, but I'm kind of lazy to rewrite my whole "method transformer" system in order to achieve that. And I feel like this won't fix the problem =/

  9. Hello there. I'm writing a mod, and I need to modify minecraft's code so I can see barrier blocks depending on my method's result. So there's a singleton with one method specifically for this, called like this (returns bool):
     

    AlwaysShowBarriersManager.instance().isEnabled()

     

    Minecraft code, responsible for displaying barrier particles is in the "net.minecraft.client.multiplayer.WorldClient" class:

    public void doVoidFogParticles(int p_doVoidFogParticles_1_, int p_doVoidFogParticles_2_, int p_doVoidFogParticles_3_) {
            int i = 16;
            Random random = new Random();
            ItemStack itemstack = this.mc.thePlayer.getHeldItem();
            boolean flag = this.mc.playerController.getCurrentGameType() == GameType.CREATIVE && itemstack != null && Block.getBlockFromItem(itemstack.getItem()) == Blocks.barrier;
            MutableBlockPos blockpos$mutableblockpos = new MutableBlockPos();
    
            for(int j = 0; j < 1000; ++j) {
                int k = p_doVoidFogParticles_1_ + this.rand.nextInt(i) - this.rand.nextInt(i);
                int l = p_doVoidFogParticles_2_ + this.rand.nextInt(i) - this.rand.nextInt(i);
                int i1 = p_doVoidFogParticles_3_ + this.rand.nextInt(i) - this.rand.nextInt(i);
                blockpos$mutableblockpos.set(k, l, i1);
                IBlockState iblockstate = this.getBlockState(blockpos$mutableblockpos);
                iblockstate.getBlock().randomDisplayTick(this, blockpos$mutableblockpos, iblockstate, random);
                if (flag && iblockstate.getBlock() == Blocks.barrier) {
                    this.spawnParticle(EnumParticleTypes.BARRIER, (double)((float)k + 0.5F), (double)((float)l + 0.5F), (double)((float)i1 + 0.5F), 0.0D, 0.0D, 0.0D, new int[0]);
                }
            }
    
        }

     

    So what I want to do is alter "flag" variable, like this:

     

    boolean flag =
                    (this.mc.playerController.getCurrentGameType() == GameType.CREATIVE && itemstack != null && Block.getBlockFromItem(itemstack.getItem()) == Blocks.barrier) ||
                            my.mod.package.AlwaysShowBarriersManager.instance().isEnabled();

    or

    if(!flag) {
    	flag = my.mod.package.AlwaysShowBarriersManager.instance().isEnabled();
    }

     

    Both solutions would work. What I usually do with coremod's ClassTransformers is I copy the whole class into same package in my mod's src folder, then modify what I need and ASMify it using IDEA plugin. I receive such code in result:

    mv = cw.visitMethod(ACC_PUBLIC, "doVoidFogParticles", "(III)V", null, null);
    mv.visitCode();
    // blablabla
    mv.visitEnd();


    My ClassTransformer's transform method looks like this (simplified):

    ClassNode classNode = new ClassNode();
    ClassReader classReader = new ClassReader(bytes);
    ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
    
    classReader.accept(classNode, ClassReader.EXPAND_FRAMES);
    
    // find needed method
    
    MethodVisitor mv = classWriter.visitMethod(); // arguments blablabla
    
    // visit code
    
    classReader.accept(methodReplacer, ClassReader.EXPAND_FRAMES);
    
    return classWriter.toByteArray();

     

    If I try to run this, the game crashes: https://pastebin.com/0hp3EsqU

    Auto-generated "visit code": https://pastebin.com/ivuabcZv

     

    What am I missing here? I know that I shouldn't use coremods, but there's no way around it, so I'm forced to use them.

  10. 42 minutes ago, diesieben07 said:

    So will making a coremod.

     

    The solution is to update.

    Update isn't real. Until Minecraft rolls out 1.14/1.15, with new PVP changes, none of the servers neither their players will update. Therefore, I just can't use 1.12.

    Unfortunately, I will have to overwrite EntityLivingBase::handleStatusUpdate in order to make it work. That's the only solution I see for 1.8.9.

    Anyways, thanks for your help.

  11. Quote

    You can overwrite the potion item using the forge registries. Just register your own implementation extending ItemPotion under the same name.

    Yes, but this will break any compatibility with other mods. Am I wrong?

     

    Quote

    EntityPlayerSP::attackEntityFrom emits LivingAttackEvent already. However this won't be of much use, since the client has no idea about what caused a given damage, that is only possible on the server.

    On Forge 1.8.9 latest it does not. What about damage amount and damage source, it doesn't really matter for me. The purpose of this is to send a chat message about other players reach distance on each their hit. I know it will never be precise, that it highly depends on ping, that it's not gonna always send true data. But again, I don't really care about all those ;)

    And sadly, I can't update my MC version. I would, but PVP was broken in 1.9 and most servers still use 1.8 (and even 1.7) as their main versions. Therefore, I would go for any trick to make it work :)


    UPD: Yes, it's fixed only in 1.11 version

  12. Just now, diesieben07 said:

    That depends on why you want to replace them. What effect are you trying to achieve?

    Default hasEffect of ItemPotion implementation decides if glinting enchanment effect is rendered on potions or not. I want to set it to always return false.

    Default attackEntityFrom doesn't emit any Forge events. In EntityLivingBase's attackEntityFrom, livingAttackEvent is emitted. I want this event to be also emitted for EntityPlayerSP, so that after this I'm able to track when player gets damage from other players.

  13. Hey there! I'm trying to hook a method of EntityPlayerSP using coremod, but for some reason

    public byte[] transform(String name, String transformedName, byte[] bytes)

    is not getting called with needed class name (net.minecraft.client.entity.EntityPlayerSP), but is getting called with all other class names (also modifying ItemPotion's method, and it works great). Here's the full code, if needed:

    public class ClassTransformer implements IClassTransformer
    {
        private Map<String, List<AbstractMethodTransformer>> methodTransformers = new HashMap<>();
    
        public ClassTransformer() {
            addMethodTransformer(new HasEffectMethodTransformer());
            addMethodTransformer(new ReachInfoClassTransformer());
        }
    
        public void addMethodTransformer(AbstractMethodTransformer transformer) {
            String className = transformer.getClassName();
    
            addMethodTransformerByName(className, transformer);
            addMethodTransformerByName(Obfuscations.get(className), transformer);
        }
    
        private void addMethodTransformerByName(String name, AbstractMethodTransformer transformer) {
            methodTransformers.computeIfAbsent(name, s -> new ArrayList<>()).add(transformer);
        }
    
        public byte[] transform(String name, String transformedName, byte[] bytes)
        {
            // DEBUG
            if(name.contains("Player") || transformedName.contains("Player"))
                System.out.println(name + " --- " + transformedName);
    
    
            if(! methodTransformers.containsKey(transformedName)) {
                return bytes;
            }
    
            System.out.println("Contains key: " + name + ", " + transformedName);
    
            List<AbstractMethodTransformer> transformers = methodTransformers.get(transformedName);
    
            ClassReader classReader = new ClassReader(bytes);
            ClassNode classNode = new ClassNode();
            ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
            classReader.accept(classNode, 0);
    
            for (MethodNode method : classNode.methods)
            {
                for(AbstractMethodTransformer transformer : transformers) {
                    String mappedMethodName = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(classNode.name, method.name, method.desc);
    
                    if(! Obfuscations.check(transformer.getMethodName(), mappedMethodName)) {
                        continue;
                    }
    
                    System.out.println("Found method: " + transformer.getMethodName() + " " + mappedMethodName);
    
                    MethodReplacer methodReplacer = new MethodReplacer(classWriter, method.name, method.desc, transformer);
                    classReader.accept(methodReplacer, ClassReader.EXPAND_FRAMES);
                    break;
                }
            }
    
            return classWriter.toByteArray();
        }
    }


    When looking for EntityPlayerSP in the console I find nothing. What can be the problem and is there any workaround?

    Here's a link to logs: https://pastebin.com/aEKyucjE

×
×
  • Create New...

Important Information

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