Added more Constants (#5323)

This commit is contained in:
Wyn Price authored and tterrag committed 2019-03-15 15:38:52 -04:00
1 parent 04a6b6c2d0
commit af4fcd73a4
6 files changed
+197 -23

No files matched your search

@@ -184,11 +184,13 @@ public class BlockSnapshot
IBlockState current = getCurrentBlock();
IBlockState replaced = getReplacedBlock();
int flags = notifyNeighbors ? Constants.BlockFlags.DEFAULT : Constants.BlockFlags.SEND_TO_CLIENTS;
if (current.getBlock() != replaced.getBlock() || current.getBlock().getMetaFromState(current) != replaced.getBlock().getMetaFromState(replaced))
{
if (force)
{
world.setBlockState(pos, replaced, notifyNeighbors ? 3 : 2);
world.setBlockState(pos, replaced, flags);
}
else
{
@@ -196,8 +198,8 @@ public class BlockSnapshot
}
}
world.setBlockState(pos, replaced, notifyNeighbors ? 3 : 2);
world.notifyBlockUpdate(pos, current, replaced, notifyNeighbors ? 3 : 2);
world.setBlockState(pos, replaced, flags);
world.notifyBlockUpdate(pos, current, replaced, flags);
TileEntity te = null;
if (getNbt() != null)
@@ -19,6 +19,8 @@
package net.minecraftforge.common.util;
import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance;
/**
* 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.
@@ -26,9 +28,9 @@ package net.minecraftforge.common.util;
public class Constants
{
/**
* NBT Tag type IDS, used when storing the nbt to disc, Should align with NBTBase.getId,
* NBT Tag type IDS, used when storing the nbt to disc, Should align with NBTBase.getId,
* table used in NBTBase.func_150283_g
*
*
* Main use is checking tag type in NBTTagCompound.func_150297_b(String, int)
*
*/
@@ -49,4 +51,170 @@ public class Constants
public static final int TAG_LONG_ARRAY = 12;
public static final int TAG_ANY_NUMERIC = 99;
}
/**
* The world event IDS, used when calling {@link net.minecraft.world.World#playEvent(net.minecraft.entity.player.EntityPlayer, int, net.minecraft.util.math.BlockPos, int)}. <br>
* Can be found from {@link net.minecraft.client.renderer.RenderGlobal#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
*/
public static class WorldEvents {
public static final int DISPENSER_DISPENSE_SOUND = 1000;
public static final int DISPENSER_FAIL_SOUND = 1001;
/**
* 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;
/**
* {@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;
/**
* {@code data} is the direction of the smoke, as a grid around the dispenser as follows (with 4 being the position of the dispenser):
* <pre>
* N
* 0 | 1 | 2
* ----------
* W 3 | 4 | 5 E
* ----------
* 6 | 7 | 8
* S
* </pre>
* Setting the {@code data} to 4 will mean the particles won't spawn
*/
public static final int DISPENSER_SMOKE = 2000;
/**
* {@code data} is the {@link net.minecraft.block.Block#getStateId state id} of the block broken
*/
public static final int BREAK_BLOCK_EFFECTS = 2001;
/**
* {@code data} is the rgb color int that should be used for the potion particles
*/
public static final int SPLASH_POTION_EFFECT = 2002;
public static final int ENDER_EYE_SHATTER = 2003;
public static final int MOB_SPAWNER_PARTICLES = 2004;
/**
* {@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;
/**
* {@code data} is the rgb color int that should be used for the potion particles
*/
public static final int LINGERING_POTION_EFFECT = 2007;
public static final int GATEWAY_SPAWN_EFFECTS = 3000;
public static final int ENDERMAN_GROWL_SOUND = 3001;
}
/**
* The flags used when calling {@link net.minecraft.world.World#setBlockState}<br>
* Can be found from {@link net.minecraft.world.World#markAndNotifyBlock} and {@link net.minecraft.client.renderer.RenderGlobal#notifyBlockUpdate}<br>
* Flags can be combined with bitwise OR
*/
public static class BlockFlags {
/**
* Calls neighborChanged on surrounding blocks
*/
public static final int NOTIFY_NEIGHBORS = 0b00001;
/**
* Sends the update to the client
*/
public static final int SEND_TO_CLIENTS = 0b00010;
/**
* Stops the blocks from being marked for a render update
*/
public static final int NO_RERENDER = 0b00100;
/**
* 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 = 0b01000;
/**
* Disables observers from seeing this update
*/
public static final int NO_OBSERVERS = 0b10000;
public static final int DEFAULT = NOTIFY_NEIGHBORS | SEND_TO_CLIENTS;
public static final int DEFAULT_AND_RERENDER = DEFAULT | RERENDER_MAIN_THREAD;
}
/**
* The mutex bits used for AI tasks {@link net.minecraft.entity.ai.EntityAIBase#setMutexBits(int)}
* Bits can be combined with bitwise OR
*/
public static class AiMutexBits {
public static final int MOVE = 0b001;
public static final int LOOK = 0b010;
public static final int JUMP = 0b100;
}
/**
* The flags used for {@link net.minecraft.entity.Entity#getFlag(int)} and {@link net.minecraft.entity.Entity#setFlag(int, boolean)}}<br>
* Can be found by searching for the usages of getFlag
*/
public static class EntityFlags {
public static final int BURNING = 0;
public static final int SNEAKING = 1;
public static final int SPRINTING = 3;
public static final int INVISIBLE = 5;
public static final int GLOWING = 6;
public static final int ELYTRA_FLYING = 7;
}
/**
* The operation used for Attribute modifier operations, {@link net.minecraft.entity.ai.attributes.AttributeModifier#AttributeModifier(String, double, int)}<br>
* Can be found at {@link ModifiableAttributeInstance#computeValue()}<br>
* The total value starts with the base value.<br>
* Order of operations are {@link #ADD}, {@link #ADD_MULTIPLE}, {@link #MULTIPLY}
* @see <a href="https://minecraft.gamepedia.com/Attribute#Operations">Minecraft Wiki</a>
*/
public static class AttributeModifierOperation {
/**
* The modifier value is added onto the total value
*/
public static final int ADD = 0;
/**
* The modifier value is multiplied by the original base value then added onto the total value
*/
public static final int ADD_MULTIPLE = 1;
/**
* The total value is multiplied by 1 + the modifier value
*/
public static final int MULTIPLY = 2;
}
}
@@ -33,6 +33,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.event.ForgeEventFactory;
import javax.annotation.Nonnull;
@@ -158,7 +159,7 @@ public class BlockFluidClassic extends BlockFluidBase
}
else
{
world.setBlockState(pos, state.withProperty(LEVEL, quantaPerBlock - expQuanta), 2);
world.setBlockState(pos, state.withProperty(LEVEL, quantaPerBlock - expQuanta), Constants.BlockFlags.SEND_TO_CLIENTS);
world.scheduleUpdate(pos, this, tickRate);
world.notifyNeighborsOfStateChange(pos, this, false);
}
@@ -280,7 +281,7 @@ public class BlockFluidClassic extends BlockFluidBase
if (meta < 0) return;
if (displaceIfPossible(world, pos))
{
world.setBlockState(pos, this.getDefaultState().withProperty(LEVEL, meta), 3);
world.setBlockState(pos, this.getDefaultState().withProperty(LEVEL, meta));
}
}
@@ -310,7 +311,7 @@ public class BlockFluidClassic extends BlockFluidBase
if (doPlace)
{
FluidUtil.destroyBlockOnFluidPlacement(world, pos);
world.setBlockState(pos, this.getDefaultState(), 11);
world.setBlockState(pos, this.getDefaultState(), Constants.BlockFlags.DEFAULT_AND_RERENDER);
}
return Fluid.BUCKET_VOLUME;
}
@@ -29,6 +29,7 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import javax.annotation.Nonnull;
@@ -97,7 +98,7 @@ public class BlockFluidFinite extends BlockFluidBase
changed = true;
if (quantaRemaining == 1)
{
world.setBlockState(pos, state.withProperty(LEVEL, quantaRemaining - 1), 2);
world.setBlockState(pos, state.withProperty(LEVEL, quantaRemaining - 1), Constants.BlockFlags.SEND_TO_CLIENTS);
return;
}
}
@@ -129,7 +130,7 @@ public class BlockFluidFinite extends BlockFluidBase
{
if (changed)
{
world.setBlockState(pos, state.withProperty(LEVEL, quantaRemaining - 1), 2);
world.setBlockState(pos, state.withProperty(LEVEL, quantaRemaining - 1), Constants.BlockFlags.SEND_TO_CLIENTS);
}
return;
}
@@ -158,7 +159,7 @@ public class BlockFluidFinite extends BlockFluidBase
}
else
{
world.setBlockState(off, getDefaultState().withProperty(LEVEL, newQuanta - 1), 2);
world.setBlockState(off, getDefaultState().withProperty(LEVEL, newQuanta - 1), Constants.BlockFlags.SEND_TO_CLIENTS);
}
world.scheduleUpdate(off, this, tickRate);
}
@@ -170,7 +171,7 @@ public class BlockFluidFinite extends BlockFluidBase
{
++each;
}
world.setBlockState(pos, state.withProperty(LEVEL, each - 1), 2);
world.setBlockState(pos, state.withProperty(LEVEL, each - 1), Constants.BlockFlags.SEND_TO_CLIENTS);
}
public int tryToFlowVerticallyInto(World world, BlockPos pos, int amtToInput)
@@ -189,13 +190,13 @@ public class BlockFluidFinite extends BlockFluidBase
amt += amtToInput;
if (amt > quantaPerBlock)
{
world.setBlockState(other, myState.withProperty(LEVEL, quantaPerBlock - 1), 3);
world.setBlockState(other, myState.withProperty(LEVEL, quantaPerBlock - 1));
world.scheduleUpdate(other, this, tickRate);
return amt - quantaPerBlock;
}
else if (amt > 0)
{
world.setBlockState(other, myState.withProperty(LEVEL, amt - 1), 3);
world.setBlockState(other, myState.withProperty(LEVEL, amt - 1));
world.scheduleUpdate(other, this, tickRate);
world.setBlockToAir(pos);
return 0;
@@ -209,7 +210,7 @@ public class BlockFluidFinite extends BlockFluidBase
{
if (displaceIfPossible(world, other))
{
world.setBlockState(other, myState.withProperty(LEVEL, amtToInput - 1), 3);
world.setBlockState(other, myState.withProperty(LEVEL, amtToInput - 1));
world.scheduleUpdate(other, this, tickRate);
world.setBlockToAir(pos);
return 0;
@@ -225,8 +226,8 @@ public class BlockFluidFinite extends BlockFluidBase
if (density_other < density) // then swap
{
IBlockState state = world.getBlockState(other);
world.setBlockState(other, myState.withProperty(LEVEL, amtToInput - 1), 3);
world.setBlockState(pos, state, 3);
world.setBlockState(other, myState.withProperty(LEVEL, amtToInput - 1));
world.setBlockState(pos, state);
world.scheduleUpdate(other, this, tickRate);
world.scheduleUpdate(pos, state.getBlock(), state.getBlock().tickRate(world));
return 0;
@@ -237,8 +238,8 @@ public class BlockFluidFinite extends BlockFluidBase
if (density_other > density)
{
IBlockState state = world.getBlockState(other);
world.setBlockState(other, myState.withProperty(LEVEL, amtToInput - 1), 3);
world.setBlockState(pos, state, 3);
world.setBlockState(other, myState.withProperty(LEVEL, amtToInput - 1));
world.setBlockState(pos, state);
world.scheduleUpdate(other, this, tickRate);
world.scheduleUpdate(pos, state.getBlock(), state.getBlock().tickRate(world));
return 0;
@@ -279,7 +280,7 @@ public class BlockFluidFinite extends BlockFluidBase
if (doPlace)
{
FluidUtil.destroyBlockOnFluidPlacement(world, pos);
world.setBlockState(pos, getDefaultState().withProperty(LEVEL, quanta - 1), 11);
world.setBlockState(pos, getDefaultState().withProperty(LEVEL, quanta - 1), Constants.BlockFlags.DEFAULT_AND_RERENDER);
}
return closest;
@@ -30,6 +30,7 @@ import net.minecraft.item.ItemBucket;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
@@ -102,7 +103,7 @@ public class BlockLiquidWrapper implements IFluidHandler
{
if (doDrain)
{
world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), 11);
world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), Constants.BlockFlags.DEFAULT_AND_RERENDER);
}
return containedStack;
}
@@ -128,7 +129,7 @@ public class BlockLiquidWrapper implements IFluidHandler
{
if (doDrain)
{
world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), 11);
world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), Constants.BlockFlags.DEFAULT_AND_RERENDER);
}
return containedStack;
}
@@ -22,6 +22,7 @@ package net.minecraftforge.fluids.capability.wrappers;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
@@ -56,7 +57,7 @@ public class BlockWrapper extends VoidFluidHandler
if (doFill)
{
FluidUtil.destroyBlockOnFluidPlacement(world, blockPos);
world.setBlockState(blockPos, block.getDefaultState(), 11);
world.setBlockState(blockPos, block.getDefaultState(), Constants.BlockFlags.DEFAULT_AND_RERENDER);
}
return Fluid.BUCKET_VOLUME;
}