Topic category: Help with modding (Java Edition)
I'm trying to make a procedure that needs to give the player a certain item from other mod
I don't know how to code so I need help as I was unable to find any tutorial. I know that it might be possible with editing the code of the procedure but I can't make it work.
ANY WAY of giving the player this item will do the job.
Info of the item that might be useful:
Mod Name: "Mr Crayfish Vehicle Mod"
Item name: Large Engine
registry item name: vehicle:iron_large_engine
modid: vehicle
If we need any other info ask me.
The full code of the procedure: (did not implement the item yet.) We need to replace the "GoldenMagnetItem" for the item specified above.
package roleplayplus.procedures;
import roleplayplus.item.MoneyBillItem;
import roleplayplus.item.GoldMagnetItem;
import roleplayplus.RoleplayPlusModElements;
import roleplayplus.RoleplayPlusMod;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.Entity;
import java.util.Map;
@RoleplayPlusModElements.ModElement.Tag
public class BuyMotorPProcedure extends RoleplayPlusModElements.ModElement {
public BuyMotorPProcedure(RoleplayPlusModElements instance) {
super(instance, 76);
}
public static void executeProcedure(Map<String, Object> dependencies) {
if (dependencies.get("entity") == null) {
if (!dependencies.containsKey("entity"))
RoleplayPlusMod.LOGGER.warn("Failed to load dependency entity for procedure BuyMotorP!");
return;
}
Entity entity = (Entity) dependencies.get("entity");
if (((entity instanceof PlayerEntity)
? ((PlayerEntity) entity).inventory.hasItemStack(new ItemStack(MoneyBillItem.block, (int) (1)))
: false)) {
if (entity instanceof PlayerEntity) {
ItemStack _stktoremove = new ItemStack(MoneyBillItem.block, (int) (1));
((PlayerEntity) entity).inventory.func_234564_a_(p -> _stktoremove.getItem() == p.getItem(), (int) 1,
((PlayerEntity) entity).container.func_234641_j_());
}
if (((entity instanceof PlayerEntity)
? ((PlayerEntity) entity).inventory.hasItemStack(new ItemStack(MoneyBillItem.block, (int) (1)))
: false)) {
if (entity instanceof PlayerEntity) {
ItemStack _stktoremove = new ItemStack(MoneyBillItem.block, (int) (1));
((PlayerEntity) entity).inventory.func_234564_a_(p -> _stktoremove.getItem() == p.getItem(), (int) 1,
((PlayerEntity) entity).container.func_234641_j_());
}
if (((entity instanceof PlayerEntity)
? ((PlayerEntity) entity).inventory.hasItemStack(new ItemStack(MoneyBillItem.block, (int) (1)))
: false)) {
if (entity instanceof PlayerEntity) {
ItemStack _stktoremove = new ItemStack(MoneyBillItem.block, (int) (1));
((PlayerEntity) entity).inventory.func_234564_a_(p -> _stktoremove.getItem() == p.getItem(), (int) 1,
((PlayerEntity) entity).container.func_234641_j_());
}
if (((entity instanceof PlayerEntity)
? ((PlayerEntity) entity).inventory.hasItemStack(new ItemStack(MoneyBillItem.block, (int) (1)))
: false)) {
if (entity instanceof PlayerEntity) {
ItemStack _stktoremove = new ItemStack(MoneyBillItem.block, (int) (1));
((PlayerEntity) entity).inventory.func_234564_a_(p -> _stktoremove.getItem() == p.getItem(), (int) 1,
((PlayerEntity) entity).container.func_234641_j_());
}
if (((entity instanceof PlayerEntity)
? ((PlayerEntity) entity).inventory.hasItemStack(new ItemStack(MoneyBillItem.block, (int) (1)))
: false)) {
if (entity instanceof PlayerEntity) {
ItemStack _stktoremove = new ItemStack(MoneyBillItem.block, (int) (1));
((PlayerEntity) entity).inventory.func_234564_a_(p -> _stktoremove.getItem() == p.getItem(), (int) 1,
((PlayerEntity) entity).container.func_234641_j_());
}
if (((entity instanceof PlayerEntity)
? ((PlayerEntity) entity).inventory.hasItemStack(new ItemStack(MoneyBillItem.block, (int) (1)))
: false)) {
if (entity instanceof PlayerEntity) {
ItemStack _stktoremove = new ItemStack(MoneyBillItem.block, (int) (1));
((PlayerEntity) entity).inventory.func_234564_a_(p -> _stktoremove.getItem() == p.getItem(), (int) 1,
((PlayerEntity) entity).container.func_234641_j_());
}
if (entity instanceof PlayerEntity) {
ItemStack _setstack = new ItemStack(GoldenMagnetItem.block, (int) (1));
_setstack.setCount((int) 1);
ItemHandlerHelper.giveItemToPlayer(((PlayerEntity) entity), _setstack);
}
} else {
if (entity instanceof PlayerEntity) {
ItemStack _setstack = new ItemStack(MoneyBillItem.block, (int) (1));
_setstack.setCount((int) 5);
ItemHandlerHelper.giveItemToPlayer(((PlayerEntity) entity), _setstack);
}
}
} else {
if (entity instanceof PlayerEntity) {
ItemStack _setstack = new ItemStack(MoneyBillItem.block, (int) (1));
_setstack.setCount((int) 4);
ItemHandlerHelper.giveItemToPlayer(((PlayerEntity) entity), _setstack);
}
}
} else {
if (entity instanceof PlayerEntity) {
ItemStack _setstack = new ItemStack(MoneyBillItem.block, (int) (1));
_setstack.setCount((int) 3);
ItemHandlerHelper.giveItemToPlayer(((PlayerEntity) entity), _setstack);
}
}
} else {
if (entity instanceof PlayerEntity) {
ItemStack _setstack = new ItemStack(MoneyBillItem.block, (int) (1));
_setstack.setCount((int) 2);
ItemHandlerHelper.giveItemToPlayer(((PlayerEntity) entity), _setstack);
}
}
} else {
if (entity instanceof PlayerEntity) {
ItemStack _setstack = new ItemStack(MoneyBillItem.block, (int) (1));
_setstack.setCount((int) 1);
ItemHandlerHelper.giveItemToPlayer(((PlayerEntity) entity), _setstack);
}
}
}
}
}
For now I have a workaround using the /give command but this may be useful to learn for the future if the target is not a player.