mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 19:39:22 +00:00
* Bump pack.mcmeta formats * 1.19 biome modifiers * Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable * Add docs and package-info to client extension interfaces package * Move RenderBlockOverlayEvent hooks to ForgeHooksClient * Add package-infos to client events package * Rename SoundLoadEvent to SoundEngineLoadEvent This reduces confusion from consumers which may think the name SoundLoadEvent refers to an individual sound being loaded rather than the sound engine. * Document and change SoundLoadEvent to fire on mod bus Previously, it fired on both the mod bus and the Forge bus, which is confusing for consumers. * Delete SoundSetupEvent Looking at its original implementation shows that there isn't an appropriate place in the new sound code to reinsert the event, and the place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent. * Perform some cleanup on client events - Removed nullable annotations from ClientPlayerNetworkEvent - Renamed #getPartialTicks methods to #getPartialTick, to be consistent with vanilla's naming of the partial tick - Cleanup documentation to remove line breaks, use the spelling 'cancelled' over 'canceled', and improve docs on existing and new methods. * Remove EntityEvent.CanUpdate Closes MinecraftForge/MinecraftForge#6394 * Switch to Jetbrains nullability annotations * New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent * Remove ForgeWorldPresetScreens * Remove IForgeRegistryEntry * Remove use of List<Throwable> in FML's CompletableFutures * Add docs to mod loading stages, stages, and phases * Gradle 7.4.2 * Use SLF4J in FMLLoader and other subprojects * Switch dynamic versions in subprojects to pinned ones * Switch ForgeRoot and MDK to FG plugin markers * Configure Forge javadoc task The task now uses a custom stylesheet with MCForge elements, and configured to combine the generation from the four FML subprojects (fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project into the javadoc output. * Update docs/md files, for 1.19 update and the move away from IRC to Discord. * Make "Potentially dangerous alternative prefix" a debug warning, not info. Co-authored-by: Curle <[email protected]> Co-authored-by: sciwhiz12 <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
112 lines
3.1 KiB
Java
112 lines
3.1 KiB
Java
/*
|
|
* Copyright (c) Forge Development LLC and contributors
|
|
* SPDX-License-Identifier: LGPL-2.1-only
|
|
*/
|
|
|
|
package net.minecraftforge.common;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.Random;
|
|
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.util.random.WeightedEntry;
|
|
import net.minecraft.util.random.WeightedRandom;
|
|
import net.minecraft.world.entity.EntityType;
|
|
|
|
public class DungeonHooks
|
|
{
|
|
private static ArrayList<DungeonMob> dungeonMobs = new ArrayList<DungeonMob>();
|
|
|
|
/**
|
|
* Adds a mob to the possible list of creatures the spawner will create.
|
|
* If the mob is already in the spawn list, the rarity will be added to the existing one,
|
|
* causing the mob to be more common.
|
|
*
|
|
* @param type Monster type
|
|
* @param rarity The rarity of selecting this mob over others. Must be greater then 0.
|
|
* Vanilla Minecraft has the following mobs:
|
|
* Spider 100
|
|
* Skeleton 100
|
|
* Zombie 200
|
|
* Meaning, Zombies are twice as common as spiders or skeletons.
|
|
* @return The new rarity of the monster,
|
|
*/
|
|
public static float addDungeonMob(EntityType<?> type, int rarity)
|
|
{
|
|
if (rarity <= 0)
|
|
{
|
|
throw new IllegalArgumentException("Rarity must be greater then zero");
|
|
}
|
|
|
|
Iterator<DungeonMob> itr = dungeonMobs.iterator();
|
|
while (itr.hasNext())
|
|
{
|
|
DungeonMob mob = itr.next();
|
|
if (type == mob.type)
|
|
{
|
|
itr.remove();
|
|
rarity = mob.getWeight().asInt() + rarity;
|
|
break;
|
|
}
|
|
}
|
|
|
|
dungeonMobs.add(new DungeonMob(rarity, type));
|
|
return rarity;
|
|
}
|
|
|
|
/**
|
|
* Will completely remove a Mob from the dungeon spawn list.
|
|
*
|
|
* @param name The name of the mob to remove
|
|
* @return The rarity of the removed mob, prior to being removed.
|
|
*/
|
|
public static int removeDungeonMob(EntityType<?> name)
|
|
{
|
|
for (DungeonMob mob : dungeonMobs)
|
|
{
|
|
if (name == mob.type)
|
|
{
|
|
dungeonMobs.remove(mob);
|
|
return mob.getWeight().asInt();
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* Gets a random mob name from the list.
|
|
* @param rand World generation random number generator
|
|
* @return The mob name
|
|
*/
|
|
public static EntityType<?> getRandomDungeonMob(RandomSource rand)
|
|
{
|
|
DungeonMob mob = WeightedRandom.getRandomItem(rand, dungeonMobs).orElseThrow();
|
|
return mob.type;
|
|
}
|
|
|
|
|
|
public static class DungeonMob extends WeightedEntry.IntrusiveBase
|
|
{
|
|
public final EntityType<?> type;
|
|
public DungeonMob(int weight, EntityType<?> type)
|
|
{
|
|
super(weight);
|
|
this.type = type;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object target)
|
|
{
|
|
return target instanceof DungeonMob && type.equals(((DungeonMob)target).type);
|
|
}
|
|
}
|
|
|
|
static
|
|
{
|
|
addDungeonMob(EntityType.SKELETON, 100);
|
|
addDungeonMob(EntityType.ZOMBIE, 200);
|
|
addDungeonMob(EntityType.SPIDER, 100);
|
|
}
|
|
}
|