[TUTORIAL] Only one igniter for all custom portals

Started by Gizmodod on Fri, 03/12/2021 - 14:39

Topic category: User side tutorials

Last seen on 11:16, 1. Apr 2021
Joined Mar 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
[TUTORIAL] Only one igniter for all custom portals
Fri, 03/12/2021 - 14:43 (edited)

Hi, if you find yourself here, it's because you don't like having an ignater per portal. :)

So here is a little solution for you!

Let's go !!

 

IMPORTANT:

- Lock files when you save, or any changes will be removed after building files

- Do this only when you have completed all the configurations for your dimension.

Otherwise you will have to unlock your file to make your additions, and the changes will be removed.

 

When you create your second dimension, set the CreativeTab to None.

this

 

 

 

In your second ignate item file (ex: TutoIgnateItem2.java)

Make in comment or Delete the imported dimension file and public ActionResultType

//import net.username.modid.world.dimension.TutoDim2Dimension;

public class TutoIgnateItem2 extends Item {
    @ObjectHolder("modid:tuto_ignate_2")
    public static final Item block = null;

    public TutoIgnateItem2() {
        super(new Properties().group(null).maxDamage(64));
    }

    /* 
    @Override
    public ActionResultType onItemUse(ItemUseContext context) {
        PlayerEntity entity = context.getPlayer();
        BlockPos pos = context.getPos().offset(context.getFace());
        ItemStack itemstack = context.getItem();
        World world = context.getWorld();
        if (!entity.canPlayerEdit(pos, context.getFace(), itemstack)) {
            return ActionResultType.FAIL;
        } else {
            int x = pos.getX();
            int y = pos.getY();
            int z = pos.getZ();
            if (world.isAirBlock(pos) && true)
                TutoDim2Dimension.portal.portalSpawn(world, pos);
            itemstack.damageItem(1, entity, c -> c.sendBreakAnimation(context.getHand()));
            return ActionResultType.SUCCESS;
        }
    }
    */
}

 

Now in your first Ignater item file add the import of your second dimension file

ex: import net.username.modid.world.dimension.TutoDimension2Dimension;

And add this line TutoDim2Dimension.portal.portalSpawn(world, pos);

At the line pointed by HERE ==>

import net.username.modid.world.dimension.TutoDim2Dimension;

public class TutoIgnateItem1 extends Item {
	@ObjectHolder("modid:tuto_ignate_1 ")
	public static final Item block = null;
	public TutoIgnateItem1() {
		super(new Item.Properties().group(ItemGroup.TOOLS).maxDamage(64));
	}

	@Override
	public ActionResultType onItemUse(ItemUseContext context) {
		PlayerEntity entity = context.getPlayer();
		BlockPos pos = context.getPos().offset(context.getFace());
		ItemStack itemstack = context.getItem();
		World world = context.getWorld();
		if (!entity.canPlayerEdit(pos, context.getFace(), itemstack)) {
			return ActionResultType.FAIL;
		} else {
			int x = pos.getX();
			int y = pos.getY();
			int z = pos.getZ();
			if (world.isAirBlock(pos) && true)
				TutoDim1Dimension.portal.portalSpawn(world, pos);
HERE ==>		TutoDim2Dimension.portal.portalSpawn(world, pos);
			itemstack.damageItem(1, entity, c -> c.sendBreakAnimation(context.getHand()));
			return ActionResultType.SUCCESS;
		}
	}
}

And you can continue that for your all ignate items

ENJOY NOW YOUR ONCE ONLY IGNATER FOR YOUR ALL CUSTOM PORTAL :D

 

Edited by Gizmodod on Fri, 03/12/2021 - 14:43