How to make a pressure plate output redstone given condition.

Started by The_Pamps on

Topic category: Help with modding (Java Edition)

Last seen on 14:21, 28. Jun 2023
Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make a pressure plate output redstone given condition.

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 13:58, 21. Jan 2023
Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • 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 01:18, 28. Mar 2024
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • 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 13:58, 21. Jan 2023
Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • 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;
	}
}