How to make a pressure plate output redstone given condition.

Started by The_Pamps on Mon, 05/09/2022 - 14:43

Topic category: Help with modding (Java Edition)

Last seen on 02:20, 9. Jun 2022
Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How to make a pressure plate output redstone given condition.
Mon, 05/09/2022 - 14:43

Hi all,

I am trying to add pressure plates to my mod that are only activated by certain entities, how would I go about this?

For example, a pressure plate that is only activated by a zombie or "undead" entity type.

Thanks in advance,

The Pamps

Last seen on 19:18, 4. Jun 2022
Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
do you want it to increase…
Sat, 05/14/2022 - 00:08

do you want it to increase the more of them it has?

Last seen on 16:02, 17. Jun 2022
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
If your using a custom block…
Sat, 05/14/2022 - 00:18

If your using a custom block, there should be a trigger called "When Enity Walks On This Block" put your procedure on that one, and use a IF statement that reads IF Event/Entity is creature type 'Undead' > then do your logic. Alternatively you can type in the search box "sub" and a block should come up named "Is Event/Entity (sub)type" and that will allow you choose a specific type of mob.

Last seen on 19:18, 4. Jun 2022
Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
This code should be what you…
Sat, 05/14/2022 - 00:29

This code should be what you want.

public class LaunchAtHeadpointingProcedure {
	public static boolean execute(LevelAccessor world, double x, double y, double z) {
		boolean undeadPresent = false;
		undeadPresent = false;
		{
			final Vec3 _center = new Vec3(x, y, z);
			List<Entity> _entfound = world.getEntitiesOfClass(Entity.class, new AABB(_center, _center).inflate(1 / 2d), e -> true).stream()
					.sorted(Comparator.comparingDouble(_entcnd -> _entcnd.distanceToSqr(_center))).collect(Collectors.toList());
			for (Entity entityiterator : _entfound) {
				if (entityiterator instanceof LivingEntity _livEnt ? _livEnt.getMobType() == MobType.UNDEAD : false) {
					undeadPresent = true;
					break;
				}
			}
		}
		return undeadPresent;
	}
}