net.minecraft.entity.EntityCategory Java Examples
The following examples show how to use
net.minecraft.entity.EntityCategory.
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: PumpkinPatchBiome.java From the-hallow with MIT License | 6 votes |
public PumpkinPatchBiome() { super(new Settings().surfaceBuilder(SURFACE_BUILDER).precipitation(Precipitation.NONE).category(Category.PLAINS).depth(0.125f).scale(0.07f).temperature(0.7f).downfall(0.8f).waterColor(0x3F76E4).waterFogColor(0x050533)); GRASS_COLOR = 0xC9C92A; FOLIAGE_COLOR = 0xC9C92A; this.addStructureFeature(Feature.MINESHAFT.configure(new MineshaftFeatureConfig(0.004D, MineshaftFeature.Type.NORMAL))); HallowedBiomeFeatures.addGrass(this); HallowedBiomeFeatures.addLakes(this); //is not the same as other biome pumpkins, do not use HallowedBiomeFeatures pumpkins this.addFeature(GenerationStep.Feature.VEGETAL_DECORATION, HallowedBiomeFeatures.configureFeature(HallowedFeatures.COLORED_PUMPKIN, FeatureConfig.DEFAULT, Decorator.COUNT_HEIGHTMAP_DOUBLE, new CountDecoratorConfig(10))); HallowedBiomeFeatures.addDefaultHallowedTrees(this); this.addSpawn(EntityCategory.CREATURE, new SpawnEntry(HallowedEntities.PUMPCOWN, 8, 4, 8)); }
Example #2
Source File: ScytheItem.java From the-hallow with MIT License | 6 votes |
@Override public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity user) { if (!target.isAlive()) { if (target instanceof PlayerEntity) { // give player soul } else if (target instanceof WitherEntity) { // give withered soul } else { EntityCategory category = target.getType().getCategory(); switch (category) { case MONSTER: // give monster soul break; case CREATURE: case WATER_CREATURE: case AMBIENT: // give creature soul break; default: break; } } } return super.postHit(stack, target, user); }
Example #3
Source File: OverworldChunkGeneratorMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 6 votes |
@Inject( method = "getEntitySpawnList", at = @At(value = "INVOKE", ordinal = 1, shift = At.Shift.BEFORE, target = "Lnet/minecraft/world/gen/feature/StructureFeature;isApproximatelyInsideStructure(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;)Z"), cancellable = true ) private void onGetEntitySpawnList(EntityCategory category, BlockPos pos, CallbackInfoReturnable<List<Biome.SpawnEntry>> cir) { if (CarpetExtraSettings.straySpawningInIgloos) { if (Feature.IGLOO.isApproximatelyInsideStructure(this.world, pos)) { cir.setReturnValue(Feature.IGLOO.getMonsterSpawns()); } } if (CarpetExtraSettings.creeperSpawningInJungleTemples) { if (Feature.JUNGLE_TEMPLE.isApproximatelyInsideStructure(this.world, pos)) { cir.setReturnValue(Feature.JUNGLE_TEMPLE.getMonsterSpawns()); } } }
Example #4
Source File: SpawnReporter.java From fabric-carpet with MIT License | 6 votes |
public static void registerSpawn(DimensionType dim, MobEntity mob, EntityCategory cat, BlockPos pos) { if (lower_spawning_limit != null) { if (!( (lower_spawning_limit.getX() <= pos.getX() && pos.getX() <= upper_spawning_limit.getX()) && (lower_spawning_limit.getY() <= pos.getY() && pos.getY() <= upper_spawning_limit.getY()) && (lower_spawning_limit.getZ() <= pos.getZ() && pos.getZ() <= upper_spawning_limit.getZ()) )) { return; } } Pair<DimensionType, EntityCategory> key = Pair.of(mob.dimension, cat); long count = spawn_stats.get(key).getOrDefault(mob.getType(), 0L); spawn_stats.get(key).put(mob.getType(), count + 1); spawned_mobs.get(key).put(Pair.of(mob.getType(), pos)); local_spawns.put(cat, local_spawns.get(cat)+1); }
Example #5
Source File: SpawnReporter.java From fabric-carpet with MIT License | 6 votes |
public static List<BaseText> printEntitiesByType(EntityCategory cat, World worldIn, boolean all) //Class<?> entityType) { List<BaseText> lst = new ArrayList<>(); lst.add( Messenger.s(String.format("Loaded entities for %s class:", get_type_string(cat)))); for (Entity entity : ((ServerWorld)worldIn).getEntities(null, (e) -> e.getType().getCategory()==cat)) { boolean persistent = entity instanceof MobEntity && ( ((MobEntity) entity).isPersistent() || ((MobEntity) entity).cannotDespawn()); if (!all && persistent) continue; EntityType type = entity.getType(); BlockPos pos = entity.getBlockPos(); lst.add( Messenger.c( "w - ", Messenger.tp(persistent?"gb":"wb",pos), String.format(persistent?"g : %s":"w : %s", type.getName().getString()) )); } if (lst.size()==1) { lst.add(Messenger.s(" - Empty.")); } return lst; }
Example #6
Source File: SpawnReporter.java From fabric-carpet with MIT License | 6 votes |
public static EntityCategory get_creature_type_from_code(String type_code) { if ("hostile".equalsIgnoreCase(type_code)) { return EntityCategory.MONSTER; } else if ("passive".equalsIgnoreCase(type_code)) { return EntityCategory.CREATURE; } else if ("water".equalsIgnoreCase(type_code)) { return EntityCategory.WATER_CREATURE; } else if ("ambient".equalsIgnoreCase(type_code)) { return EntityCategory.AMBIENT; } return null; }
Example #7
Source File: SpawnCommand.java From fabric-carpet with MIT License | 5 votes |
private static int setMobcaps(ServerCommandSource source, int hostile_cap) { double desired_ratio = (double)hostile_cap/ EntityCategory.MONSTER.getSpawnCap(); SpawnReporter.mobcap_exponent = 4.0*Math.log(desired_ratio)/Math.log(2.0); Messenger.m(source, String.format("gi Mobcaps for hostile mobs changed to %d, other groups will follow", hostile_cap)); return 1; }
Example #8
Source File: PerimeterDiagnostics.java From fabric-carpet with MIT License | 5 votes |
private PerimeterDiagnostics(ServerWorld server, EntityCategory ctype, MobEntity el) { this.sle = null; this.worldServer = server; this.ctype = ctype; this.el = el; }
Example #9
Source File: Messenger.java From fabric-carpet with MIT License | 5 votes |
public static String creatureTypeColor(EntityCategory type) { switch (type) { case MONSTER: return "n"; case CREATURE: return "e"; case AMBIENT: return "f"; case WATER_CREATURE: return "v"; } return "w"; }
Example #10
Source File: SpawnReporter.java From fabric-carpet with MIT License | 5 votes |
public static List<BaseText> recent_spawns(World world, EntityCategory creature_type) { List<BaseText> lst = new ArrayList<>(); if ((track_spawns == 0L)) { lst.add(Messenger.s("Spawn tracking not started")); return lst; } String type_code = creature_type.getName(); lst.add(Messenger.s(String.format("Recent %s spawns:",type_code))); for (Pair<EntityType, BlockPos> pair : spawned_mobs.get(Pair.of(world.getDimension().getType(),creature_type)).keySet()) { lst.add( Messenger.c( "w - ", Messenger.tp("wb",pair.getRight()), String.format("w : %s", pair.getLeft().getName().getString()) )); } if (lst.size()==1) { lst.add(Messenger.s(" - Nothing spawned yet, sorry.")); } return lst; }
Example #11
Source File: SpawnReporter.java From fabric-carpet with MIT License | 5 votes |
public static List<BaseText> show_mobcaps(BlockPos pos, World worldIn) { DyeColor under = WoolTool.getWoolColorAtPosition(worldIn, pos.down()); if (under == null) { if (track_spawns > 0L) { return tracking_report(worldIn); } else { return printMobcapsForDimension(worldIn.dimension.getType(), true ); } } EntityCategory creature_type = get_type_code_from_wool_code(under); if (creature_type != null) { if (track_spawns > 0L) { return recent_spawns(worldIn, creature_type); } else { return printEntitiesByType(creature_type, worldIn, true); } } if (track_spawns > 0L) { return tracking_report(worldIn); } else { return printMobcapsForDimension(worldIn.dimension.getType(), true ); } }
Example #12
Source File: SpawnReporter.java From fabric-carpet with MIT License | 5 votes |
public static EntityCategory get_type_code_from_wool_code(DyeColor color) { switch (color) { case RED: return EntityCategory.MONSTER; case GREEN: return EntityCategory.CREATURE; case BLUE: return EntityCategory.WATER_CREATURE; case BROWN: return EntityCategory.AMBIENT; } return null; }
Example #13
Source File: SpawnReporter.java From fabric-carpet with MIT License | 5 votes |
public static void reset_spawn_stats(boolean full) { spawn_stats.clear(); spawned_mobs.clear(); for (EntityCategory enumcreaturetype : EntityCategory.values()) { if (full) { spawn_tries.put(enumcreaturetype, 1); } for (DimensionType dim : DimensionType.getAll()) { Pair<DimensionType, EntityCategory> key = Pair.of(dim, enumcreaturetype); overall_spawn_ticks.put(key, 0L); spawn_attempts.put(key, 0L); spawn_ticks_full.put(key, 0L); spawn_ticks_fail.put(key, 0L); spawn_ticks_succ.put(key, 0L); spawn_ticks_spawns.put(key, 0L); spawn_cap_count.put(key, 0L); spawn_stats.put(key, new Object2LongOpenHashMap<>()); spawned_mobs.put(key, new EvictingQueue<>()); } } track_spawns = 0L; }
Example #14
Source File: ServerChunkManagerMixin.java From fabric-carpet with MIT License | 5 votes |
@SuppressWarnings("UnresolvedMixinReference") @Redirect(method = "method_20801", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/SpawnHelper;spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/util/math/BlockPos;)V" )) // inject our repeat of spawns if more spawn ticks per tick are chosen. private void spawnMultipleTimes(EntityCategory entityCategory_1, ServerWorld world_1, WorldChunk worldChunk_1, BlockPos blockPos_1) { for (int i = 0; i < SpawnReporter.spawn_tries.get(entityCategory_1); i++) { SpawnHelper.spawnEntitiesInChunk(entityCategory_1, world_1, worldChunk_1, blockPos_1); } }
Example #15
Source File: OverworldChunkGeneratorMixin.java From fabric-carpet with MIT License | 5 votes |
@Inject(method = "getEntitySpawnList", at = @At(value = "INVOKE", ordinal = 1, shift = At.Shift.BEFORE, target = "Lnet/minecraft/world/gen/feature/StructureFeature;isApproximatelyInsideStructure(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;)Z"), cancellable = true) private void onGetEntitySpawnList(EntityCategory entityCategory_1, BlockPos blockPos_1, CallbackInfoReturnable<List<Biome.SpawnEntry>> cir) { if (CarpetSettings.huskSpawningInTemples) { if (Feature.DESERT_PYRAMID.isApproximatelyInsideStructure(this.world, blockPos_1)) { cir.setReturnValue(Feature.DESERT_PYRAMID.getMonsterSpawns()); } } }
Example #16
Source File: FloatingIslandsChunkGeneratorMixin.java From fabric-carpet with MIT License | 5 votes |
@Override public List<Biome.SpawnEntry> getEntitySpawnList(EntityCategory entityCategory_1, BlockPos blockPos_1) { if (CarpetSettings.shulkerSpawningInEndCities && EntityCategory.MONSTER == entityCategory_1) { if (Feature.END_CITY.isInsideStructure(this.world, blockPos_1)) { return Feature.END_CITY.getMonsterSpawns(); } } return this.world.getBiome(blockPos_1).getEntitySpawnList(entityCategory_1); }
Example #17
Source File: SpawnHelperMixin.java From fabric-carpet with MIT License | 5 votes |
@Redirect(method = "spawnEntitiesInChunk", at = @At( value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;squaredDistanceTo(DDD)D" )) private static double getSqDistanceTo(PlayerEntity playerEntity, double double_1, double double_2, double double_3, EntityCategory entityCategory_1, ServerWorld world_1, WorldChunk worldChunk_1, BlockPos blockPos_1) { double distanceTo = playerEntity.squaredDistanceTo(double_1, double_2, double_3); if (CarpetSettings.lagFreeSpawning && distanceTo > 16384.0D && entityCategory_1 != EntityCategory.CREATURE) return 0.0; return distanceTo; }
Example #18
Source File: SpawnCommand.java From fabric-carpet with MIT License | 5 votes |
private static int resetSpawnRates(ServerCommandSource source) { for (EntityCategory s: SpawnReporter.spawn_tries.keySet()) { SpawnReporter.spawn_tries.put(s,1); } Messenger.m(source, "gi Spawn rates brought to 1 round per tick for all groups."); return 1; }
Example #19
Source File: HallowedBaseBiome.java From the-hallow with MIT License | 5 votes |
protected HallowedBaseBiome(Settings settings) { super(settings.parent(null)); DefaultBiomeFeatures.addLandCarvers(this); HallowedBiomeFeatures.addDecoration(this); HallowedBiomeFeatures.addDisks(this); HallowedBiomeFeatures.addOres(this); HallowedBiomeFeatures.addMineables(this); this.addSpawn(EntityCategory.CREATURE, new SpawnEntry(HallowedEntities.CROW, 40, 1, 2)); this.addSpawn(EntityCategory.MONSTER, new SpawnEntry(EntityType.ENDERMAN, 10, 1, 4)); this.addSpawn(EntityCategory.MONSTER, new SpawnEntry(EntityType.WITCH, 5, 1, 1)); this.addSpawn(EntityCategory.MONSTER, new SpawnEntry(HallowedEntities.MUMMY, 95, 4, 4)); BIOMES.add(this); }
Example #20
Source File: WorldEvent.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
public PotentialSpawns(IWorld world, EntityCategory type, BlockPos pos, List<SpawnEntry> oldList) { super(world); this.pos = pos; this.type = type; if (oldList != null) { this.list = new ArrayList<SpawnEntry>(oldList); } else { this.list = new ArrayList<SpawnEntry>(); } }
Example #21
Source File: WorldEvents.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
public static List<Biome.SpawnEntry> getPotentialSpawns(IWorld world, EntityCategory type, BlockPos pos, List<Biome.SpawnEntry> oldSpawns) { WorldEvent.PotentialSpawns event = new WorldEvent.PotentialSpawns(world, type, pos, oldSpawns); if (MinecraftForge.EVENT_BUS.post(event)) { return Collections.emptyList(); } return event.getList(); }
Example #22
Source File: SpawnCommand.java From fabric-carpet with MIT License | 5 votes |
private static int setSpawnRates(ServerCommandSource source, String mobtype, int rounds) throws CommandSyntaxException { EntityCategory cat = getCategory(mobtype); SpawnReporter.spawn_tries.put(cat, rounds); Messenger.m(source, "gi "+mobtype+" mobs will now spawn "+rounds+" times per tick"); return 1; }
Example #23
Source File: SpawnCommand.java From fabric-carpet with MIT License | 5 votes |
private static EntityCategory getCategory(String string) throws CommandSyntaxException { if (!Arrays.stream(EntityCategory.values()).map(EntityCategory::getName).collect(Collectors.toSet()).contains(string)) { throw new SimpleCommandExceptionType(Messenger.c("r Wrong mob type: "+string+" should be "+ Arrays.stream(EntityCategory.values()).map(EntityCategory::getName).collect(Collectors.joining(", ")))).create(); } return EntityCategory.valueOf(string.toUpperCase()); }
Example #24
Source File: SpawnCommand.java From fabric-carpet with MIT License | 4 votes |
private static int recentSpawnsForType(ServerCommandSource source, String mob_type) throws CommandSyntaxException { EntityCategory cat = getCategory(mob_type); Messenger.send(source, SpawnReporter.recent_spawns(source.getWorld(), cat)); return 1; }
Example #25
Source File: HallowedChunkGenerator.java From the-hallow with MIT License | 4 votes |
@Override public List<Biome.SpawnEntry> getEntitySpawnList(EntityCategory category, BlockPos pos) { // Custom feature spawn stuff goes here return super.getEntitySpawnList(category, pos); }
Example #26
Source File: FlatChunkGeneratorMixin.java From fabric-carpet with MIT License | 4 votes |
@Override public List<Biome.SpawnEntry> getEntitySpawnList(EntityCategory category, BlockPos pos) { if (CarpetSettings.flatWorldStructureSpawning) { if (Feature.SWAMP_HUT.method_14029(this.world, pos)) { if (category == EntityCategory.MONSTER) { return Feature.SWAMP_HUT.getMonsterSpawns(); } if (category == EntityCategory.CREATURE) { return Feature.SWAMP_HUT.getCreatureSpawns(); } } else if (category == EntityCategory.MONSTER) { if (Feature.PILLAGER_OUTPOST.isApproximatelyInsideStructure(this.world, pos)) { return Feature.PILLAGER_OUTPOST.getMonsterSpawns(); } if (CarpetSettings.huskSpawningInTemples) { if (Feature.DESERT_PYRAMID.isApproximatelyInsideStructure(this.world, pos)) { return Feature.DESERT_PYRAMID.getMonsterSpawns(); } } if (Feature.OCEAN_MONUMENT.isApproximatelyInsideStructure(this.world, pos)) { return Feature.OCEAN_MONUMENT.getMonsterSpawns(); } if (Feature.NETHER_BRIDGE.isInsideStructure(this.world, pos)) { return Feature.NETHER_BRIDGE.getMonsterSpawns(); } if (Feature.NETHER_BRIDGE.isApproximatelyInsideStructure(this.world, pos) && this.world.getBlockState(pos.down(1)).getBlock() == Blocks.NETHER_BRICKS) { return Feature.NETHER_BRIDGE.getMonsterSpawns(); } if (CarpetSettings.shulkerSpawningInEndCities) { if (Feature.END_CITY.isInsideStructure(this.world, pos)) { return Feature.END_CITY.getMonsterSpawns(); } } } } return super.getEntitySpawnList(category, pos); }
Example #27
Source File: SpawnCommand.java From fabric-carpet with MIT License | 4 votes |
private static int listEntitiesOfType(ServerCommandSource source, String mobtype, boolean all) throws CommandSyntaxException { EntityCategory cat = getCategory(mobtype); Messenger.send(source, SpawnReporter.printEntitiesByType(cat, source.getWorld(), all)); return 1; }
Example #28
Source File: ServerChunkManagerMixin.java From fabric-carpet with MIT License | 4 votes |
@Inject(method = "tickChunks", at = @At("RETURN")) private void onFinishSpawnWorldCycle(CallbackInfo ci) { LevelProperties levelProperties_1 = this.world.getLevelProperties(); boolean boolean_3 = levelProperties_1.getTime() % 400L == 0L; if (SpawnReporter.track_spawns > 0L && SpawnReporter.local_spawns != null) { for (EntityCategory cat: EntityCategory.values()) { DimensionType dim = world.dimension.getType(); Pair key = Pair.of(world.dimension.getType(), cat); int spawnTries = SpawnReporter.spawn_tries.get(cat); if (!SpawnReporter.local_spawns.containsKey(cat)) { if (!cat.isAnimal() || boolean_3) { // fill mobcaps for that category so spawn got cancelled SpawnReporter.spawn_ticks_full.put(key, SpawnReporter.spawn_ticks_full.get(key)+ spawnTries); } } else if (SpawnReporter.local_spawns.get(cat) > 0) { // tick spawned mobs for that type SpawnReporter.spawn_ticks_succ.put(key, SpawnReporter.spawn_ticks_succ.get(key)+spawnTries); SpawnReporter.spawn_ticks_spawns.put(key, SpawnReporter.spawn_ticks_spawns.get(key)+ SpawnReporter.local_spawns.get(cat)); // this will be off comparing to 1.13 as that would succeed if // ANY tries in that round were successful. // there will be much more difficult to mix in // considering spawn tries to remove, as with warp // there is little need for them anyways. } else // spawn no mobs despite trying { //tick didn's spawn mobs of that type SpawnReporter.spawn_ticks_fail.put(key, SpawnReporter.spawn_ticks_fail.get(key)+spawnTries); } } } SpawnReporter.local_spawns = null; }
Example #29
Source File: ServerChunkManagerMixin.java From fabric-carpet with MIT License | 4 votes |
@SuppressWarnings("UnresolvedMixinReference") @Redirect(method = "method_20801", at = @At( value = "INVOKE", target = "Lnet/minecraft/entity/EntityCategory;getSpawnCap()I" )) // allows to change mobcaps and captures each category try per dimension before it fails due to full mobcaps. private int getNewMobcaps(EntityCategory entityCategory) { DimensionType dim = this.world.dimension.getType(); int newCap = (int) ((double)entityCategory.getSpawnCap()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4)))); if (SpawnReporter.track_spawns > 0L) { int int_2 = SpawnReporter.chunkCounts.get(dim); // eligible chunks for spawning int int_3 = newCap * int_2 / CHUNKS_ELIGIBLE_FOR_SPAWNING; //current spawning limits int mobCount = SpawnReporter.mobCounts.get(dim).getInt(entityCategory); if (SpawnReporter.track_spawns > 0L && !SpawnReporter.first_chunk_marker.contains(entityCategory)) { SpawnReporter.first_chunk_marker.add(entityCategory); //first chunk with spawn eligibility for that category Pair key = Pair.of(dim, entityCategory); int spawnTries = SpawnReporter.spawn_tries.get(entityCategory); SpawnReporter.spawn_attempts.put(key, SpawnReporter.spawn_attempts.get(key) + spawnTries); SpawnReporter.spawn_cap_count.put(key, SpawnReporter.spawn_cap_count.get(key) + mobCount); } if (mobCount <= int_3 || SpawnReporter.mock_spawns) { //place 0 to indicate there were spawn attempts for a category //if (entityCategory != EntityCategory.CREATURE || world.getServer().getTicks() % 400 == 0) // this will only be called once every 400 ticks anyways SpawnReporter.local_spawns.putIfAbsent(entityCategory, 0L); //else //full mobcaps - and key in local_spawns will be missing } } return SpawnReporter.mock_spawns?Integer.MAX_VALUE:newCap; }
Example #30
Source File: WorldEvent.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
public EntityCategory getType() { return type; }