mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-18 14:11:30 +01:00
Backport minecart-item-type fix from f5467001
.
This commit is contained in:
parent
8db0053ffc
commit
b0ebbee3de
@ -1013,14 +1013,16 @@ private static <T extends Event & Cancellable> void handleBlockRightClick(T even
|
||||
|
||||
// Handle created Minecarts
|
||||
if (item != null && Materials.isMinecart(item.getType())) {
|
||||
// TODO: Give a more specific Minecart type
|
||||
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, clicked.getLocation().add(0.5, 0, 0.5), EntityType.MINECART));
|
||||
EntityType entityType = Materials.getRelatedEntity(item.getType());
|
||||
if (entityType == null) {
|
||||
entityType = EntityType.MINECART;
|
||||
}
|
||||
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), entityType));
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle created boats
|
||||
if (item != null && Materials.isBoat(item.getType())) {
|
||||
// TODO as above
|
||||
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), EntityType.BOAT));
|
||||
return;
|
||||
}
|
||||
|
@ -806,6 +806,17 @@ public static Material getRelatedMaterial(EntityType type) {
|
||||
return ENTITY_ITEMS.get(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the related entity type for a material.
|
||||
*
|
||||
* @param material the material
|
||||
* @return the related entity type or {@code null} if one is not known or exists
|
||||
*/
|
||||
@Nullable
|
||||
public static EntityType getRelatedEntity(Material material) {
|
||||
return ENTITY_ITEMS.inverse().get(material);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the material of the block placed by the given bucket, defaulting
|
||||
* to water if the bucket type is not known.
|
||||
|
Loading…
Reference in New Issue
Block a user