Villager Profession?

Started by BetaDv_ on

Topic category: Help with Minecraft modding (Java Edition)

Active 3 months ago
Joined Nov 2020
Points:
588

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 10
Villager Profession?

How could I make a villager with a Proffesion: "Scammer", what he does, is setup fake trades, and whenever the user trades, he gets nothing in Exchange, and just gets scammed overall. I know I can make a gui and all that, but if I could use the default gui so it looks credible, and make it spawn in villages it would be best, if anyone has any idea how I could get this done (even if it involves code) I would really apreciate if you could help me! :)

 

Active 2 hours ago
Joined Mar 2021
Points:
956

User statistics:

  • Modifications: 3
  • Forum topics: 37
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 451
Just use default vanilla gui…
Thu, 10/21/2021 - 19:16

Just use default vanilla gui and apply it

In trade you can get something like AIR

Make villagers spawn in villages with return conditions

 

Active 6 months ago
Joined Oct 2020
Points:
1573

User statistics:

  • Modifications: 0
  • Forum topics: 15
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 1874
like woodcreatures said,…
Thu, 10/21/2021 - 20:16

like woodcreatures said, just make a new villager with the exact same texture and download the GUI from Google or .minecraft folder and use this: MCreator Tutorial: How to make NPC Trades | 2020.3 - YouTube

a workaround could be with commands, by summoning a Vanilla Villager with a custom trade Minecraft 1.16.4: How to make a custom villager trades - Bing video however I don't think this is a good option

 

Active 2 years ago
Joined Apr 2018
Points:
740

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 125
Well.. you can make custom…
Thu, 10/21/2021 - 20:23

Well.. you can make custom professions and trades for villagers, there is even registry for that.

This feature is going to be in MCreator in future.

But you can make it right now with coding.

I can explain this too you and even provide example(from my mod).

 

 

Active 3 months ago
Joined Nov 2020
Points:
588

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 10
I'd love if you could help…
Thu, 10/21/2021 - 22:43

I'd love if you could help me do this, Frostygames. Any time you are available, could you send me the code and stuff?

 

Active 2 years ago
Joined Apr 2018
Points:
740

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 125
Sure, here: https://github…
Fri, 10/22/2021 - 04:23

Sure, here: https://github.com/Frostygames0/Elemental-Amulets/blob/master/src/main/java/frostygames0/elementalamulets/init/ModVillagers.java

This is how to register villagers. Use register method in the constructor of your main class.

Also, anything lower than registerWandererTrades is not needed.

 To give your villager a working outfit: https://github.com/Frostygames0/Elemental-Amulets/tree/master/src/main/resources/assets/elementalamulets/textures/entity

 

 

 

 

 

Active 2 years ago
Joined Apr 2018
Points:
740

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 125
Also a small note: if you…
Fri, 10/22/2021 - 04:27

Also a small note: if you copy the code, then the license of your mod should be GPL v3 or any compatible license and not “all rights reserved”

 

Active 3 months ago
Joined Nov 2020
Points:
588

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 10
Hey, I understand how this…
Fri, 10/22/2021 - 07:44

Hey, I understand how this code works, but doesn't this actually give me the item? I want it to not give anything back xd

 

Active 2 years ago
Joined Apr 2018
Points:
740

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 125
If you want it to return…
Fri, 10/22/2021 - 10:10

If you want it to return empty item then use ItemStack.EMPTY in BasicTrade's constructor instead of new ItemStack(Item instance).

Or you can create your own trade class. 

 

Active 3 months ago
Joined Nov 2020
Points:
588

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 10
Well yes, but wouldn't work…
Fri, 10/22/2021 - 14:50

Well yes, but wouldn't work as I intended. I want to show the item, but when the user goes to take it, it removes it and it takes his emeralds and stuff

 

Active 3 months ago
Joined Nov 2020
Points:
588

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 10
That's at least what I think…
Fri, 10/22/2021 - 14:50

That's at least what I think it will do

 

Active 3 months ago
Joined Nov 2020
Points:
588

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 10
I have a question. Since I…
Fri, 10/22/2021 - 15:04

I have a question. Since I don't know any bit of Java really, only Javascript, which is very different. Could you explain to me a bit how to port this to my mod? If it helps my package name is:
me.betadv.better_vanilla

Thx in Advance, you are nice! :)

 

Active 2 years ago
Joined Apr 2018
Points:
740

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 125
package me.betadv.better…
Sat, 10/23/2021 - 09:53

package me.betadv.better_vanilla;

import com.google.common.collect.ImmutableSet;
import net.minecraft.block.Blocks;
import net.minecraft.entity.merchant.villager.VillagerProfession;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.SoundEvents;
import net.minecraft.village.PointOfInterestType;
import net.minecraftforge.common.BasicTrade;
import net.minecraftforge.event.village.VillagerTradesEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

@Mod.EventBusSubscriber(modid = "YOUR_MOD_ID")
public class ScammerVillager {
    public static final DeferredRegister<VillagerProfession> PROFESSIONS = DeferredRegister.create(ForgeRegistries.PROFESSIONS, "YOUR_MOD_ID");
    public static final DeferredRegister<PointOfInterestType> POI_TYPES = DeferredRegister.create(ForgeRegistries.POI_TYPES, "YOUR_MOD_ID");

    public static final RegistryObject<PointOfInterestType> SCAMMER_POI = POI_TYPES.register("scammer",
            () -> new PointOfInterestType("scammer", PointOfInterestType.getBlockStates(Blocks.AIR), 1, 1));
    public static final RegistryObject<VillagerProfession> SCAMMER = PROFESSIONS.register("scammer",
            () -> new VillagerProfession("scammer", SCAMMER_POI.get(), ImmutableSet.of(), ImmutableSet.of(), SoundEvents.VILLAGER_NO));

    // PUT THIS METHOD IN YOUR MAIN CLASS CONSTRUCTOR(Method that has the name of main class) (It's called like your mod)
    public static void register() {
        IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
        POI_TYPES.register(bus);
        PROFESSIONS.register(bus);
    }

    @SubscribeEvent
    public static void registerTrades(final VillagerTradesEvent event) {
        if(event.getType() == SCAMMER.get()) {
            event.getTrades().get(1).add(new BasicTrade(1, new ItemStack(Items.DIAMOND, 5), 10, 1, 1f));
            // EXAMPLE TRADE (price, Item, max amount of trades before the "recharge", xp villager gets, price multiplier)
        }
    }
}

1.Replace YOUR MOD ID with your mod id, also call your file as ScammerVillager

2.Call register method in your mod constructor like that: ScammerVillager.register()

3. That should be all

Active 3 months ago
Joined Nov 2020
Points:
588

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 10
YOO, thanks so much man! You…
Sat, 10/23/2021 - 17:18

YOO, thanks so much man! You are so good! This has worked for me!

Active 2 years ago
Joined Apr 2018
Points:
740

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 125
NP, if you have any…
Sat, 10/23/2021 - 18:42

NP, if you have any questions just ask!