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

urbanxx001

Members
  • Posts

    181
  • Joined

  • Last visited

Posts posted by urbanxx001

  1. This post helped me when I was also tackling ItemModelProperties. You want to create a method in your item class that designates each itemstack change with a float, and register it with:

    DeferredWorkQueue.runLater(() -> {
        ItemModelsProperties.func_239418_a_(
                ModItems.YOUR_ITEM, new ResourceLocation(MOD_ID, "your_item"),
                (stack, world, entity) -> YourItemClass.yourMethod(stack));
    });

    And then specify the texture overrides in your item model json. Also you can find vanilla classes in External Libraries => Gradle net.minecraftforge:forge:[version]

  2. I have a RightClickEmpty event that needs to pass the server player into a method from an item class. However, event.getPlayer() only returns the client player. I heard that it should be done with packet handlers then, is that right? Alternatively, I could achieve the same thing with the onArmorTick method in the item class. But for that I would need to detect right clicking, which doesn't seem possible without an event. 

  3. 8 hours ago, Romejanic said:

    ease of development

    In terms of that, usually older versions will have more documentation (with the number of archived forum posts), but newer versions are easier to work with, such as with the new Deferred Registry system. That's probably obvious, but it's worth mentioning.

  4. A new latest.log isn't generated in run/logs, if you're referring to the separate file from the console log. Or I misunderstand. 

    Edit: Everything is resolved after adding the cursemaven plugin:

    plugins {
        id "com.wynprice.cursemaven" version "2.1.1"
    }

    Thank you anyway though!

  5. Full gradle:

    buildscript {
        repositories {
            maven { url = 'https://files.minecraftforge.net/maven' }
            jcenter()
            mavenCentral()
        }
        dependencies {
            classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
        }
    }
    apply plugin: 'net.minecraftforge.gradle'
    // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
    apply plugin: 'eclipse'
    apply plugin: 'maven-publish'
    
    version = '1.0'
    group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
    archivesBaseName = 'modid'
    
    sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
    
    println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
    minecraft {
        // The mappings can be changed at any time, and must be in the following format.
        // snapshot_YYYYMMDD   Snapshot are built nightly.
        // stable_#            Stables are built at the discretion of the MCP team.
        // Use non-default mappings at your own risk. they may not always work.
        // Simply re-run your setup task after changing the mappings to update your workspace.
        mappings channel: 'snapshot', version: '20200514-1.16'
        // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
        
        //accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
    
        // Default run configurations.
        // These can be tweaked, removed, or duplicated as needed.
        runs {
            client {
                workingDirectory project.file('run')
    
                // Recommended logging data for a userdev environment
                property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
    
                // Recommended logging level for the console
                property 'forge.logging.console.level', 'debug'
    
                mods {
                    examplemod {
                        source sourceSets.main
                    }
                }
            }
    
            server {
                workingDirectory project.file('run')
    
                // Recommended logging data for a userdev environment
                property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
    
                // Recommended logging level for the console
                property 'forge.logging.console.level', 'debug'
    
                mods {
                    examplemod {
                        source sourceSets.main
                    }
                }
            }
    
            data {
                workingDirectory project.file('run')
    
                // Recommended logging data for a userdev environment
                property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
    
                // Recommended logging level for the console
                property 'forge.logging.console.level', 'debug'
    
                args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/')
    
                mods {
                    examplemod {
                        source sourceSets.main
                    }
                }
            }
        }
    }
    
    dependencies {
       
        minecraft 'net.minecraftforge:forge:1.16.1-32.0.108'
        implementation fg.deobf("curse.maven:quark:3024740")
    }
    
    // Example configuration to allow publishing using the maven-publish task
    // This is the preferred method to reobfuscate your jar file
    jar.finalizedBy('reobfJar') 
    // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
    //publish.dependsOn('reobfJar')
    
    publishing {
        publications {
            mavenJava(MavenPublication) {
                artifact jar
            }
        }
        repositories {
            maven {
                url "file:///${project.projectDir}/mcmodsrepo"
            }
        }
    }

     

  6. So after attempting to refresh dependencies, the library isn't downloaded, even though the implementation and repository lines are correct. The error:

    Could not find curse.maven:quark:3024740_mapped_snapshot_20200514-1.16.
    Searched in the following locations:
      - https://files.minecraftforge.net/maven/curse/maven/quark/3024740_mapped_snapshot_20200514-1.16/quark-3024740_mapped_snapshot_20200514-1.16.pom
      - https://files.minecraftforge.net/maven/curse/maven/quark/3024740_mapped_snapshot_20200514-1.16/quark-3024740_mapped_snapshot_20200514-1.16.jar
      - file:/C:/Users/Name/.gradle/caches/forge_gradle/bundeled_repo/curse/maven/quark/3024740_mapped_snapshot_20200514-1.16/quark-3024740_mapped_snapshot_20200514-1.16.pom
      - file:/C:/Users/Name/.gradle/caches/forge_gradle/bundeled_repo/curse/maven/quark/3024740_mapped_snapshot_20200514-1.16/quark-3024740_mapped_snapshot_20200514-1.16.jar
      - https://libraries.minecraft.net/curse/maven/quark/3024740_mapped_snapshot_20200514-1.16/quark-3024740_mapped_snapshot_20200514-1.16.jar
      - https://repo.maven.apache.org/maven2/curse/maven/quark/3024740_mapped_snapshot_20200514-1.16/quark-3024740_mapped_snapshot_20200514-1.16.pom
      - https://repo.maven.apache.org/maven2/curse/maven/quark/3024740_mapped_snapshot_20200514-1.16/quark-3024740_mapped_snapshot_20200514-1.16.jar
    
  7. I'm implementing a soft dependency (gradle calls it module) in build.gradle. For instance, I looked at another mod's source that adds content associated with the quark mod:

    dependencies {
        implementation fg.deobf("curse.maven:quark:3024740")
    }

    However, I don't know what the number represents and where to find it for other mods. It doesn't seem related to the version number.

  8. 4 hours ago, vemerion said:

    Try changing the last return to -1.

    That did the trick, thanks for your help yesterday and now today. I wonder why it wasn't that way in the tutorial. Fixed Layer0 by using fillItemGroup, I first avoided it as I thought it would register 2 instances of the item. 

  9. Yeah. In the main class:

    eventBus.addListener(ColorHandler::registerItemColors);

    With:

    public class ColorHandler {
    
        public static void registerItemColors(ColorHandlerEvent.Item event) {
            event.getItemColors().register(DyeableBackpackItem::getItemColor, ModItems.LEATHER_BACKPACK);
        }
    }
  10. After following a tutorial I still have a small problem (I know the anti-tut ppl will berate me). Layer0 is dyeable but returns a black color, and layer1 (overlay) returns the default color that layer0 should be. The layer0 texture is properly grayscale. Item code below. It's probably due to getItemColor, but I've toyed with it with no success

     
    
    public class DyeableBackpackItem extends Item implements IBackpack {
    
       private final Backpack backpack;
       private static final String NBT_COLOR = "BackpackColor";
    
       public DyeableBackpackItem(Backpack backpack, Properties properties) {
          super(properties);
          this.backpack = backpack;
       }
    
       public static int getBackpackColor(ItemStack stack) {
          return stack.getOrCreateTag().getInt(NBT_COLOR);
       }
    
       public static void setBackpackColor(ItemStack stack, int color) {
          stack.getOrCreateTag().putInt(NBT_COLOR, color);
       }
    
       public static int getItemColor(ItemStack stack, int tintIndex) {
          if (tintIndex == 0) {
             return getBackpackColor(stack);
          }
          return 10511680;
       }
    
       @Override
       public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
    
          ItemStack itemstack = playerIn.getHeldItem(handIn);
    
          if (playerIn.isSneaking()) {
             if (!worldIn.isRemote && playerIn instanceof ServerPlayerEntity) {
    
                double pX = playerIn.getPosX();
                double pY = playerIn.getPosY();
                double pZ = playerIn.getPosZ();
    
                worldIn.playSound(null, pX, pY + 0.5D, pZ, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, SoundCategory.PLAYERS, 1.0F, 1.0F);
                open((ServerPlayerEntity)playerIn, itemstack, handIn == Hand.MAIN_HAND ? playerIn.inventory.currentItem : -1);
    
                return ActionResult.resultConsume(itemstack);
             }
          }
          return ActionResult.resultFail(itemstack);
       }
    
       @Override
       public void open(ServerPlayerEntity player, ItemStack stack, int selectedSlot) {
          NetworkHooks.openGui(player, new SimpleNamedContainerProvider((id, playerInventory, openPlayer) -> new BackpackContainer(id, playerInventory, new BackpackInventory(stack, backpack.getInventorySize()), backpack, selectedSlot), stack.getDisplayName()), buffer -> {
             buffer.writeEnumValue(backpack);
             buffer.writeVarInt(selectedSlot);
          });
       }
       
       public Backpack getBackpack() {
          return backpack;
       }
    
       // Fixes bug
    
       @Override
       public CompoundNBT getShareTag(ItemStack stack) {
          if (ServerConfig.getInstance().shareAllNBTData.get()) {
             return super.getShareTag(stack);
          }
          if (!stack.hasTag()) {
             return null;
          }
          final CompoundNBT compound = stack.getTag().copy();
          compound.remove("Items");
          if (compound.isEmpty()) {
             return null;
          }
          return compound;
       }
    
       // Fixes bug
       
       @Override
       public boolean onDroppedByPlayer(ItemStack item, PlayerEntity player) {
          return !(player.openContainer instanceof BackpackContainer);
       }
    }
  11. 12 minutes ago, Draco18s said:

    Why are you suing a mutable blockpos when you aren't reusing it?

    Originally used for updating the Blockstate Y position in another loop. Was playing around with the loop, but removed it. The world null line is just to suppress a message that pops up in the editor. 

    16 minutes ago, Draco18s said:

    Inline this garbage or use intelligent variable names.

    Flag is a good name as that's what they're used for. But I guess what you're saying is that their purpose isn't immediately obvious to someone else reviewing the code. 

    21 minutes ago, Draco18s said:

    Yes, INSIDE the NON WALKABLE BLOCK."

    You're right it should tp around that position instead, thanks for catching that. Will fix it. 

  12. In the following effect method, I'd like the player to teleport to a block that's within their line of site. It does so by iterating over positions in the sight vector over a distance (16 in this case). There's no response in game however. Alternatively, I tested setPositionAndUpdate without flag3, which is the raw function used in attemptTeleport, but this gives wild results, with teleports that don't match the line of sight and often clip under the world. Any help is appreciated.

    @Override
    public void performEffect(LivingEntity entityLiving, int amplifier) {
        Minecraft instance = Minecraft.getInstance();
    
        final Vector3d vLook = entityLiving.getLook(1.0F);
        int d = 16;
    
        for (int i = 1; i <= d; i++) {
            double bX = vLook.getX() * i;
            double bY = vLook.getY() * i;
            double bZ = vLook.getY() * i;
    
            BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable(bX, bY, bZ);
            assert instance.world != null;
            boolean flag1 = instance.world.getBlockState(blockpos$mutable).getMaterial().blocksMovement();
            boolean flag2 = i == d;
            boolean flag3 = entityLiving.attemptTeleport(bX, bY, bZ, true);
    
            if ((flag1 || flag2) && flag3) {
                //entityLiving.setPositionAndUpdate(bX, bY, bZ);
                SoundEvent soundevent = SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT;
                instance.world.playSound(null, entityLiving.prevPosX, entityLiving.prevPosY, entityLiving.prevPosZ, soundevent, SoundCategory.PLAYERS, 1.0F, 1.0F);
                entityLiving.playSound(soundevent, 1.0F, 1.0F);
            }
        }
    }

     

  13. I'm not sure if this will hide the effect names like you want, but try:

    public static final DeferredRegister<Effect> EFFECTS = DeferredRegister.create(ForgeRegistries.POTIONS, Main.MOD_ID);
    
    public static RegistryObject<Effect> INVULNERABILITY = EFFECTS.register("invulnerability", InvulnerabilityEffect::new);
    

     

    (Yes, ForgeRegistries.POTIONS). And then, in the InvulnerabilityEffect class:

    public class InvulnerabilityEffect extends Effect {
    
        public InvulnerabilityEffect() {
            super(EffectType.BENEFICIAL, color);
        }
    
        @Override
        public void performEffect(LivingEntity entityLivingBaseIn, int amplifier) {
        entityLivingBaseIn.addPotionEffect(new EffectInstance(Effects.REGENERATION, 432, 1));
        entityLivingBaseIn.addPotionEffect(new EffectInstance(Effects.RESISTANCE, 432, 1));
        entityLivingBaseIn.addPotionEffect(new EffectInstance(Effects.FIRE_RESISTANCE, 432, 1));
    }
    
        @Override
        public void affectEntity(@Nullable Entity source, @Nullable Entity indirectSource, LivingEntity entityLivingBaseIn, int amplifier, double health) {
        this.performEffect(entityLivingBaseIn, amplifier);
    }

     

    Where color must be replaced with a hex number. Then the item food properties will accept it with:

    ModEffects.INVULNERABILITY.get()

    If this doesn't work, you'll probably need to delve in the source code and replicate the 3 effects that way. You're right that heal() is tied to regeneration. Resistance and fire resistance are handled by attackEntityfrom() and applyPotionDamageCalculation() methods, respectively.

  14. 54 minutes ago, ChampionAsh5357 said:

    most of the information has never been validated

    That's why they usually launch the code in the test environment to show viewers that it works.

     

    54 minutes ago, ChampionAsh5357 said:

    You should use documentation

    The Documentation is good for reference, but they "avoid examples in lieu of more thorough explanations" (from the github). This is great from the perspective of someone who already knows the basics and needs to brush up, but it feels disconnected when just starting out. Right now it's only for 1.15 as well (although most of that can apply to 1.16).

×
×
  • Create New...

Important Information

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