I have an event which fires when a "clam" item is used.
I would like to summon an item at the player's location, within the if/else statement shown below.
@SubscribeEvent
public static void clamUsed(PlayerInteractEvent.RightClickItem event) {
LivingEntity player = event.getEntityLiving();
ItemStack mainhand = player.getItemStackFromSlot(EquipmentSlotType.MAINHAND);
if (player.getHeldItemMainhand().getItem() == RegistryHandler.CLAM.get()) {
Random random = new Random();
if (random.nextInt(20 - 1 + 1) + 1 == 20) {
//Give the player Item A
}
else {
//Give the player Item B
}
mainhand.shrink(1);
}
}
How?
Here's my event, which fires when a fishing rod is cast (or reeled in, I'll fix that later).
@SubscribeEvent
public static void usedWorm(PlayerInteractEvent.RightClickItem event) {
LivingEntity player = event.getEntityLiving();
if (player.getHeldItemOffhand().getItem() == RegistryHandler.WORM.get()) {
if (player.getHeldItemMainhand().getItem() == Items.FISHING_ROD) {
player.addPotionEffect(new EffectInstance(Effects.LUCK, 2400));
//fairly certain the ItemStack thingy goes here, not sure about syntax though
}
}
}
The event is currently allowing the offhand item (the Worm) to be used an infinite number of times.
To maintain balance, a Worm must be consumed when this is done. It is absolutely imperative to catching funny fish.
I am unfamiliar with ItemStacks and their applications. Is it possible to dumb this down enough for my ogre brain to comprehend?
public class Main {
public static void main(String[] args) {
System.out.println("Sir, I'd greatly appreciate it if you at least told me what I did wrong.");
}
}
If you were asking for my issue...
REQUIRED TYPE: IItemProvider
PROVIDED: RegistryObject <net.minecraft.item.item>
If you were asking what my issue was, everything I touch breaks. It's hereditary, I think.
I'M SO SORRY, BUT AW BEANS, I MESSED IT UP.
event.getGenericTrades().add(new BasicTrade(3, new ItemStack(RegistryHandler.EXOTIC_SPICE, 1), 10, 10));
This is what I have. I probably did something stupid, but I don't know what.
Never mind. Apparently, my stupidity knows no bounds, because about 83 errors were returned.
I'm fairly certain that adding trades has to do with the BasicTrade class. however, and I've tried adding it into the method where I call the WandererTradesEvent. No luck so far, though.
Stupid as I may be, with the little experience in Java that I have, I will keep trying.
Can someone walk me through setting up a trade?