-
Notifications
You must be signed in to change notification settings - Fork 1
/
PassthroughSignsAPI.java
48 lines (42 loc) · 1.71 KB
/
PassthroughSignsAPI.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.girafi.passthroughsigns.api;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.HashSet;
import java.util.Set;
public class PassthroughSignsAPI {
public static IPassable passable;
public static final Set<Block> BLOCK_PASSABLES = new HashSet<>();
public static final Set<EntityType<?>> ENTITY_PASSABLES = new HashSet<>();
/**
* Can be used to make a block/entity based on its registry name from string passable
* Example of use of intermod communication : InterModComms.sendTo("passthroughsigns", "registerPassable", "block/entity registry name");
*
* @param string the string of a blocks registry name or a entities class string
*/
public static void setCanBePassed(String string) {
ResourceLocation resourceLocation = new ResourceLocation(string);
if (ForgeRegistries.ENTITY_TYPES.containsKey(resourceLocation)) {
ENTITY_PASSABLES.add(ForgeRegistries.ENTITY_TYPES.getValue(resourceLocation));
} else if (ForgeRegistries.BLOCKS.containsKey(resourceLocation)) {
BLOCK_PASSABLES.add(ForgeRegistries.BLOCKS.getValue(resourceLocation));
}
}
/**
* Convenience method for making a block passable
*
* @param block the block
**/
public static void setCanBePassed(Block block) {
BLOCK_PASSABLES.add(block);
}
/**
* Convenience method for making a entity passable
*
* @param entityType the entity type
**/
public static void setCanBePassed(EntityType entityType) {
ENTITY_PASSABLES.add(entityType);
}
}