1
0
Fork 0

Prepare for 1.15+ (#4856)

+ Add type-safe container for states
* Split registry Blocks into BlockTypes, BlockStates so the block types enumeration can be #included without too much penalty
* Ensure Registry uses type-safe container
This commit is contained in:
Tiger Wang 2020-12-21 13:54:04 +00:00 committed by GitHub
parent 5b6bed6b00
commit 9518a27357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 72531 additions and 66530 deletions

27
src/BlockState.h Normal file
View File

@ -0,0 +1,27 @@
#pragma once
#include "Registries/BlockTypes.h"
struct BlockState
{
constexpr BlockState(uint_least16_t StateID) :
ID(StateID)
{
}
/** Gets the block type of this block state. */
BlockType Type() const;
bool operator == (BlockState Block) const
{
return ID == Block.ID;
}
bool operator != (BlockState Block) const
{
return ID != Block.ID;
}
/** The state ID of the block state. */
uint_least16_t ID;
};

View File

@ -72,6 +72,7 @@ target_sources(
BlockArea.h BlockArea.h
BlockInServerPluginInterface.h BlockInServerPluginInterface.h
BlockInfo.h BlockInfo.h
BlockState.h
BlockTracer.h BlockTracer.h
BlockType.h BlockType.h
BrewingRecipes.h BrewingRecipes.h

View File

@ -41,10 +41,11 @@ local g_ShouldProcessExt =
--- The list of files not to be processed: --- The list of files not to be processed:
local g_IgnoredFiles = local g_IgnoredFiles =
{ {
"Bindings/Bindings.h",
"Bindings/Bindings.cpp", "Bindings/Bindings.cpp",
"Bindings/Bindings.h",
"Bindings/LuaState_Implementation.cpp", "Bindings/LuaState_Implementation.cpp",
"Registries/Blocks.h" "Registries/BlockStates.cpp",
"Registries/BlockStates.h"
} }
--- The list of files not to be processed, as a dictionary (filename => true), built from g_IgnoredFiles --- The list of files not to be processed, as a dictionary (filename => true), built from g_IgnoredFiles

View File

@ -42,17 +42,17 @@ namespace
auto Palette393(const BLOCKTYPE a_BlockType, const NIBBLETYPE a_Meta) auto Palette393(const BLOCKTYPE a_BlockType, const NIBBLETYPE a_Meta)
{ {
return Palette_1_13::FromBlock(PaletteUpgrade::FromBlock(a_BlockType, a_Meta)); return Palette_1_13::From(PaletteUpgrade::FromBlock(a_BlockType, a_Meta));
} }
auto Palette401(const BLOCKTYPE a_BlockType, const NIBBLETYPE a_Meta) auto Palette401(const BLOCKTYPE a_BlockType, const NIBBLETYPE a_Meta)
{ {
return Palette_1_13_1::FromBlock(PaletteUpgrade::FromBlock(a_BlockType, a_Meta)); return Palette_1_13_1::From(PaletteUpgrade::FromBlock(a_BlockType, a_Meta));
} }
auto Palette477(const BLOCKTYPE a_BlockType, const NIBBLETYPE a_Meta) auto Palette477(const BLOCKTYPE a_BlockType, const NIBBLETYPE a_Meta)
{ {
return Palette_1_14::FromBlock(PaletteUpgrade::FromBlock(a_BlockType, a_Meta)); return Palette_1_14::From(PaletteUpgrade::FromBlock(a_BlockType, a_Meta));
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
#pragma once #pragma once
#include "../../Registries/Items.h" #include "BlockState.h"
#include "../../Registries/Statistics.h" #include "Registries/Items.h"
#include "Registries/Statistics.h"
namespace Palette_1_13 namespace Palette_1_13
{ {
UInt32 FromBlock(short ID); UInt32 From(BlockState Block);
UInt32 FromItem(Item ID); UInt32 From(Item ID);
UInt32 From(Statistic ID); UInt32 From(Statistic ID);
Item ToItem(UInt32 ID); Item ToItem(UInt32 ID);
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
#pragma once #pragma once
#include "../../Registries/Items.h" #include "BlockState.h"
#include "../../Registries/Statistics.h" #include "Registries/Items.h"
#include "Registries/Statistics.h"
namespace Palette_1_13_1 namespace Palette_1_13_1
{ {
UInt32 FromBlock(short ID); UInt32 From(BlockState Block);
UInt32 FromItem(Item ID); UInt32 From(Item ID);
UInt32 From(Statistic ID); UInt32 From(Statistic ID);
Item ToItem(UInt32 ID); Item ToItem(UInt32 ID);
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
#pragma once #pragma once
#include "../../Registries/Items.h" #include "BlockState.h"
#include "../../Registries/Statistics.h" #include "Registries/Items.h"
#include "Registries/Statistics.h"
namespace Palette_1_14 namespace Palette_1_14
{ {
UInt32 FromBlock(short ID); UInt32 From(BlockState Block);
UInt32 FromItem(Item ID); UInt32 From(Item ID);
UInt32 From(Statistic ID); UInt32 From(Statistic ID);
Item ToItem(UInt32 ID); Item ToItem(UInt32 ID);
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
#pragma once #pragma once
#include "../../Registries/Items.h" #include "BlockState.h"
#include "../../Registries/Statistics.h" #include "Registries/Items.h"
#include "Registries/Statistics.h"
namespace Palette_1_15 namespace Palette_1_15
{ {
UInt32 FromBlock(short ID); UInt32 From(BlockState Block);
UInt32 FromItem(Item ID); UInt32 From(Item ID);
UInt32 From(Statistic ID); UInt32 From(Statistic ID);
Item ToItem(UInt32 ID); Item ToItem(UInt32 ID);
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
#pragma once #pragma once
#include "../../Registries/Items.h" #include "BlockState.h"
#include "../../Registries/Statistics.h" #include "Registries/Items.h"
#include "Registries/Statistics.h"
namespace Palette_1_16 namespace Palette_1_16
{ {
UInt32 FromBlock(short ID); UInt32 From(BlockState Block);
UInt32 FromItem(Item ID); UInt32 From(Item ID);
UInt32 From(Statistic ID); UInt32 From(Statistic ID);
Item ToItem(UInt32 ID); Item ToItem(UInt32 ID);
} }

View File

@ -1,11 +1,11 @@
#include "Globals.h" #include "Globals.h"
#include "Upgrade.h" #include "Upgrade.h"
#include "../../Registries/Blocks.h" #include "Registries/BlockStates.h"
namespace PaletteUpgrade namespace PaletteUpgrade
{ {
short FromBlock(BLOCKTYPE Block, NIBBLETYPE Meta) BlockState FromBlock(const BLOCKTYPE Block, const NIBBLETYPE Meta)
{ {
using namespace Block; using namespace Block;
@ -1705,7 +1705,7 @@ namespace PaletteUpgrade
} }
} }
Item FromItem(short Item, short Damage) Item FromItem(const short Item, const short Damage)
{ {
switch ((Item << 16) | Damage) switch ((Item << 16) | Damage)
{ {
@ -2516,7 +2516,7 @@ namespace PaletteUpgrade
} }
} }
std::pair<short, short> ToItem(Item ID) std::pair<short, short> ToItem(const Item ID)
{ {
switch (ID) switch (ID)
{ {

View File

@ -1,11 +1,12 @@
#pragma once #pragma once
#include "../../BlockType.h" #include "ChunkDef.h"
#include "../../Registries/Items.h" #include "BlockState.h"
#include "Registries/Items.h"
namespace PaletteUpgrade namespace PaletteUpgrade
{ {
short FromBlock(BLOCKTYPE Block, NIBBLETYPE Meta); BlockState FromBlock(BLOCKTYPE Block, NIBBLETYPE Meta);
Item FromItem(short Item, short Damage); Item FromItem(short Item, short Damage);
std::pair<short, short> ToItem(Item ID); std::pair<short, short> ToItem(Item ID);
} }

View File

@ -648,7 +648,7 @@ std::pair<short, short> cProtocol_1_13::GetItemFromProtocolID(UInt32 a_ProtocolI
UInt32 cProtocol_1_13::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) UInt32 cProtocol_1_13::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta)
{ {
return Palette_1_13::FromBlock(PaletteUpgrade::FromBlock(a_BlockType, a_Meta)); return Palette_1_13::From(PaletteUpgrade::FromBlock(a_BlockType, a_Meta));
} }
@ -657,7 +657,7 @@ UInt32 cProtocol_1_13::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_
UInt32 cProtocol_1_13::GetProtocolItemType(short a_ItemID, short a_ItemDamage) UInt32 cProtocol_1_13::GetProtocolItemType(short a_ItemID, short a_ItemDamage)
{ {
return Palette_1_13::FromItem(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage)); return Palette_1_13::From(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage));
} }
@ -1364,7 +1364,7 @@ std::pair<short, short> cProtocol_1_13_1::GetItemFromProtocolID(UInt32 a_Protoco
UInt32 cProtocol_1_13_1::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) UInt32 cProtocol_1_13_1::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta)
{ {
return Palette_1_13_1::FromBlock(PaletteUpgrade::FromBlock(a_BlockType, a_Meta)); return Palette_1_13_1::From(PaletteUpgrade::FromBlock(a_BlockType, a_Meta));
} }
@ -1373,7 +1373,7 @@ UInt32 cProtocol_1_13_1::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
UInt32 cProtocol_1_13_1::GetProtocolItemType(short a_ItemID, short a_ItemDamage) UInt32 cProtocol_1_13_1::GetProtocolItemType(short a_ItemID, short a_ItemDamage)
{ {
return Palette_1_13_1::FromItem(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage)); return Palette_1_13_1::From(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage));
} }

View File

@ -196,7 +196,7 @@ std::pair<short, short> cProtocol_1_14::GetItemFromProtocolID(UInt32 a_ProtocolI
UInt32 cProtocol_1_14::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) UInt32 cProtocol_1_14::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta)
{ {
return Palette_1_14::FromBlock(PaletteUpgrade::FromBlock(a_BlockType, a_Meta)); return Palette_1_14::From(PaletteUpgrade::FromBlock(a_BlockType, a_Meta));
} }
@ -205,7 +205,7 @@ UInt32 cProtocol_1_14::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_
UInt32 cProtocol_1_14::GetProtocolItemType(short a_ItemID, short a_ItemDamage) UInt32 cProtocol_1_14::GetProtocolItemType(short a_ItemID, short a_ItemDamage)
{ {
return Palette_1_14::FromItem(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage)); return Palette_1_14::From(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage));
} }

File diff suppressed because one or more lines are too long

25485
src/Registries/BlockStates.h Normal file

File diff suppressed because it is too large Load Diff

768
src/Registries/BlockTypes.h Normal file
View File

@ -0,0 +1,768 @@
#pragma once
enum class BlockType
{
AcaciaButton,
AcaciaDoor,
AcaciaFence,
AcaciaFenceGate,
AcaciaLeaves,
AcaciaLog,
AcaciaPlanks,
AcaciaPressurePlate,
AcaciaSapling,
AcaciaSign,
AcaciaSlab,
AcaciaStairs,
AcaciaTrapdoor,
AcaciaWallSign,
AcaciaWood,
ActivatorRail,
Air,
Allium,
AncientDebris,
Andesite,
AndesiteSlab,
AndesiteStairs,
AndesiteWall,
Anvil,
AttachedMelonStem,
AttachedPumpkinStem,
AzureBluet,
Bamboo,
BambooSapling,
Barrel,
Barrier,
Basalt,
Beacon,
Bedrock,
BeeNest,
Beehive,
Beetroots,
Bell,
BirchButton,
BirchDoor,
BirchFence,
BirchFenceGate,
BirchLeaves,
BirchLog,
BirchPlanks,
BirchPressurePlate,
BirchSapling,
BirchSign,
BirchSlab,
BirchStairs,
BirchTrapdoor,
BirchWallSign,
BirchWood,
BlackBanner,
BlackBed,
BlackCarpet,
BlackConcrete,
BlackConcretePowder,
BlackGlazedTerracotta,
BlackShulkerBox,
BlackStainedGlass,
BlackStainedGlassPane,
BlackTerracotta,
BlackWallBanner,
BlackWool,
Blackstone,
BlackstoneSlab,
BlackstoneStairs,
BlackstoneWall,
BlastFurnace,
BlueBanner,
BlueBed,
BlueCarpet,
BlueConcrete,
BlueConcretePowder,
BlueGlazedTerracotta,
BlueIce,
BlueOrchid,
BlueShulkerBox,
BlueStainedGlass,
BlueStainedGlassPane,
BlueTerracotta,
BlueWallBanner,
BlueWool,
BoneBlock,
Bookshelf,
BrainCoral,
BrainCoralBlock,
BrainCoralFan,
BrainCoralWallFan,
BrewingStand,
BrickSlab,
BrickStairs,
BrickWall,
Bricks,
BrownBanner,
BrownBed,
BrownCarpet,
BrownConcrete,
BrownConcretePowder,
BrownGlazedTerracotta,
BrownMushroom,
BrownMushroomBlock,
BrownShulkerBox,
BrownStainedGlass,
BrownStainedGlassPane,
BrownTerracotta,
BrownWallBanner,
BrownWool,
BubbleColumn,
BubbleCoral,
BubbleCoralBlock,
BubbleCoralFan,
BubbleCoralWallFan,
Cactus,
Cake,
Campfire,
Carrots,
CartographyTable,
CarvedPumpkin,
Cauldron,
CaveAir,
Chain,
ChainCommandBlock,
Chest,
ChippedAnvil,
ChiseledNetherBricks,
ChiseledPolishedBlackstone,
ChiseledQuartzBlock,
ChiseledRedSandstone,
ChiseledSandstone,
ChiseledStoneBricks,
ChorusFlower,
ChorusPlant,
Clay,
CoalBlock,
CoalOre,
CoarseDirt,
Cobblestone,
CobblestoneSlab,
CobblestoneStairs,
CobblestoneWall,
Cobweb,
Cocoa,
CommandBlock,
Comparator,
Composter,
Conduit,
Cornflower,
CrackedNetherBricks,
CrackedPolishedBlackstoneBricks,
CrackedStoneBricks,
CraftingTable,
CreeperHead,
CreeperWallHead,
CrimsonButton,
CrimsonDoor,
CrimsonFence,
CrimsonFenceGate,
CrimsonFungus,
CrimsonHyphae,
CrimsonNylium,
CrimsonPlanks,
CrimsonPressurePlate,
CrimsonRoots,
CrimsonSign,
CrimsonSlab,
CrimsonStairs,
CrimsonStem,
CrimsonTrapdoor,
CrimsonWallSign,
CryingObsidian,
CutRedSandstone,
CutRedSandstoneSlab,
CutSandstone,
CutSandstoneSlab,
CyanBanner,
CyanBed,
CyanCarpet,
CyanConcrete,
CyanConcretePowder,
CyanGlazedTerracotta,
CyanShulkerBox,
CyanStainedGlass,
CyanStainedGlassPane,
CyanTerracotta,
CyanWallBanner,
CyanWool,
DamagedAnvil,
Dandelion,
DarkOakButton,
DarkOakDoor,
DarkOakFence,
DarkOakFenceGate,
DarkOakLeaves,
DarkOakLog,
DarkOakPlanks,
DarkOakPressurePlate,
DarkOakSapling,
DarkOakSign,
DarkOakSlab,
DarkOakStairs,
DarkOakTrapdoor,
DarkOakWallSign,
DarkOakWood,
DarkPrismarine,
DarkPrismarineSlab,
DarkPrismarineStairs,
DaylightDetector,
DeadBrainCoral,
DeadBrainCoralBlock,
DeadBrainCoralFan,
DeadBrainCoralWallFan,
DeadBubbleCoral,
DeadBubbleCoralBlock,
DeadBubbleCoralFan,
DeadBubbleCoralWallFan,
DeadBush,
DeadFireCoral,
DeadFireCoralBlock,
DeadFireCoralFan,
DeadFireCoralWallFan,
DeadHornCoral,
DeadHornCoralBlock,
DeadHornCoralFan,
DeadHornCoralWallFan,
DeadTubeCoral,
DeadTubeCoralBlock,
DeadTubeCoralFan,
DeadTubeCoralWallFan,
DetectorRail,
DiamondBlock,
DiamondOre,
Diorite,
DioriteSlab,
DioriteStairs,
DioriteWall,
Dirt,
Dispenser,
DragonEgg,
DragonHead,
DragonWallHead,
DriedKelpBlock,
Dropper,
EmeraldBlock,
EmeraldOre,
EnchantingTable,
EndGateway,
EndPortal,
EndPortalFrame,
EndRod,
EndStone,
EndStoneBrickSlab,
EndStoneBrickStairs,
EndStoneBrickWall,
EndStoneBricks,
EnderChest,
Farmland,
Fern,
Fire,
FireCoral,
FireCoralBlock,
FireCoralFan,
FireCoralWallFan,
FletchingTable,
FlowerPot,
FrostedIce,
Furnace,
GildedBlackstone,
Glass,
GlassPane,
Glowstone,
GoldBlock,
GoldOre,
Granite,
GraniteSlab,
GraniteStairs,
GraniteWall,
Grass,
GrassBlock,
GrassPath,
Gravel,
GrayBanner,
GrayBed,
GrayCarpet,
GrayConcrete,
GrayConcretePowder,
GrayGlazedTerracotta,
GrayShulkerBox,
GrayStainedGlass,
GrayStainedGlassPane,
GrayTerracotta,
GrayWallBanner,
GrayWool,
GreenBanner,
GreenBed,
GreenCarpet,
GreenConcrete,
GreenConcretePowder,
GreenGlazedTerracotta,
GreenShulkerBox,
GreenStainedGlass,
GreenStainedGlassPane,
GreenTerracotta,
GreenWallBanner,
GreenWool,
Grindstone,
HayBale,
HeavyWeightedPressurePlate,
HoneyBlock,
HoneycombBlock,
Hopper,
HornCoral,
HornCoralBlock,
HornCoralFan,
HornCoralWallFan,
Ice,
InfestedChiseledStoneBricks,
InfestedCobblestone,
InfestedCrackedStoneBricks,
InfestedMossyStoneBricks,
InfestedStone,
InfestedStoneBricks,
IronBars,
IronBlock,
IronDoor,
IronOre,
IronTrapdoor,
JackOLantern,
Jigsaw,
Jukebox,
JungleButton,
JungleDoor,
JungleFence,
JungleFenceGate,
JungleLeaves,
JungleLog,
JunglePlanks,
JunglePressurePlate,
JungleSapling,
JungleSign,
JungleSlab,
JungleStairs,
JungleTrapdoor,
JungleWallSign,
JungleWood,
Kelp,
KelpPlant,
Ladder,
Lantern,
LapisBlock,
LapisOre,
LargeFern,
Lava,
Lectern,
Lever,
LightBlueBanner,
LightBlueBed,
LightBlueCarpet,
LightBlueConcrete,
LightBlueConcretePowder,
LightBlueGlazedTerracotta,
LightBlueShulkerBox,
LightBlueStainedGlass,
LightBlueStainedGlassPane,
LightBlueTerracotta,
LightBlueWallBanner,
LightBlueWool,
LightGrayBanner,
LightGrayBed,
LightGrayCarpet,
LightGrayConcrete,
LightGrayConcretePowder,
LightGrayGlazedTerracotta,
LightGrayShulkerBox,
LightGrayStainedGlass,
LightGrayStainedGlassPane,
LightGrayTerracotta,
LightGrayWallBanner,
LightGrayWool,
LightWeightedPressurePlate,
Lilac,
LilyOfTheValley,
LilyPad,
LimeBanner,
LimeBed,
LimeCarpet,
LimeConcrete,
LimeConcretePowder,
LimeGlazedTerracotta,
LimeShulkerBox,
LimeStainedGlass,
LimeStainedGlassPane,
LimeTerracotta,
LimeWallBanner,
LimeWool,
Lodestone,
Loom,
MagentaBanner,
MagentaBed,
MagentaCarpet,
MagentaConcrete,
MagentaConcretePowder,
MagentaGlazedTerracotta,
MagentaShulkerBox,
MagentaStainedGlass,
MagentaStainedGlassPane,
MagentaTerracotta,
MagentaWallBanner,
MagentaWool,
MagmaBlock,
Melon,
MelonStem,
MossyCobblestone,
MossyCobblestoneSlab,
MossyCobblestoneStairs,
MossyCobblestoneWall,
MossyStoneBrickSlab,
MossyStoneBrickStairs,
MossyStoneBrickWall,
MossyStoneBricks,
MovingPiston,
MushroomStem,
Mycelium,
NetherBrickFence,
NetherBrickSlab,
NetherBrickStairs,
NetherBrickWall,
NetherBricks,
NetherGoldOre,
NetherPortal,
NetherQuartzOre,
NetherSprouts,
NetherWart,
NetherWartBlock,
NetheriteBlock,
Netherrack,
NoteBlock,
OakButton,
OakDoor,
OakFence,
OakFenceGate,
OakLeaves,
OakLog,
OakPlanks,
OakPressurePlate,
OakSapling,
OakSign,
OakSlab,
OakStairs,
OakTrapdoor,
OakWallSign,
OakWood,
Observer,
Obsidian,
OrangeBanner,
OrangeBed,
OrangeCarpet,
OrangeConcrete,
OrangeConcretePowder,
OrangeGlazedTerracotta,
OrangeShulkerBox,
OrangeStainedGlass,
OrangeStainedGlassPane,
OrangeTerracotta,
OrangeTulip,
OrangeWallBanner,
OrangeWool,
OxeyeDaisy,
PackedIce,
Peony,
PetrifiedOakSlab,
PinkBanner,
PinkBed,
PinkCarpet,
PinkConcrete,
PinkConcretePowder,
PinkGlazedTerracotta,
PinkShulkerBox,
PinkStainedGlass,
PinkStainedGlassPane,
PinkTerracotta,
PinkTulip,
PinkWallBanner,
PinkWool,
Piston,
PistonHead,
PlayerHead,
PlayerWallHead,
Podzol,
PolishedAndesite,
PolishedAndesiteSlab,
PolishedAndesiteStairs,
PolishedBasalt,
PolishedBlackstone,
PolishedBlackstoneBrickSlab,
PolishedBlackstoneBrickStairs,
PolishedBlackstoneBrickWall,
PolishedBlackstoneBricks,
PolishedBlackstoneButton,
PolishedBlackstonePressurePlate,
PolishedBlackstoneSlab,
PolishedBlackstoneStairs,
PolishedBlackstoneWall,
PolishedDiorite,
PolishedDioriteSlab,
PolishedDioriteStairs,
PolishedGranite,
PolishedGraniteSlab,
PolishedGraniteStairs,
Poppy,
Potatoes,
PottedAcaciaSapling,
PottedAllium,
PottedAzureBluet,
PottedBamboo,
PottedBirchSapling,
PottedBlueOrchid,
PottedBrownMushroom,
PottedCactus,
PottedCornflower,
PottedCrimsonFungus,
PottedCrimsonRoots,
PottedDandelion,
PottedDarkOakSapling,
PottedDeadBush,
PottedFern,
PottedJungleSapling,
PottedLilyOfTheValley,
PottedOakSapling,
PottedOrangeTulip,
PottedOxeyeDaisy,
PottedPinkTulip,
PottedPoppy,
PottedRedMushroom,
PottedRedTulip,
PottedSpruceSapling,
PottedWarpedFungus,
PottedWarpedRoots,
PottedWhiteTulip,
PottedWitherRose,
PoweredRail,
Prismarine,
PrismarineBrickSlab,
PrismarineBrickStairs,
PrismarineBricks,
PrismarineSlab,
PrismarineStairs,
PrismarineWall,
Pumpkin,
PumpkinStem,
PurpleBanner,
PurpleBed,
PurpleCarpet,
PurpleConcrete,
PurpleConcretePowder,
PurpleGlazedTerracotta,
PurpleShulkerBox,
PurpleStainedGlass,
PurpleStainedGlassPane,
PurpleTerracotta,
PurpleWallBanner,
PurpleWool,
PurpurBlock,
PurpurPillar,
PurpurSlab,
PurpurStairs,
QuartzBlock,
QuartzBricks,
QuartzPillar,
QuartzSlab,
QuartzStairs,
Rail,
RedBanner,
RedBed,
RedCarpet,
RedConcrete,
RedConcretePowder,
RedGlazedTerracotta,
RedMushroom,
RedMushroomBlock,
RedNetherBrickSlab,
RedNetherBrickStairs,
RedNetherBrickWall,
RedNetherBricks,
RedSand,
RedSandstone,
RedSandstoneSlab,
RedSandstoneStairs,
RedSandstoneWall,
RedShulkerBox,
RedStainedGlass,
RedStainedGlassPane,
RedTerracotta,
RedTulip,
RedWallBanner,
RedWool,
RedstoneBlock,
RedstoneLamp,
RedstoneOre,
RedstoneTorch,
RedstoneWallTorch,
RedstoneWire,
Repeater,
RepeatingCommandBlock,
RespawnAnchor,
RoseBush,
Sand,
Sandstone,
SandstoneSlab,
SandstoneStairs,
SandstoneWall,
Scaffolding,
SeaLantern,
SeaPickle,
Seagrass,
Shroomlight,
ShulkerBox,
SkeletonSkull,
SkeletonWallSkull,
SlimeBlock,
SmithingTable,
Smoker,
SmoothQuartz,
SmoothQuartzSlab,
SmoothQuartzStairs,
SmoothRedSandstone,
SmoothRedSandstoneSlab,
SmoothRedSandstoneStairs,
SmoothSandstone,
SmoothSandstoneSlab,
SmoothSandstoneStairs,
SmoothStone,
SmoothStoneSlab,
Snow,
SnowBlock,
SoulCampfire,
SoulFire,
SoulLantern,
SoulSand,
SoulSoil,
SoulTorch,
SoulWallTorch,
Spawner,
Sponge,
SpruceButton,
SpruceDoor,
SpruceFence,
SpruceFenceGate,
SpruceLeaves,
SpruceLog,
SprucePlanks,
SprucePressurePlate,
SpruceSapling,
SpruceSign,
SpruceSlab,
SpruceStairs,
SpruceTrapdoor,
SpruceWallSign,
SpruceWood,
StickyPiston,
Stone,
StoneBrickSlab,
StoneBrickStairs,
StoneBrickWall,
StoneBricks,
StoneButton,
StonePressurePlate,
StoneSlab,
StoneStairs,
Stonecutter,
StrippedAcaciaLog,
StrippedAcaciaWood,
StrippedBirchLog,
StrippedBirchWood,
StrippedCrimsonHyphae,
StrippedCrimsonStem,
StrippedDarkOakLog,
StrippedDarkOakWood,
StrippedJungleLog,
StrippedJungleWood,
StrippedOakLog,
StrippedOakWood,
StrippedSpruceLog,
StrippedSpruceWood,
StrippedWarpedHyphae,
StrippedWarpedStem,
StructureBlock,
StructureVoid,
SugarCane,
Sunflower,
SweetBerryBush,
TNT,
TallGrass,
TallSeagrass,
Target,
Terracotta,
Torch,
TrappedChest,
Tripwire,
TripwireHook,
TubeCoral,
TubeCoralBlock,
TubeCoralFan,
TubeCoralWallFan,
TurtleEgg,
TwistingVines,
TwistingVinesPlant,
Vine,
VoidAir,
WallTorch,
WarpedButton,
WarpedDoor,
WarpedFence,
WarpedFenceGate,
WarpedFungus,
WarpedHyphae,
WarpedNylium,
WarpedPlanks,
WarpedPressurePlate,
WarpedRoots,
WarpedSign,
WarpedSlab,
WarpedStairs,
WarpedStem,
WarpedTrapdoor,
WarpedWallSign,
WarpedWartBlock,
Water,
WeepingVines,
WeepingVinesPlant,
WetSponge,
Wheat,
WhiteBanner,
WhiteBed,
WhiteCarpet,
WhiteConcrete,
WhiteConcretePowder,
WhiteGlazedTerracotta,
WhiteShulkerBox,
WhiteStainedGlass,
WhiteStainedGlassPane,
WhiteTerracotta,
WhiteTulip,
WhiteWallBanner,
WhiteWool,
WitherRose,
WitherSkeletonSkull,
WitherSkeletonWallSkull,
YellowBanner,
YellowBed,
YellowCarpet,
YellowConcrete,
YellowConcretePowder,
YellowGlazedTerracotta,
YellowShulkerBox,
YellowStainedGlass,
YellowStainedGlassPane,
YellowTerracotta,
YellowWallBanner,
YellowWool,
ZombieHead,
ZombieWallHead
};

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,10 @@
target_sources( target_sources(
${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_PROJECT_NAME} PRIVATE
Blocks.cpp BlockStates.cpp
Blocks.h BlockStates.h
BlockTypes.h
Items.h Items.h
Statistics.h Statistics.h
) )

View File

@ -1,4 +1,3 @@
#pragma once #pragma once
enum class Statistic enum class Statistic

View File

@ -3,8 +3,9 @@
#include <stack> #include <stack>
#include "../RedstoneSimulator.h" #include "Chunk.h"
#include "../../Chunk.h" #include "BlockState.h"
#include "Simulator/RedstoneSimulator.h"
@ -82,7 +83,7 @@ public:
} }
/** Temporary, should be chunk data: wire block store, to avoid recomputing states every time. */ /** Temporary, should be chunk data: wire block store, to avoid recomputing states every time. */
std::unordered_map<Vector3i, short, VectorHasher<int>> WireStates; std::unordered_map<Vector3i, BlockState, VectorHasher<int>> WireStates;
std::unordered_set<Vector3i, VectorHasher<int>> AlwaysTickedPositions; std::unordered_set<Vector3i, VectorHasher<int>> AlwaysTickedPositions;

View File

@ -2,7 +2,7 @@
#pragma once #pragma once
#include "RedstoneHandler.h" #include "RedstoneHandler.h"
#include "../../Registries/Blocks.h" #include "Registries/BlockStates.h"
@ -20,7 +20,7 @@ namespace RedstoneWireHandler
/** Invokes Callback with the wire's left, front, and right direction state corresponding to Offset. /** Invokes Callback with the wire's left, front, and right direction state corresponding to Offset.
Returns a new block constructed from the directions that the callback may have modified. */ Returns a new block constructed from the directions that the callback may have modified. */
template <class OffsetCallback> template <class OffsetCallback>
inline short DoWithDirectionState(const Vector3i Offset, short Block, OffsetCallback Callback) inline BlockState DoWithDirectionState(const Vector3i Offset, BlockState Block, OffsetCallback Callback)
{ {
auto North = Block::RedstoneWire::North(Block); auto North = Block::RedstoneWire::North(Block);
auto South = Block::RedstoneWire::South(Block); auto South = Block::RedstoneWire::South(Block);
@ -49,7 +49,7 @@ namespace RedstoneWireHandler
} }
/** Adjusts a given wire block so that the direction represented by Offset has state Direction. */ /** Adjusts a given wire block so that the direction represented by Offset has state Direction. */
inline void SetDirectionState(const Vector3i Offset, short & Block, TemporaryDirection Direction) inline void SetDirectionState(const Vector3i Offset, BlockState & Block, TemporaryDirection Direction)
{ {
Block = DoWithDirectionState(Offset, Block, [Direction](auto, auto & Front, auto) Block = DoWithDirectionState(Offset, Block, [Direction](auto, auto & Front, auto)
{ {
@ -189,7 +189,7 @@ namespace RedstoneWireHandler
return; return;
} }
DataForChunk(Chunk).WireStates[Position] = Block; DataForChunk(Chunk).WireStates.emplace(Position, Block);
} }
inline PowerLevel GetPowerDeliveredToPosition(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked) inline PowerLevel GetPowerDeliveredToPosition(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked)