Added more Constants (#5323)

This commit is contained in:
Wyn Price 2019-03-15 19:38:52 +00:00 committed by tterrag
parent cb0cf2f04f
commit 47a7d8e2b7
4 changed files with 181 additions and 8 deletions

View file

@ -176,11 +176,13 @@ public class BlockSnapshot
IBlockState current = getCurrentBlock(); IBlockState current = getCurrentBlock();
IBlockState replaced = getReplacedBlock(); IBlockState replaced = getReplacedBlock();
int flags = notifyNeighbors ? Constants.BlockFlags.DEFAULT : Constants.BlockFlags.SEND_TO_CLIENTS;
if (current != replaced) if (current != replaced)
{ {
if (force) if (force)
{ {
world.setBlockState(pos, replaced, notifyNeighbors ? 3 : 2); world.setBlockState(pos, replaced, flags);
} }
else else
{ {
@ -188,8 +190,8 @@ public class BlockSnapshot
} }
} }
world.setBlockState(pos, replaced, notifyNeighbors ? 3 : 2); world.setBlockState(pos, replaced, flags);
world.notifyBlockUpdate(pos, current, replaced, notifyNeighbors ? 3 : 2); world.notifyBlockUpdate(pos, current, replaced, flags);
TileEntity te = null; TileEntity te = null;
if (getNbt() != null) if (getNbt() != null)

View file

@ -19,6 +19,9 @@
package net.minecraftforge.common.util; package net.minecraftforge.common.util;
import net.minecraft.block.Block;
import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance;
/** /**
* A class containing constants for magic numbers used in the minecraft codebase. * 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. * Everything here should be checked each update, and have a comment relating to where to check it.
@ -49,4 +52,170 @@ public class Constants
public static final int TAG_LONG_ARRAY = 12; public static final int TAG_LONG_ARRAY = 12;
public static final int TAG_ANY_NUMERIC = 99; 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.WorldRenderer#notifyBlockUpdate}<br>
* Flags can be combined with bitwise OR
*/
public static class BlockFlags {
/**
* Calls {@link Block#neighborChanged(net.minecraft.block.state.IBlockState, net.minecraft.world.World, net.minecraft.util.math.BlockPos, Block, net.minecraft.util.math.BlockPos) 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;
}
} }

View file

@ -30,6 +30,7 @@ import net.minecraft.item.ItemBucket;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -102,7 +103,7 @@ public class BlockLiquidWrapper implements IFluidHandler
{ {
if (doDrain) if (doDrain)
{ {
world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), 11); world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), Constants.BlockFlags.DEFAULT_AND_RERENDER);
} }
return containedStack; return containedStack;
} }
@ -128,7 +129,7 @@ public class BlockLiquidWrapper implements IFluidHandler
{ {
if (doDrain) if (doDrain)
{ {
world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), 11); world.setBlockState(blockPos, Blocks.AIR.getDefaultState(), Constants.BlockFlags.DEFAULT_AND_RERENDER);
} }
return containedStack; return containedStack;
} }

View file

@ -22,6 +22,7 @@ package net.minecraftforge.fluids.capability.wrappers;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.FluidUtil;
@ -56,7 +57,7 @@ public class BlockWrapper extends VoidFluidHandler
if (doFill) if (doFill)
{ {
FluidUtil.destroyBlockOnFluidPlacement(world, blockPos); FluidUtil.destroyBlockOnFluidPlacement(world, blockPos);
world.setBlockState(blockPos, block.getDefaultState(), 11); world.setBlockState(blockPos, block.getDefaultState(), Constants.BlockFlags.DEFAULT_AND_RERENDER);
} }
return Fluid.BUCKET_VOLUME; return Fluid.BUCKET_VOLUME;
} }