net.minecraft.entity.SpawnRestriction Java Examples
The following examples show how to use
net.minecraft.entity.SpawnRestriction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MixinSpawnHelper.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
@Inject(method = "canSpawn(Lnet/minecraft/entity/SpawnRestriction$Location;Lnet/minecraft/world/CollisionView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/EntityType;)Z", at = @At(value = "INVOKE", target = "net/minecraft/world/CollisionView.getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;"), cancellable = true) private static void handleCustomSpawnRestrictionLocation(SpawnRestriction.Location location, CollisionView world, BlockPos pos, EntityType<?> type, CallbackInfoReturnable<Boolean> callback) { PatchworkSpawnRestrictionLocation patchworkLocation = (PatchworkSpawnRestrictionLocation) (Object) location; if (patchworkLocation.patchwork_useVanillaBehavior()) { return; } callback.setReturnValue(patchworkLocation.canSpawnAt(world, pos, type)); }
Example #2
Source File: HallowedEntities.java From the-hallow with MIT License | 4 votes |
public static void init() { @SuppressWarnings("unused") Object classloading = SpawnRestriction.class; SpawnRestrictionInvoker.invokeRegister(HallowedEntities.MUMMY, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, HostileEntity::canSpawnInDark); EntityComponentCallback.event(VillagerEntity.class).register((player, components) -> components.put(CANDY, new VillagerCandyComponent())); }
Example #3
Source File: SpawnRestrictionInvoker.java From the-hallow with MIT License | 4 votes |
@Invoker public static <T extends MobEntity> void invokeRegister(EntityType<T> type, SpawnRestriction.Location location, Heightmap.Type heightmapType, SpawnRestriction.SpawnPredicate<T> restriction) { throw new UnsupportedOperationException(); }
Example #4
Source File: EnumHacks.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
public static SpawnRestriction.Location createSpawnRestrictionLocation(String name, TriPredicate<CollisionView, BlockPos, EntityType<?>> predicate) { SpawnRestriction.Location instance = constructAndAdd(SpawnRestriction.Location.class, ordinal -> SpawnRestrictionLocationAccessor.invokeConstructor(name, ordinal)); ((PatchworkSpawnRestrictionLocation) (Object) instance).patchwork_setPredicate(predicate); return instance; }
Example #5
Source File: SpawnRestrictionLocationAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Invoker("<init>") static SpawnRestriction.Location invokeConstructor(String name, int ordinal) { throw new IllegalStateException("Mixin did not transform accessor! Something is very wrong!"); }
Example #6
Source File: MixinSpawnRestrictionLocation.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void patchwork_setValues(SpawnRestriction.Location[] values) { field_6319 = values; }
Example #7
Source File: IForgeBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 2 votes |
/** * Determines if a specified mob type can spawn on this block, returning false will * prevent any mob from spawning on the block. * * @param state The current state * @param world The current world * @param pos Block position in world * @param restriction The location spawn restriction * @param entityType The type of entity attempting to spawn * @return True to allow a mob of the specified category to spawn, false to prevent it. */ default boolean canCreatureSpawn(BlockState state, BlockView world, BlockPos pos, SpawnRestriction.Location restriction, @Nullable EntityType<?> entityType) { return state.allowsSpawning(world, pos, entityType); }