mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
Deprecate net.minecraftforge.common.util.Constants and inner classes to encourage usage of vanilla constants (#8140)
This commit is contained in:
1 parent
4a2572d545
commit
ebe375dac0
7 files changed
+118
-99
No files matched your search
@@ -22,6 +22,7 @@ package net.minecraftforge.common.util;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -135,7 +136,7 @@ public class BlockSnapshot
|
||||
BlockState current = getCurrentBlock();
|
||||
BlockState replaced = getReplacedBlock();
|
||||
|
||||
int flags = notifyNeighbors ? Constants.BlockFlags.DEFAULT : Constants.BlockFlags.BLOCK_UPDATE;
|
||||
int flags = notifyNeighbors ? Block.UPDATE_ALL : Block.UPDATE_CLIENTS;
|
||||
|
||||
if (current != replaced)
|
||||
{
|
||||
|
||||
@@ -19,10 +19,18 @@
|
||||
|
||||
package net.minecraftforge.common.util;
|
||||
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.LevelEvent;
|
||||
|
||||
/**
|
||||
* A class containing constants for magic numbers used in the minecraft codebase.
|
||||
* Everything here should be checked each update, and have a comment relating to where to check it.
|
||||
*
|
||||
* @deprecated No longer needed. See inner classes for replacements.
|
||||
* TODO Remove in 1.18
|
||||
*/
|
||||
@Deprecated(since = "1.17", forRemoval = true)
|
||||
public class Constants
|
||||
{
|
||||
/**
|
||||
@@ -31,116 +39,123 @@ public class Constants
|
||||
*
|
||||
* Main use is checking tag type in {@link net.minecraft.nbt.CompoundNBT#contains(String, int)}
|
||||
*
|
||||
* @deprecated Replaced by the constants in {@link net.minecraft.nbt.Tag}.
|
||||
* TODO Remove in 1.18
|
||||
*/
|
||||
@Deprecated(since = "1.17", forRemoval = true)
|
||||
public static class NBT
|
||||
{
|
||||
public static final int TAG_END = 0;
|
||||
public static final int TAG_BYTE = 1;
|
||||
public static final int TAG_SHORT = 2;
|
||||
public static final int TAG_INT = 3;
|
||||
public static final int TAG_LONG = 4;
|
||||
public static final int TAG_FLOAT = 5;
|
||||
public static final int TAG_DOUBLE = 6;
|
||||
public static final int TAG_BYTE_ARRAY = 7;
|
||||
public static final int TAG_STRING = 8;
|
||||
public static final int TAG_LIST = 9;
|
||||
public static final int TAG_COMPOUND = 10;
|
||||
public static final int TAG_INT_ARRAY = 11;
|
||||
public static final int TAG_LONG_ARRAY = 12;
|
||||
public static final int TAG_ANY_NUMERIC = 99;
|
||||
public static final int TAG_END = Tag.TAG_END;
|
||||
public static final int TAG_BYTE = Tag.TAG_BYTE;
|
||||
public static final int TAG_SHORT = Tag.TAG_SHORT;
|
||||
public static final int TAG_INT = Tag.TAG_INT;
|
||||
public static final int TAG_LONG = Tag.TAG_LONG;
|
||||
public static final int TAG_FLOAT = Tag.TAG_FLOAT;
|
||||
public static final int TAG_DOUBLE = Tag.TAG_DOUBLE;
|
||||
public static final int TAG_BYTE_ARRAY = Tag.TAG_BYTE_ARRAY;
|
||||
public static final int TAG_STRING = Tag.TAG_STRING;
|
||||
public static final int TAG_LIST = Tag.TAG_LIST;
|
||||
public static final int TAG_COMPOUND = Tag.TAG_COMPOUND;
|
||||
public static final int TAG_INT_ARRAY = Tag.TAG_INT_ARRAY;
|
||||
public static final int TAG_LONG_ARRAY = Tag.TAG_LONG_ARRAY;
|
||||
public static final int TAG_ANY_NUMERIC = Tag.TAG_ANY_NUMERIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* The world event IDS, used when calling {@link IWorld#playEvent(int, BlockPos, int)}. <br>
|
||||
* Can be found from {@link net.minecraft.client.renderer.WorldRenderer#playEvent}<br>
|
||||
* Some of the events use the {@code data} parameter. If this is the case, an explanation of what {@code data} does is also provided
|
||||
*
|
||||
* @deprecated Replaced by the constants in {@link net.minecraft.world.level.block.LevelEvent}.
|
||||
* TODO Remove in 1.18
|
||||
*/
|
||||
@Deprecated(since = "1.17", forRemoval = true)
|
||||
public static class WorldEvents {
|
||||
public static final int DISPENSER_DISPENSE_SOUND = 1000;
|
||||
public static final int DISPENSER_FAIL_SOUND = 1001;
|
||||
public static final int DISPENSER_DISPENSE_SOUND = LevelEvent.SOUND_DISPENSER_DISPENSE;
|
||||
public static final int DISPENSER_FAIL_SOUND = LevelEvent.SOUND_DISPENSER_FAIL;
|
||||
/**
|
||||
* Like DISPENSER_DISPENSE_SOUND, but for items that are fired (arrows, eggs, snowballs)
|
||||
*/
|
||||
public static final int DISPENSER_LAUNCH_SOUND = 1002;
|
||||
public static final int ENDEREYE_LAUNCH_SOUND = 1003;
|
||||
public static final int FIREWORK_SHOOT_SOUND = 1004;
|
||||
public static final int IRON_DOOR_OPEN_SOUND = 1005;
|
||||
public static final int WOODEN_DOOR_OPEN_SOUND = 1006;
|
||||
public static final int WOODEN_TRAPDOOR_OPEN_SOUND = 1007;
|
||||
public static final int FENCE_GATE_OPEN_SOUND = 1008;
|
||||
public static final int FIRE_EXTINGUISH_SOUND = 1009;
|
||||
public static final int DISPENSER_LAUNCH_SOUND = LevelEvent.SOUND_DISPENSER_PROJECTILE_LAUNCH;
|
||||
public static final int ENDEREYE_LAUNCH_SOUND = LevelEvent.SOUND_ENDER_EYE_LAUNCH;
|
||||
public static final int FIREWORK_SHOOT_SOUND = LevelEvent.SOUND_FIREWORK_SHOOT;
|
||||
public static final int IRON_DOOR_OPEN_SOUND = LevelEvent.SOUND_OPEN_IRON_DOOR;
|
||||
public static final int WOODEN_DOOR_OPEN_SOUND = LevelEvent.SOUND_OPEN_WOODEN_DOOR;
|
||||
public static final int WOODEN_TRAPDOOR_OPEN_SOUND = LevelEvent.SOUND_OPEN_WOODEN_TRAP_DOOR;
|
||||
public static final int FENCE_GATE_OPEN_SOUND = LevelEvent.SOUND_OPEN_FENCE_GATE;
|
||||
public static final int FIRE_EXTINGUISH_SOUND = LevelEvent.SOUND_EXTINGUISH_FIRE;
|
||||
/**
|
||||
* {@code data} is the item ID of the record you want to play
|
||||
*/
|
||||
public static final int PLAY_RECORD_SOUND = 1010;
|
||||
public static final int IRON_DOOR_CLOSE_SOUND = 1011;
|
||||
public static final int WOODEN_DOOR_CLOSE_SOUND = 1012;
|
||||
public static final int WOODEN_TRAPDOOR_CLOSE_SOUND = 1013;
|
||||
public static final int FENCE_GATE_CLOSE_SOUND = 1014;
|
||||
public static final int GHAST_WARN_SOUND = 1015;
|
||||
public static final int GHAST_SHOOT_SOUND = 1016;
|
||||
public static final int ENDERDRAGON_SHOOT_SOUND = 1017;
|
||||
public static final int BLAZE_SHOOT_SOUND = 1018;
|
||||
public static final int ZOMBIE_ATTACK_DOOR_WOOD_SOUND = 1019;
|
||||
public static final int ZOMBIE_ATTACK_DOOR_IRON_SOUND = 1020;
|
||||
public static final int ZOMBIE_BREAK_DOOR_WOOD_SOUND = 1021;
|
||||
public static final int WITHER_BREAK_BLOCK_SOUND = 1022;
|
||||
public static final int WITHER_BREAK_BLOCK = 1023;
|
||||
public static final int WITHER_SHOOT_SOUND = 1024;
|
||||
public static final int BAT_TAKEOFF_SOUND = 1025;
|
||||
public static final int ZOMBIE_INFECT_SOUND = 1026;
|
||||
public static final int ZOMBIE_VILLAGER_CONVERTED_SOUND = 1027;
|
||||
public static final int ANVIL_DESTROYED_SOUND = 1029;
|
||||
public static final int ANVIL_USE_SOUND = 1030;
|
||||
public static final int ANVIL_LAND_SOUND = 1031;
|
||||
public static final int PORTAL_TRAVEL_SOUND = 1032;
|
||||
public static final int CHORUS_FLOWER_GROW_SOUND = 1033;
|
||||
public static final int CHORUS_FLOWER_DEATH_SOUND = 1034;
|
||||
public static final int BREWING_STAND_BREW_SOUND = 1035;
|
||||
public static final int IRON_TRAPDOOR_CLOSE_SOUND = 1036;
|
||||
public static final int IRON_TRAPDOOR_OPEN_SOUND = 1037;
|
||||
public static final int PHANTOM_BITE_SOUND = 1039;
|
||||
public static final int ZOMBIE_CONVERT_TO_DROWNED_SOUND = 1040;
|
||||
public static final int HUSK_CONVERT_TO_ZOMBIE_SOUND = 1041;
|
||||
public static final int GRINDSTONE_USE_SOUND = 1042;
|
||||
public static final int ITEM_BOOK_TURN_PAGE_SOUND = 1043;
|
||||
public static final int PLAY_RECORD_SOUND = LevelEvent.SOUND_PLAY_RECORDING;
|
||||
public static final int IRON_DOOR_CLOSE_SOUND = LevelEvent.SOUND_CLOSE_IRON_DOOR;
|
||||
public static final int WOODEN_DOOR_CLOSE_SOUND = LevelEvent.SOUND_CLOSE_WOODEN_DOOR;
|
||||
public static final int WOODEN_TRAPDOOR_CLOSE_SOUND = LevelEvent.SOUND_CLOSE_WOODEN_TRAP_DOOR;
|
||||
public static final int FENCE_GATE_CLOSE_SOUND = LevelEvent.SOUND_CLOSE_FENCE_GATE;
|
||||
public static final int GHAST_WARN_SOUND = LevelEvent.SOUND_GHAST_WARNING;
|
||||
public static final int GHAST_SHOOT_SOUND = LevelEvent.SOUND_GHAST_FIREBALL;
|
||||
public static final int ENDERDRAGON_SHOOT_SOUND = LevelEvent.SOUND_DRAGON_FIREBALL;
|
||||
public static final int BLAZE_SHOOT_SOUND = LevelEvent.SOUND_BLAZE_FIREBALL;
|
||||
public static final int ZOMBIE_ATTACK_DOOR_WOOD_SOUND = LevelEvent.SOUND_ZOMBIE_WOODEN_DOOR;
|
||||
public static final int ZOMBIE_ATTACK_DOOR_IRON_SOUND = LevelEvent.SOUND_ZOMBIE_IRON_DOOR;
|
||||
public static final int ZOMBIE_BREAK_DOOR_WOOD_SOUND = LevelEvent.SOUND_ZOMBIE_DOOR_CRASH;
|
||||
public static final int WITHER_BREAK_BLOCK_SOUND = LevelEvent.SOUND_WITHER_BLOCK_BREAK;
|
||||
public static final int WITHER_BREAK_BLOCK = LevelEvent.SOUND_WITHER_BOSS_SPAWN;
|
||||
public static final int WITHER_SHOOT_SOUND = LevelEvent.SOUND_WITHER_BOSS_SHOOT;
|
||||
public static final int BAT_TAKEOFF_SOUND = LevelEvent.SOUND_BAT_LIFTOFF;
|
||||
public static final int ZOMBIE_INFECT_SOUND = LevelEvent.SOUND_ZOMBIE_INFECTED;
|
||||
public static final int ZOMBIE_VILLAGER_CONVERTED_SOUND = LevelEvent.SOUND_ZOMBIE_CONVERTED;
|
||||
public static final int ANVIL_DESTROYED_SOUND = LevelEvent.SOUND_ANVIL_BROKEN;
|
||||
public static final int ANVIL_USE_SOUND = LevelEvent.SOUND_ANVIL_USED;
|
||||
public static final int ANVIL_LAND_SOUND = LevelEvent.SOUND_ANVIL_LAND;
|
||||
public static final int PORTAL_TRAVEL_SOUND = LevelEvent.SOUND_PORTAL_TRAVEL;
|
||||
public static final int CHORUS_FLOWER_GROW_SOUND = LevelEvent.SOUND_CHORUS_GROW;
|
||||
public static final int CHORUS_FLOWER_DEATH_SOUND = LevelEvent.SOUND_CHORUS_DEATH;
|
||||
public static final int BREWING_STAND_BREW_SOUND = LevelEvent.SOUND_BREWING_STAND_BREW;
|
||||
public static final int IRON_TRAPDOOR_CLOSE_SOUND = LevelEvent.SOUND_CLOSE_IRON_TRAP_DOOR;
|
||||
public static final int IRON_TRAPDOOR_OPEN_SOUND = LevelEvent.SOUND_OPEN_IRON_TRAP_DOOR;
|
||||
public static final int PHANTOM_BITE_SOUND = LevelEvent.SOUND_PHANTOM_BITE;
|
||||
public static final int ZOMBIE_CONVERT_TO_DROWNED_SOUND = LevelEvent.SOUND_ZOMBIE_TO_DROWNED;
|
||||
public static final int HUSK_CONVERT_TO_ZOMBIE_SOUND = LevelEvent.SOUND_HUSK_TO_ZOMBIE;
|
||||
public static final int GRINDSTONE_USE_SOUND = LevelEvent.SOUND_GRINDSTONE_USED;
|
||||
public static final int ITEM_BOOK_TURN_PAGE_SOUND = LevelEvent.SOUND_PAGE_TURN;
|
||||
/**
|
||||
* Spawns the composter particles and plays the sound event sound event<br>
|
||||
* {@code data} is bigger than 0 when the composter can still be filled up, and is smaller or equal to 0 when the composter is full. (This only effects the sound event)
|
||||
*/
|
||||
public static final int COMPOSTER_FILLED_UP = 1500;
|
||||
public static final int LAVA_EXTINGUISH = 1501;
|
||||
public static final int REDSTONE_TORCH_BURNOUT = 1502;
|
||||
public static final int END_PORTAL_FRAME_FILL = 1503;
|
||||
public static final int COMPOSTER_FILLED_UP = LevelEvent.COMPOSTER_FILL;
|
||||
public static final int LAVA_EXTINGUISH = LevelEvent.LAVA_FIZZ;
|
||||
public static final int REDSTONE_TORCH_BURNOUT = LevelEvent.REDSTONE_TORCH_BURNOUT;
|
||||
public static final int END_PORTAL_FRAME_FILL = LevelEvent.END_PORTAL_FRAME_FILL;
|
||||
/**
|
||||
* {@code data} is the {@link Direction#getIndex()} of the direction the smoke is to come out of.
|
||||
*/
|
||||
public static final int DISPENSER_SMOKE = 2000;
|
||||
public static final int DISPENSER_SMOKE = LevelEvent.PARTICLES_SHOOT;
|
||||
|
||||
/**
|
||||
* {@code data} is the {@link net.minecraft.block.Block#getStateId state id} of the block broken
|
||||
*/
|
||||
public static final int BREAK_BLOCK_EFFECTS = 2001;
|
||||
public static final int BREAK_BLOCK_EFFECTS = LevelEvent.PARTICLES_DESTROY_BLOCK;
|
||||
/**
|
||||
* {@code data} is the rgb color int that should be used for the potion particles<br>
|
||||
* This is the same as {@link Constants.WorldEvents#POTION_IMPACT} but uses the particle type {@link ParticleTypes#EFFECT}
|
||||
*/
|
||||
public static final int POTION_IMPACT_INSTANT = 2002;
|
||||
public static final int ENDER_EYE_SHATTER = 2003;
|
||||
public static final int MOB_SPAWNER_PARTICLES = 2004;
|
||||
public static final int POTION_IMPACT_INSTANT = LevelEvent.PARTICLES_SPELL_POTION_SPLASH;
|
||||
public static final int ENDER_EYE_SHATTER = LevelEvent.PARTICLES_EYE_OF_ENDER_DEATH;
|
||||
public static final int MOB_SPAWNER_PARTICLES = LevelEvent.PARTICLES_MOBBLOCK_SPAWN;
|
||||
/**
|
||||
* {@code data} is the amount of particles to spawn. If {@code data} is 0 then there will be 15 particles spawned
|
||||
*/
|
||||
public static final int BONEMEAL_PARTICLES = 2005;
|
||||
public static final int DRAGON_FIREBALL_HIT = 2006;
|
||||
public static final int BONEMEAL_PARTICLES = LevelEvent.PARTICLES_PLANT_GROWTH;
|
||||
public static final int DRAGON_FIREBALL_HIT = LevelEvent.PARTICLES_DRAGON_FIREBALL_SPLASH;
|
||||
/**
|
||||
* {@code data} is the rgb color int that should be used for the potion particles<br>
|
||||
* This is the same as {@link Constants.WorldEvents#POTION_IMPACT_INSTANT} but uses the particle type {@link ParticleTypes#INSTANT_EFFECT}
|
||||
*/
|
||||
public static final int POTION_IMPACT = 2007;
|
||||
public static final int SPAWN_EXPLOSION_PARTICLE = 2008;
|
||||
public static final int GATEWAY_SPAWN_EFFECTS = 3000;
|
||||
public static final int ENDERMAN_GROWL_SOUND = 3001;
|
||||
public static final int POTION_IMPACT = LevelEvent.PARTICLES_INSTANT_POTION_SPLASH;
|
||||
public static final int SPAWN_EXPLOSION_PARTICLE = LevelEvent.PARTICLES_DRAGON_BLOCK_BREAK;
|
||||
public static final int GATEWAY_SPAWN_EFFECTS = LevelEvent.ANIMATION_END_GATEWAY_SPAWN;
|
||||
public static final int ENDERMAN_GROWL_SOUND = LevelEvent.ANIMATION_DRAGON_SUMMON_ROAR;
|
||||
}
|
||||
|
||||
|
||||
@@ -151,28 +166,32 @@ public class Constants
|
||||
* {@link World#markAndNotifyBlock}, and
|
||||
* {@link WorldRenderer#notifyBlockUpdate}<br>
|
||||
* Flags can be combined with bitwise OR
|
||||
*
|
||||
* @deprecated Replaced by the constants in {@link net.minecraft.world.level.block.Block}.
|
||||
* TODO Remove in 1.18
|
||||
*/
|
||||
@Deprecated(since = "1.17", forRemoval = true)
|
||||
public static class BlockFlags {
|
||||
/**
|
||||
* Calls
|
||||
* {@link Block#neighborChanged(BlockState, World, BlockPos, Block, BlockPos, boolean)
|
||||
* neighborChanged} on surrounding blocks (with isMoving as false). Also updates comparator output state.
|
||||
*/
|
||||
public static final int NOTIFY_NEIGHBORS = (1 << 0);
|
||||
public static final int NOTIFY_NEIGHBORS = Block.UPDATE_NEIGHBORS;
|
||||
/**
|
||||
* Calls {@link World#notifyBlockUpdate(BlockPos, BlockState, BlockState, int)}.<br>
|
||||
* Server-side, this updates all the path-finding navigators.
|
||||
*/
|
||||
public static final int BLOCK_UPDATE = (1 << 1);
|
||||
public static final int BLOCK_UPDATE = Block.UPDATE_CLIENTS;
|
||||
/**
|
||||
* Stops the blocks from being marked for a render update
|
||||
*/
|
||||
public static final int NO_RERENDER = (1 << 2);
|
||||
public static final int NO_RERENDER = Block.UPDATE_INVISIBLE;
|
||||
/**
|
||||
* Makes the block be re-rendered immediately, on the main thread.
|
||||
* If NO_RERENDER is set, then this will be ignored
|
||||
*/
|
||||
public static final int RERENDER_MAIN_THREAD = (1 << 3);
|
||||
public static final int RERENDER_MAIN_THREAD = Block.UPDATE_IMMEDIATE;
|
||||
/**
|
||||
* Causes neighbor updates to be sent to all surrounding blocks (including
|
||||
* diagonals). This in turn will call
|
||||
@@ -181,13 +200,13 @@ public class Constants
|
||||
* {@link Block#updateNeighbors(BlockState, IWorld, BlockPos, int)
|
||||
* updateNeighbors} on the new state.
|
||||
*/
|
||||
public static final int UPDATE_NEIGHBORS = (1 << 4);
|
||||
public static final int UPDATE_NEIGHBORS = Block.UPDATE_KNOWN_SHAPE;
|
||||
|
||||
/**
|
||||
* Prevents neighbor changes from spawning item drops, used by
|
||||
* {@link Block#replaceBlock(BlockState, BlockState, IWorld, BlockPos, int)}.
|
||||
*/
|
||||
public static final int NO_NEIGHBOR_DROPS = (1 << 5);
|
||||
public static final int NO_NEIGHBOR_DROPS = Block.UPDATE_SUPPRESS_DROPS;
|
||||
|
||||
/**
|
||||
* Tell the block being changed that it was moved, rather than removed/replaced,
|
||||
@@ -195,9 +214,9 @@ public class Constants
|
||||
* {@link Block#onReplaced(BlockState, World, BlockPos, BlockState, boolean)}
|
||||
* as the last parameter.
|
||||
*/
|
||||
public static final int IS_MOVING = (1 << 6);
|
||||
public static final int IS_MOVING = Block.UPDATE_MOVE_BY_PISTON;
|
||||
|
||||
public static final int DEFAULT = NOTIFY_NEIGHBORS | BLOCK_UPDATE;
|
||||
public static final int DEFAULT_AND_RERENDER = DEFAULT | RERENDER_MAIN_THREAD;
|
||||
public static final int DEFAULT = Block.UPDATE_ALL;
|
||||
public static final int DEFAULT_AND_RERENDER = Block.UPDATE_ALL_IMMEDIATE;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user