diff --git a/cmd/blockhash/main.go b/cmd/blockhash/main.go index 670cc4bba..e8a39d688 100644 --- a/cmd/blockhash/main.go +++ b/cmd/blockhash/main.go @@ -224,7 +224,7 @@ func (b *hashBuilder) ftype(structName, s string, expr ast.Expr, directives map[ return "uint64(" + s + ".Uint8())", 4 case "CoralType": return "uint64(" + s + ".Uint8())", 3 - case "AnvilType", "SandstoneType", "PrismarineType", "StoneBricksType", "NetherBricksType", "FroglightType", "WallConnectionType": + case "AnvilType", "SandstoneType", "PrismarineType", "StoneBricksType", "NetherBricksType", "FroglightType", "WallConnectionType", "BlackstoneType", "DeepslateType": return "uint64(" + s + ".Uint8())", 2 case "OreType", "FireType", "GrassType": return "uint64(" + s + ".Uint8())", 1 diff --git a/server/block/blackstone.go b/server/block/blackstone.go new file mode 100644 index 000000000..7515ba3ca --- /dev/null +++ b/server/block/blackstone.go @@ -0,0 +1,49 @@ +package block + +import ( + "github.com/df-mc/dragonfly/server/item" + "github.com/df-mc/dragonfly/server/world" + "math/rand" +) + +// Blackstone is a naturally generating block in the nether that can be used to craft stone tools, brewing stands and +// furnaces. Gilded blackstone also has a 10% chance to drop 2-6 golden nuggets. +type Blackstone struct { + solid + bassDrum + + // Type is the type of blackstone of the block. + Type BlackstoneType +} + +// BreakInfo ... +func (b Blackstone) BreakInfo() BreakInfo { + drops := oneOf(b) + if b.Type == GildedBlackstone() { + drops = func(item.Tool, []item.Enchantment) []item.Stack { + if rand.Float64() < 0.1 { + return []item.Stack{item.NewStack(item.GoldNugget{}, rand.Intn(4)+2)} + } + return []item.Stack{item.NewStack(b, 1)} + } + } + return newBreakInfo(1.5, pickaxeHarvestable, pickaxeEffective, drops).withBlastResistance(30) +} + +// EncodeItem ... +func (b Blackstone) EncodeItem() (name string, meta int16) { + return "minecraft:" + b.Type.String(), 0 +} + +// EncodeBlock ... +func (b Blackstone) EncodeBlock() (string, map[string]any) { + return "minecraft:" + b.Type.String(), nil +} + +// allBlackstone returns a list of all blackstone block variants. +func allBlackstone() (s []world.Block) { + for _, t := range BlackstoneTypes() { + s = append(s, Blackstone{Type: t}) + } + return +} diff --git a/server/block/blackstone_type.go b/server/block/blackstone_type.go new file mode 100644 index 000000000..e7c8c12d6 --- /dev/null +++ b/server/block/blackstone_type.go @@ -0,0 +1,68 @@ +package block + +// BlackstoneType represents a type of blackstone. +type BlackstoneType struct { + blackstone +} + +type blackstone uint8 + +// NormalBlackstone is the normal variant of blackstone. +func NormalBlackstone() BlackstoneType { + return BlackstoneType{0} +} + +// GildedBlackstone is the gilded variant of blackstone. +func GildedBlackstone() BlackstoneType { + return BlackstoneType{1} +} + +// PolishedBlackstone is the polished variant of blackstone. +func PolishedBlackstone() BlackstoneType { + return BlackstoneType{2} +} + +// ChiseledPolishedBlackstone is the chiseled polished variant of blackstone. +func ChiseledPolishedBlackstone() BlackstoneType { + return BlackstoneType{3} +} + +// Uint8 returns the blackstone type as a uint8. +func (s blackstone) Uint8() uint8 { + return uint8(s) +} + +// Name ... +func (s blackstone) Name() string { + switch s { + case 0: + return "Blackstone" + case 1: + return "Gilded Blackstone" + case 2: + return "Polished Blackstone" + case 3: + return "Chiseled Polished Blackstone" + } + panic("unknown blackstone type") +} + +// String ... +func (s blackstone) String() string { + switch s { + case 0: + return "blackstone" + case 1: + return "gilded_blackstone" + case 2: + return "polished_blackstone" + case 3: + return "chiseled_polished_blackstone" + } + panic("unknown blackstone type") +} + +// BlackstoneTypes ... +func BlackstoneTypes() []BlackstoneType { + return []BlackstoneType{NormalBlackstone(), GildedBlackstone(), PolishedBlackstone(), ChiseledPolishedBlackstone()} +} diff --git a/server/block/deepslate.go b/server/block/deepslate.go new file mode 100644 index 000000000..33e8aec86 --- /dev/null +++ b/server/block/deepslate.go @@ -0,0 +1,71 @@ +package block + +import ( + "github.com/df-mc/dragonfly/server/block/cube" + "github.com/df-mc/dragonfly/server/item" + "github.com/df-mc/dragonfly/server/world" + "github.com/go-gl/mathgl/mgl64" +) + +// Deepslate is similar to stone but is naturally found deep underground around Y0 and below, and is harder to break. +type Deepslate struct { + solid + bassDrum + + // Type is the type of deepslate of the block. + Type DeepslateType + // Axis is the axis which the deepslate faces. + Axis cube.Axis +} + +// BreakInfo ... +func (d Deepslate) BreakInfo() BreakInfo { + hardness := 3.5 + if d.Type == NormalDeepslate() { + hardness = 3 + } + return newBreakInfo(hardness, pickaxeHarvestable, pickaxeEffective, oneOf(d)).withBlastResistance(18) +} + +// SmeltInfo ... +func (d Deepslate) SmeltInfo() item.SmeltInfo { + if d.Type == CobbledDeepslate() { + return newSmeltInfo(item.NewStack(Deepslate{}, 1), 0.1) + } + return item.SmeltInfo{} +} + +// UseOnBlock ... +func (d Deepslate) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, user item.User, ctx *item.UseContext) (used bool) { + pos, face, used = firstReplaceable(w, pos, face, d) + if !used { + return + } + if d.Type == NormalDeepslate() { + d.Axis = face.Axis() + } + + place(w, pos, d, user, ctx) + return placed(ctx) +} + +// EncodeItem ... +func (d Deepslate) EncodeItem() (name string, meta int16) { + return "minecraft:" + d.Type.String(), 0 +} + +// EncodeBlock ... +func (d Deepslate) EncodeBlock() (string, map[string]any) { + if d.Type == NormalDeepslate() { + return "minecraft:deepslate", map[string]any{"pillar_axis": d.Axis.String()} + } + return "minecraft:" + d.Type.String(), nil +} + +// allDeepslate returns a list of all deepslate block variants. +func allDeepslate() (s []world.Block) { + for _, t := range DeepslateTypes() { + s = append(s, Deepslate{Type: t}) + } + return +} diff --git a/server/block/deepslate_bricks.go b/server/block/deepslate_bricks.go new file mode 100644 index 000000000..bb7333eba --- /dev/null +++ b/server/block/deepslate_bricks.go @@ -0,0 +1,41 @@ +package block + +import "github.com/df-mc/dragonfly/server/item" + +// DeepslateBricks are a brick variant of deepslate and can spawn in ancient cities. +type DeepslateBricks struct { + solid + bassDrum + + // Cracked specifies if the deepslate bricks is its cracked variant. + Cracked bool +} + +// BreakInfo ... +func (d DeepslateBricks) BreakInfo() BreakInfo { + return newBreakInfo(3.5, pickaxeHarvestable, pickaxeEffective, oneOf(d)).withBlastResistance(18) +} + +// SmeltInfo ... +func (d DeepslateBricks) SmeltInfo() item.SmeltInfo { + if d.Cracked { + return item.SmeltInfo{} + } + return newSmeltInfo(item.NewStack(DeepslateBricks{Cracked: true}, 1), 0.1) +} + +// EncodeItem ... +func (d DeepslateBricks) EncodeItem() (name string, meta int16) { + if d.Cracked { + return "minecraft:cracked_deepslate_bricks", 0 + } + return "minecraft:deepslate_bricks", 0 +} + +// EncodeBlock ... +func (d DeepslateBricks) EncodeBlock() (string, map[string]any) { + if d.Cracked { + return "minecraft:cracked_deepslate_bricks", nil + } + return "minecraft:deepslate_bricks", nil +} diff --git a/server/block/deepslate_tiles.go b/server/block/deepslate_tiles.go new file mode 100644 index 000000000..2ff23e153 --- /dev/null +++ b/server/block/deepslate_tiles.go @@ -0,0 +1,41 @@ +package block + +import "github.com/df-mc/dragonfly/server/item" + +// DeepslateTiles are a tiled variant of deepslate and can spawn in ancient cities. +type DeepslateTiles struct { + solid + bassDrum + + // Cracked specifies if the deepslate tiles is its cracked variant. + Cracked bool +} + +// BreakInfo ... +func (d DeepslateTiles) BreakInfo() BreakInfo { + return newBreakInfo(3.5, pickaxeHarvestable, pickaxeEffective, oneOf(d)).withBlastResistance(18) +} + +// SmeltInfo ... +func (d DeepslateTiles) SmeltInfo() item.SmeltInfo { + if d.Cracked { + return item.SmeltInfo{} + } + return newSmeltInfo(item.NewStack(DeepslateTiles{Cracked: true}, 1), 0.1) +} + +// EncodeItem ... +func (d DeepslateTiles) EncodeItem() (name string, meta int16) { + if d.Cracked { + return "minecraft:cracked_deepslate_tiles", 0 + } + return "minecraft:deepslate_tiles", 0 +} + +// EncodeBlock ... +func (d DeepslateTiles) EncodeBlock() (string, map[string]any) { + if d.Cracked { + return "minecraft:cracked_deepslate_tiles", nil + } + return "minecraft:deepslate_tiles", nil +} diff --git a/server/block/deepslate_type.go b/server/block/deepslate_type.go new file mode 100644 index 000000000..9a57ec2a3 --- /dev/null +++ b/server/block/deepslate_type.go @@ -0,0 +1,68 @@ +package block + +// DeepslateType represents a type of deepslate. +type DeepslateType struct { + deepslate +} + +type deepslate uint8 + +// NormalDeepslate is the normal variant of deepslate. +func NormalDeepslate() DeepslateType { + return DeepslateType{0} +} + +// CobbledDeepslate is the cobbled variant of deepslate. +func CobbledDeepslate() DeepslateType { + return DeepslateType{1} +} + +// PolishedDeepslate is the polished variant of deepslate. +func PolishedDeepslate() DeepslateType { + return DeepslateType{2} +} + +// ChiseledDeepslate is the chiseled variant of deepslate. +func ChiseledDeepslate() DeepslateType { + return DeepslateType{3} +} + +// Uint8 returns the deepslate type as a uint8. +func (s deepslate) Uint8() uint8 { + return uint8(s) +} + +// Name ... +func (s deepslate) Name() string { + switch s { + case 0: + return "Deepslate" + case 1: + return "Cobbled Deepslate" + case 2: + return "Polished Deepslate" + case 3: + return "Chiseled Deepslate" + } + panic("unknown deepslate type") +} + +// String ... +func (s deepslate) String() string { + switch s { + case 0: + return "deepslate" + case 1: + return "cobbled_deepslate" + case 2: + return "polished_deepslate" + case 3: + return "chiseled_deepslate" + } + panic("unknown deepslate type") +} + +// DeepslateTypes ... +func DeepslateTypes() []DeepslateType { + return []DeepslateType{NormalDeepslate(), CobbledDeepslate(), PolishedDeepslate(), ChiseledDeepslate()} +} diff --git a/server/block/gilded_blackstone.go b/server/block/gilded_blackstone.go deleted file mode 100644 index bcc5d4102..000000000 --- a/server/block/gilded_blackstone.go +++ /dev/null @@ -1,31 +0,0 @@ -package block - -import ( - "github.com/df-mc/dragonfly/server/item" - "math/rand" -) - -// GildedBlackstone is a variant of blackstone that can drop itself or gold nuggets when mined. -type GildedBlackstone struct { - solid -} - -// BreakInfo ... -func (b GildedBlackstone) BreakInfo() BreakInfo { - return newBreakInfo(1.5, pickaxeHarvestable, pickaxeEffective, func(item.Tool, []item.Enchantment) []item.Stack { - if rand.Float64() < 0.1 { - return []item.Stack{item.NewStack(item.GoldNugget{}, rand.Intn(4)+2)} - } - return []item.Stack{item.NewStack(b, 1)} - }).withBlastResistance(30) -} - -// EncodeItem ... -func (GildedBlackstone) EncodeItem() (name string, meta int16) { - return "minecraft:gilded_blackstone", 0 -} - -// EncodeBlock ... -func (GildedBlackstone) EncodeBlock() (string, map[string]any) { - return "minecraft:gilded_blackstone", nil -} diff --git a/server/block/hash.go b/server/block/hash.go index cd929c8d4..b04558639 100644 --- a/server/block/hash.go +++ b/server/block/hash.go @@ -15,6 +15,7 @@ const ( hashBeacon hashBedrock hashBeetrootSeeds + hashBlackstone hashBlastFurnace hashBlueIce hashBone @@ -40,6 +41,9 @@ const ( hashCoralBlock hashCraftingTable hashDeadBush + hashDeepslate + hashDeepslateBricks + hashDeepslateTiles hashDiamond hashDiamondOre hashDiorite @@ -62,7 +66,6 @@ const ( hashFlower hashFroglight hashFurnace - hashGildedBlackstone hashGlass hashGlassPane hashGlazedTerracotta @@ -112,6 +115,7 @@ const ( hashPackedMud hashPlanks hashPodzol + hashPolishedBlackstoneBrick hashPotato hashPrismarine hashPumpkin @@ -211,6 +215,10 @@ func (b BeetrootSeeds) Hash() uint64 { return hashBeetrootSeeds | uint64(b.Growth)<<8 } +func (b Blackstone) Hash() uint64 { + return hashBlackstone | uint64(b.Type.Uint8())<<8 +} + func (b BlastFurnace) Hash() uint64 { return hashBlastFurnace | uint64(b.Facing)<<8 | uint64(boolByte(b.Lit))<<11 } @@ -311,6 +319,18 @@ func (DeadBush) Hash() uint64 { return hashDeadBush } +func (d Deepslate) Hash() uint64 { + return hashDeepslate | uint64(d.Type.Uint8())<<8 +} + +func (d DeepslateBricks) Hash() uint64 { + return hashDeepslateBricks | uint64(boolByte(d.Cracked))<<8 +} + +func (d DeepslateTiles) Hash() uint64 { + return hashDeepslateTiles | uint64(boolByte(d.Cracked))<<8 +} + func (Diamond) Hash() uint64 { return hashDiamond } @@ -399,10 +419,6 @@ func (f Furnace) Hash() uint64 { return hashFurnace | uint64(f.Facing)<<8 | uint64(boolByte(f.Lit))<<11 } -func (GildedBlackstone) Hash() uint64 { - return hashGildedBlackstone -} - func (Glass) Hash() uint64 { return hashGlass } @@ -599,6 +615,10 @@ func (Podzol) Hash() uint64 { return hashPodzol } +func (b PolishedBlackstoneBrick) Hash() uint64 { + return hashPolishedBlackstoneBrick | uint64(boolByte(b.Cracked))<<8 +} + func (p Potato) Hash() uint64 { return hashPotato | uint64(p.Growth)<<8 } diff --git a/server/block/polished_blackstone_brick.go b/server/block/polished_blackstone_brick.go new file mode 100644 index 000000000..dcbf90c9e --- /dev/null +++ b/server/block/polished_blackstone_brick.go @@ -0,0 +1,43 @@ +package block + +import "github.com/df-mc/dragonfly/server/item" + +// PolishedBlackstoneBrick are a brick variant of polished blackstone and can spawn in bastion remnants and ruined portals. +type PolishedBlackstoneBrick struct { + solid + bassDrum + + // Cracked specifies if the polished blackstone bricks is its cracked variant. + Cracked bool +} + +// BreakInfo ... +func (b PolishedBlackstoneBrick) BreakInfo() BreakInfo { + return newBreakInfo(1.5, pickaxeHarvestable, pickaxeEffective, oneOf(b)).withBlastResistance(6) +} + +// SmeltInfo ... +func (b PolishedBlackstoneBrick) SmeltInfo() item.SmeltInfo { + if b.Cracked { + return item.SmeltInfo{} + } + return newSmeltInfo(item.NewStack(PolishedBlackstoneBrick{Cracked: true}, 1), 0.1) +} + +// EncodeItem ... +func (b PolishedBlackstoneBrick) EncodeItem() (name string, meta int16) { + name = "polished_blackstone_bricks" + if b.Cracked { + name = "cracked_" + name + } + return "minecraft:" + name, 0 +} + +// EncodeBlock ... +func (b PolishedBlackstoneBrick) EncodeBlock() (string, map[string]any) { + name := "polished_blackstone_bricks" + if b.Cracked { + name = "cracked_" + name + } + return "minecraft:" + name, nil +} diff --git a/server/block/register.go b/server/block/register.go index 4e8ffbd32..2bfaa7f78 100644 --- a/server/block/register.go +++ b/server/block/register.go @@ -28,6 +28,10 @@ func init() { world.RegisterBlock(Cobblestone{}) world.RegisterBlock(CraftingTable{}) world.RegisterBlock(DeadBush{}) + world.RegisterBlock(DeepslateBricks{Cracked: true}) + world.RegisterBlock(DeepslateBricks{}) + world.RegisterBlock(DeepslateTiles{Cracked: true}) + world.RegisterBlock(DeepslateTiles{}) world.RegisterBlock(Diamond{}) world.RegisterBlock(Diorite{Polished: true}) world.RegisterBlock(Diorite{}) @@ -42,7 +46,6 @@ func init() { world.RegisterBlock(EndBricks{}) world.RegisterBlock(EndStone{}) world.RegisterBlock(FletchingTable{}) - world.RegisterBlock(GildedBlackstone{}) world.RegisterBlock(GlassPane{}) world.RegisterBlock(Glass{}) world.RegisterBlock(Glowstone{}) @@ -66,16 +69,18 @@ func init() { world.RegisterBlock(NetherGoldOre{}) world.RegisterBlock(NetherQuartzOre{}) world.RegisterBlock(NetherSprouts{}) + world.RegisterBlock(NetherWartBlock{Warped: true}) + world.RegisterBlock(NetherWartBlock{}) world.RegisterBlock(Netherite{}) world.RegisterBlock(Netherrack{}) - world.RegisterBlock(NetherWartBlock{}) - world.RegisterBlock(NetherWartBlock{Warped: true}) world.RegisterBlock(Note{}) world.RegisterBlock(Obsidian{Crying: true}) world.RegisterBlock(Obsidian{}) world.RegisterBlock(PackedIce{}) world.RegisterBlock(PackedMud{}) world.RegisterBlock(Podzol{}) + world.RegisterBlock(PolishedBlackstoneBrick{Cracked: true}) + world.RegisterBlock(PolishedBlackstoneBrick{}) world.RegisterBlock(QuartzBricks{}) world.RegisterBlock(RawCopper{}) world.RegisterBlock(RawGold{}) @@ -113,6 +118,7 @@ func init() { registerAll(allBarrels()) registerAll(allBasalt()) registerAll(allBeetroot()) + registerAll(allBlackstone()) registerAll(allBlastFurnaces()) registerAll(allBoneBlock()) registerAll(allCactus()) @@ -126,6 +132,7 @@ func init() { registerAll(allConcretePowder()) registerAll(allCoral()) registerAll(allCoralBlocks()) + registerAll(allDeepslate()) registerAll(allDoors()) registerAll(allDoubleFlowers()) registerAll(allDoubleTallGrass()) @@ -213,6 +220,10 @@ func init() { world.RegisterItem(CocoaBean{}) world.RegisterItem(CraftingTable{}) world.RegisterItem(DeadBush{}) + world.RegisterItem(DeepslateBricks{Cracked: true}) + world.RegisterItem(DeepslateBricks{}) + world.RegisterItem(DeepslateTiles{Cracked: true}) + world.RegisterItem(DeepslateTiles{}) world.RegisterItem(Diamond{}) world.RegisterItem(Diorite{Polished: true}) world.RegisterItem(Diorite{}) @@ -229,7 +240,6 @@ func init() { world.RegisterItem(EnderChest{}) world.RegisterItem(Farmland{}) world.RegisterItem(Furnace{}) - world.RegisterItem(GildedBlackstone{}) world.RegisterItem(GlassPane{}) world.RegisterItem(Glass{}) world.RegisterItem(Glowstone{}) @@ -261,23 +271,25 @@ func init() { world.RegisterItem(NetherGoldOre{}) world.RegisterItem(NetherQuartzOre{}) world.RegisterItem(NetherSprouts{}) + world.RegisterItem(NetherWartBlock{Warped: true}) + world.RegisterItem(NetherWartBlock{}) world.RegisterItem(NetherWart{}) world.RegisterItem(Netherite{}) world.RegisterItem(Netherrack{}) - world.RegisterItem(NetherWartBlock{}) - world.RegisterItem(NetherWartBlock{Warped: true}) world.RegisterItem(Note{Pitch: 24}) world.RegisterItem(Obsidian{Crying: true}) world.RegisterItem(Obsidian{}) world.RegisterItem(PackedIce{}) world.RegisterItem(PackedMud{}) world.RegisterItem(Podzol{}) + world.RegisterItem(PolishedBlackstoneBrick{Cracked: true}) + world.RegisterItem(PolishedBlackstoneBrick{}) world.RegisterItem(Potato{}) world.RegisterItem(PumpkinSeeds{}) world.RegisterItem(Pumpkin{Carved: true}) world.RegisterItem(Pumpkin{}) - world.RegisterItem(Purpur{}) world.RegisterItem(PurpurPillar{}) + world.RegisterItem(Purpur{}) world.RegisterItem(QuartzBricks{}) world.RegisterItem(QuartzPillar{}) world.RegisterItem(Quartz{Smooth: true}) @@ -399,6 +411,12 @@ func init() { for _, s := range StairsBlocks() { world.RegisterItem(Stairs{Block: s}) } + for _, t := range BlackstoneTypes() { + world.RegisterItem(Blackstone{Type: t}) + } + for _, t := range DeepslateTypes() { + world.RegisterItem(Deepslate{Type: t}) + } } func registerAll(blocks []world.Block) { diff --git a/server/block/slab_type.go b/server/block/slab_type.go index fe76ad8e5..62d118d41 100644 --- a/server/block/slab_type.go +++ b/server/block/slab_type.go @@ -7,43 +7,86 @@ import ( // encodeSlabBlock encodes the provided block in to an identifier and meta value that can be used to encode the slab. func encodeSlabBlock(block world.Block) (id, slabType string, meta int16) { switch block := block.(type) { - case Planks: - switch block.Wood { - case OakWood(), SpruceWood(), BirchWood(), JungleWood(), AcaciaWood(), DarkOakWood(): - return block.Wood.String(), "wood_type", int16(block.Wood.Uint8()) - default: - return block.Wood.String(), "", 0 + // TODO: Copper + case Andesite: + if block.Polished { + return "polished_andesite", "stone_slab_type_3", 2 } - case Stone: - if block.Smooth { - return "smooth_stone", "stone_slab_type", 0 + return "andesite", "stone_slab_type_3", 3 + case Blackstone: + if block.Type == NormalBlackstone() { + return "blackstone", "", 0 + } else if block.Type == PolishedBlackstone() { + return "polished_blackstone", "", 0 } - return "stone", "stone_slab_type_4", 2 + case Bricks: + return "brick", "stone_slab_type", 4 case Cobblestone: if block.Mossy { return "mossy_cobblestone", "stone_slab_type_2", 5 } return "cobblestone", "stone_slab_type", 3 - case StoneBricks: - if block.Type == MossyStoneBricks() { - return "mossy_stone_brick", "stone_slab_type_4", 0 + case Deepslate: + if block.Type == CobbledDeepslate() { + return "cobbled_deepslate", "", 0 + } else if block.Type == PolishedDeepslate() { + return "polished_deepslate", "", 0 } - return "stone_brick", "stone_slab_type", 5 - case Andesite: - if block.Polished { - return "polished_andesite", "stone_slab_type_3", 2 + case DeepslateBricks: + if !block.Cracked { + return "deepslate_brick", "", 0 + } + case DeepslateTiles: + if !block.Cracked { + return "deepslate_tile", "", 0 } - return "andesite", "stone_slab_type_3", 3 case Diorite: if block.Polished { return "polished_diorite", "stone_slab_type_3", 5 } return "diorite", "stone_slab_type_3", 4 + case EndBricks: + return "end_stone_brick", "stone_slab_type_3", 0 case Granite: if block.Polished { return "polished_granite", "stone_slab_type_3", 7 } return "granite", "stone_slab_type_3", 6 + case MudBricks: + return "mud_brick", "", 0 + case NetherBricks: + if block.Type == RedNetherBricks() { + return "nether_brick", "stone_slab_type", 7 + } + return "red_nether_brick", "stone_slab_type_2", 7 + case Planks: + switch block.Wood { + case OakWood(), SpruceWood(), BirchWood(), JungleWood(), AcaciaWood(), DarkOakWood(): + return block.Wood.String(), "wood_type", int16(block.Wood.Uint8()) + default: + return block.Wood.String(), "", 0 + } + case PolishedBlackstoneBrick: + if !block.Cracked { + return "polished_blackstone_brick", "", 0 + } + case Prismarine: + switch block.Type { + case NormalPrismarine(): + return "prismarine_rough", "stone_slab_type_2", 2 + case DarkPrismarine(): + return "prismarine_dark", "stone_slab_type_2", 3 + case BrickPrismarine(): + return "prismarine_brick", "stone_slab_type_2", 4 + } + panic("invalid prismarine type") + case Purpur: + return "purpur", "stone_slab_type_2", 1 + case Quartz: + if block.Smooth { + return "smooth_quartz", "stone_slab_type_4", 1 + } + return "quartz", "stone_slab_type", 6 case Sandstone: switch block.Type { case NormalSandstone(): @@ -63,37 +106,16 @@ func encodeSlabBlock(block world.Block) (id, slabType string, meta int16) { return "smooth_sandstone", "stone_slab_type_2", 6 } panic("invalid sandstone type") - case Bricks: - return "brick", "stone_slab_type", 4 - case Prismarine: - switch block.Type { - case NormalPrismarine(): - return "prismarine_rough", "stone_slab_type_2", 2 - case DarkPrismarine(): - return "prismarine_dark", "stone_slab_type_2", 3 - case BrickPrismarine(): - return "prismarine_brick", "stone_slab_type_2", 4 - } - panic("invalid prismarine type") - case NetherBricks: - if block.Type == RedNetherBricks() { - return "nether_brick", "stone_slab_type", 7 - } - return "red_nether_brick", "stone_slab_type_2", 7 - case Quartz: + case Stone: if block.Smooth { - return "smooth_quartz", "stone_slab_type_4", 1 + return "smooth_stone", "stone_slab_type", 0 } - return "quartz", "stone_slab_type", 6 - case Purpur: - return "purpur", "stone_slab_type_2", 1 - case EndBricks: - return "end_stone_brick", "stone_slab_type_3", 0 - // TODO: Blackstone - // TODO: Copper - // TODO: Deepslate, - case MudBricks: - return "mud_brick", "", 0 + return "stone", "stone_slab_type_4", 2 + case StoneBricks: + if block.Type == MossyStoneBricks() { + return "mossy_stone_brick", "stone_slab_type_4", 0 + } + return "stone_brick", "stone_slab_type", 5 } panic("invalid block used for slab") } @@ -118,29 +140,34 @@ func encodeLegacySlabId(slabType string) string { // SlabBlocks returns a list of all possible blocks for a slab. func SlabBlocks() []world.Block { b := []world.Block{ - Stone{}, - Stone{Smooth: true}, - Cobblestone{}, - Cobblestone{Mossy: true}, - StoneBricks{}, - StoneBricks{Type: MossyStoneBricks()}, - Andesite{}, + // TODO: Copper Andesite{Polished: true}, - Diorite{}, + Andesite{}, + Blackstone{Type: PolishedBlackstone()}, + Blackstone{}, + Bricks{}, + Cobblestone{Mossy: true}, + Cobblestone{}, + DeepslateBricks{}, + DeepslateTiles{}, + Deepslate{Type: CobbledDeepslate()}, + Deepslate{Type: PolishedDeepslate()}, Diorite{Polished: true}, - Granite{}, + Diorite{}, + EndBricks{}, Granite{Polished: true}, - Bricks{}, - NetherBricks{}, + Granite{}, + MudBricks{}, NetherBricks{Type: RedNetherBricks()}, - Quartz{}, - Quartz{Smooth: true}, + NetherBricks{}, + PolishedBlackstoneBrick{}, Purpur{}, - EndBricks{}, - // TODO: Blackstone - // TODO: Copper - // TODO: Deepslate, - MudBricks{}, + Quartz{Smooth: true}, + Quartz{}, + StoneBricks{Type: MossyStoneBricks()}, + StoneBricks{}, + Stone{Smooth: true}, + Stone{}, } for _, p := range PrismarineTypes() { b = append(b, Prismarine{Type: p}) diff --git a/server/block/stairs_type.go b/server/block/stairs_type.go index 3d9932df9..dbe1f7f6c 100644 --- a/server/block/stairs_type.go +++ b/server/block/stairs_type.go @@ -7,53 +7,46 @@ import ( // encodeStairsBlock encodes the provided block in to an identifier and meta value that can be used to encode the stairs. func encodeStairsBlock(block world.Block) string { switch block := block.(type) { - case Planks: - return block.Wood.String() - case Stone: - if !block.Smooth { - return "normal_stone" + // TODO: Copper + case Andesite: + if block.Polished { + return "polished_andesite" + } + return "andesite" + case Blackstone: + if block.Type == NormalBlackstone() { + return "blackstone" + } else if block.Type == PolishedBlackstone() { + return "polished_blackstone" } + case PolishedBlackstoneBrick: + return "polished_blackstone_brick" + case Bricks: + return "brick" case Cobblestone: if block.Mossy { return "mossy_cobblestone" } return "stone" - case StoneBricks: - if block.Type == MossyStoneBricks() { - return "mossy_stone_brick" - } - return "stone_brick" - case Andesite: - if block.Polished { - return "polished_andesite" - } - return "andesite" case Diorite: if block.Polished { return "polished_diorite" } return "diorite" + case EndBricks: + return "end_brick" case Granite: if block.Polished { return "polished_granite" } return "granite" - case Sandstone: - switch block.Type { - case NormalSandstone(): - if block.Red { - return "red_sandstone" - } - return "sandstone" - case SmoothSandstone(): - if block.Red { - return "smooth_red_sandstone" - } - return "smooth_sandstone" + case NetherBricks: + if block.Type == RedNetherBricks() { + return "nether_brick" } - panic("invalid sandstone type") - case Bricks: - return "brick" + return "red_nether_brick" + case Planks: + return block.Wood.String() case Prismarine: switch block.Type { case NormalPrismarine(): @@ -64,25 +57,36 @@ func encodeStairsBlock(block world.Block) string { return "prismarine_bricks" } panic("invalid prismarine type") - case NetherBricks: - if block.Type == RedNetherBricks() { - return "nether_brick" - } - return "red_nether_brick" + case Purpur: + return "purpur" case Quartz: if block.Smooth { return "smooth_quartz" } return "quartz" - case Purpur: - return "purpur" - case EndBricks: - return "end_brick" - // TODO: Blackstone - // TODO: Copper - // TODO: Deepslate, - case MudBricks: - return "mud_brick" + case Sandstone: + switch block.Type { + case NormalSandstone(): + if block.Red { + return "red_sandstone" + } + return "sandstone" + case SmoothSandstone(): + if block.Red { + return "smooth_red_sandstone" + } + return "smooth_sandstone" + } + panic("invalid sandstone type") + case Stone: + if !block.Smooth { + return "normal_stone" + } + case StoneBricks: + if block.Type == MossyStoneBricks() { + return "mossy_stone_brick" + } + return "stone_brick" } panic("invalid block used for stairs") } @@ -90,14 +94,18 @@ func encodeStairsBlock(block world.Block) string { // StairsBlocks returns a list of all possible blocks for stairs. func StairsBlocks() []world.Block { b := []world.Block{ - // TODO: Blackstone // TODO: Copper - // TODO: Deepslate, Andesite{Polished: true}, Andesite{}, + Blackstone{Type: PolishedBlackstone()}, + Blackstone{}, Bricks{}, Cobblestone{Mossy: true}, Cobblestone{}, + DeepslateBricks{}, + DeepslateTiles{}, + Deepslate{Type: CobbledDeepslate()}, + Deepslate{Type: PolishedDeepslate()}, Diorite{Polished: true}, Diorite{}, EndBricks{}, @@ -106,6 +114,7 @@ func StairsBlocks() []world.Block { MudBricks{}, NetherBricks{Type: RedNetherBricks()}, NetherBricks{}, + PolishedBlackstoneBrick{}, Purpur{}, Quartz{Smooth: true}, Quartz{}, diff --git a/server/block/wall_type.go b/server/block/wall_type.go index 96e146266..47a7a9058 100644 --- a/server/block/wall_type.go +++ b/server/block/wall_type.go @@ -9,17 +9,33 @@ func encodeWallBlock(block world.Block) (string, int16) { if !block.Polished { return "andesite", 4 } - // TODO: Blackstone + case Blackstone: + if block.Type == NormalBlackstone() { + return "blackstone", 0 + } else if block.Type == PolishedBlackstone() { + return "polished_blackstone", 0 + } case Bricks: return "brick", 6 - // TODO: Cobbled Deepslate case Cobblestone: if block.Mossy { return "mossy_cobblestone", 1 } return "cobblestone", 0 - // TODO: Deepslate Brick - // TODO: Deepslate Tile + case Deepslate: + if block.Type == CobbledDeepslate() { + return "cobbled_deepslate", 0 + } else if block.Type == PolishedDeepslate() { + return "polished_deepslate", 0 + } + case DeepslateBricks: + if !block.Cracked { + return "deepslate_brick", 0 + } + case DeepslateTiles: + if !block.Cracked { + return "deepslate_tile", 0 + } case Diorite: if !block.Polished { return "diorite", 3 @@ -38,6 +54,10 @@ func encodeWallBlock(block world.Block) (string, int16) { } else if block.Type == RedNetherBricks() { return "red_nether_brick", 13 } + case PolishedBlackstoneBrick: + if !block.Cracked { + return "polished_blackstone_brick", 0 + } case Prismarine: if block.Type == NormalPrismarine() { return "prismarine", 11 @@ -63,26 +83,26 @@ func encodeWallBlock(block world.Block) (string, int16) { func WallBlocks() []world.Block { return []world.Block{ Andesite{}, - // TODO: Blackstone + Blackstone{Type: PolishedBlackstone()}, + Blackstone{}, Bricks{}, - // TODO: Cobbled Deepslate - Cobblestone{}, Cobblestone{Mossy: true}, - // TODO: Deepslate Brick - // TODO: Deepslate Tile + Cobblestone{}, + DeepslateBricks{}, + DeepslateTiles{}, + Deepslate{Type: CobbledDeepslate()}, + Deepslate{Type: PolishedDeepslate()}, Diorite{}, EndBricks{}, Granite{}, MudBricks{}, - NetherBricks{}, NetherBricks{Type: RedNetherBricks()}, - // TODO: Polished Blackstone - // TODO: Polished Blackstone brick - // TODO: Polished Deepslate + NetherBricks{}, + PolishedBlackstoneBrick{}, Prismarine{}, - Sandstone{}, Sandstone{Red: true}, - StoneBricks{}, + Sandstone{}, StoneBricks{Type: MossyStoneBricks()}, + StoneBricks{}, } }