MC 1.17/1.18 Terrain/Entity/Inventory (#1943)

Merge branch 'master' of github.com:milutinke/Minecraft-Console-Client into milutinke-master

Manually fix merge conflicts
Additional changes:
 - WindowItems: Fix data type for "elements" below 1.17
 - DestroyEntities: Fix packet palettes and remove DestroyEntity
 - EntityMetadata: Throw exception if health field mapping is not updated

Co-authored-by: Milutinke <bgteam@live.com>
Co-authored-by: BruceChen <MrChen131217@gmail.com>
This commit is contained in:
ORelio 2022-08-19 16:35:55 +02:00
commit 1ce7850193
34 changed files with 5983 additions and 920 deletions

View file

@ -23,6 +23,17 @@ namespace MinecraftClient.Mapping.BlockPalettes
/// </remarks>
public static class BlockPaletteGenerator
{
/// <summary>
/// Generate mapping from Minecraft blocks.json
/// </summary>
/// <param name="blocksJsonFile">path to blocks.json</param>
/// <remarks>java -cp minecraft_server.jar net.minecraft.data.Main --reports</remarks>
/// <returns>state => block name mappings</returns>
public static void GenerateBlockPalette(string blocksJsonFile)
{
BlockPaletteGenerator.JsonToClass(blocksJsonFile, "Palette", "Material");
}
/// <summary>
/// Generate mapping from Minecraft blocks.json
/// </summary>
@ -33,6 +44,9 @@ namespace MinecraftClient.Mapping.BlockPalettes
/// <returns>state => block name mappings</returns>
public static void JsonToClass(string blocksJsonFile, string outputClass, string outputEnum = null)
{
string outputPalettePath = Path.Combine(Path.GetDirectoryName(blocksJsonFile), outputClass + "XXX.cs");
string outputEnumPath = Path.Combine(Path.GetDirectoryName(blocksJsonFile), outputEnum + "XXX.cs");
HashSet<int> knownStates = new HashSet<int>();
Dictionary<string, HashSet<int>> blocks = new Dictionary<string, HashSet<int>>();
@ -70,7 +84,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
"",
"namespace MinecraftClient.Mapping.BlockPalettes",
"{",
" public class PaletteXXX : PaletteMapping",
" public class PaletteXXX : BlockPalette",
" {",
" private static Dictionary<int, Material> materials = new Dictionary<int, Material>();",
"",
@ -121,7 +135,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
"}"
});
File.WriteAllLines(outputClass, outFile);
File.WriteAllLines(outputPalettePath, outFile);
if (outputEnum != null)
{
@ -138,7 +152,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
" }",
"}"
});
File.WriteAllLines(outputEnum, outFile);
File.WriteAllLines(outputEnumPath, outFile);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -11,18 +11,29 @@ namespace MinecraftClient.Mapping
/// </summary>
public class ChunkColumn
{
public const int ColumnSize = 16;
public int ColumnSize;
public bool FullyLoaded = false;
/// <summary>
/// Blocks contained into the chunk
/// </summary>
private readonly Chunk[] chunks = new Chunk[ColumnSize];
private readonly Chunk[] chunks;
/// <summary>
/// Lock for thread safety
/// </summary>
private readonly ReaderWriterLockSlim chunkLock = new ReaderWriterLockSlim();
/// <summary>
/// Create a new ChunkColumn
/// </summary>
public ChunkColumn(int size = 16)
{
ColumnSize = size;
chunks = new Chunk[size];
}
/// <summary>
/// Get or set the specified chunk column
/// </summary>

View file

@ -0,0 +1,176 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MinecraftClient.Mapping
{
/// <summary>
/// The dimension type, available after 1.16.2
/// </summary>
public class Dimension
{
/// <summary>
/// The name of the dimension type (for example, "minecraft:overworld").
/// </summary>
public readonly string Name;
/// <summary>
/// Whether piglins shake and transform to zombified piglins.
/// </summary>
public readonly bool piglinSafe = false;
/// <summary>
/// When false, compasses spin randomly. When true, nether portals can spawn zombified piglins.
/// </summary>
public readonly bool natural = true;
/// <summary>
/// How much light the dimension has.
/// </summary>
public readonly float ambientLight = 0.0f;
/// <summary>
/// If set, the time of the day is the specified value.
/// Value: -1: not set
/// Value: [0, 24000]: time of the day
/// </summary>
public readonly long fixedTime = -1;
/// <summary>
/// A resource location defining what block tag to use for infiniburn.
/// Value above 1.18.2: "#" or minecraft resource "#minecraft:...".
/// Value below 1.18.1: "" or minecraft resource "minecraft:...".
/// </summary>
public readonly string infiniburn = "#minecraft:infiniburn_overworld";
/// <summary>
/// Whether players can charge and use respawn anchors.
/// </summary>
public readonly bool respawnAnchorWorks = false;
/// <summary>
/// Whether the dimension has skylight access or not.
/// </summary>
public readonly bool hasSkylight = true;
/// <summary>
/// Whether players can use a bed to sleep.
/// </summary>
public readonly bool bedWorks = true;
/// <summary>
/// unknown
/// Values: "minecraft:overworld", "minecraft:the_nether", "minecraft:the_end" or something else.
/// </summary>
public readonly string effects = "minecraft:overworld";
/// <summary>
/// Whether players with the Bad Omen effect can cause a raid.
/// </summary>
public readonly bool hasRaids = true;
/// <summary>
/// The minimum Y level.
/// </summary>
public readonly int minY = 0;
/// <summary>
/// The maximum Y level.
/// </summary>
public readonly int maxY = 256;
/// <summary>
/// The maximum height.
/// </summary>
public readonly int height = 256;
/// <summary>
/// The maximum height to which chorus fruits and nether portals can bring players within this dimension.
/// </summary>
public readonly int logicalHeight = 256;
/// <summary>
/// The multiplier applied to coordinates when traveling to the dimension.
/// </summary>
public readonly double coordinateScale = 1.0;
/// <summary>
/// Whether the dimensions behaves like the nether (water evaporates and sponges dry) or not. Also causes lava to spread thinner.
/// </summary>
public readonly bool ultrawarm = false;
/// <summary>
/// Whether the dimension has a bedrock ceiling or not. When true, causes lava to spread faster.
/// </summary>
public readonly bool hasCeiling = false;
/// <summary>
/// Default value used in version below 1.17
/// </summary>
public Dimension()
{
this.Name = "minecraft:overworld";
}
/// <summary>
/// Create from the "Dimension Codec" NBT Tag Compound
/// </summary>
/// <param name="name">Dimension name</param>
/// <param name="nbt">The dimension type (NBT Tag Compound)</param>
public Dimension(string name, Dictionary<string, object> nbt)
{
if (name == null)
throw new ArgumentNullException("name");
if (nbt == null)
throw new ArgumentNullException("nbt Data");
this.Name = name;
if (nbt.ContainsKey("piglin_safe"))
this.piglinSafe = 1 == (byte)nbt["piglin_safe"];
if (nbt.ContainsKey("natural"))
this.natural = 1 == (byte)nbt["natural"];
if (nbt.ContainsKey("ambient_light"))
this.ambientLight = (float)nbt["ambient_light"];
if (nbt.ContainsKey("fixed_time"))
this.fixedTime = (long)nbt["fixed_time"];
if (nbt.ContainsKey("infiniburn"))
this.infiniburn = (string)nbt["infiniburn"];
if (nbt.ContainsKey("respawn_anchor_works"))
this.respawnAnchorWorks = 1 == (byte)nbt["respawn_anchor_works"];
if (nbt.ContainsKey("has_skylight"))
this.hasSkylight = 1 == (byte)nbt["has_skylight"];
if (nbt.ContainsKey("bed_works"))
this.bedWorks = 1 == (byte)nbt["bed_works"];
if (nbt.ContainsKey("effects"))
this.effects = (string)nbt["effects"];
if (nbt.ContainsKey("has_raids"))
this.hasRaids = 1 == (byte)nbt["has_raids"];
if (nbt.ContainsKey("min_y"))
this.minY = (int)nbt["min_y"];
if (nbt.ContainsKey("height"))
this.height = (int)nbt["height"];
if (nbt.ContainsKey("min_y") && nbt.ContainsKey("height"))
this.maxY = this.minY + this.height;
if (nbt.ContainsKey("logical_height"))
this.logicalHeight = (int)nbt["logical_height"];
if (nbt.ContainsKey("coordinate_scale"))
{
var coordinateScaleObj = nbt["coordinate_scale"];
if (coordinateScaleObj.GetType() == typeof(float))
this.coordinateScale = (float)coordinateScaleObj;
else
this.coordinateScale = (double)coordinateScaleObj;
}
if (nbt.ContainsKey("ultrawarm"))
this.ultrawarm = 1 == (byte)nbt["ultrawarm"];
if (nbt.ContainsKey("has_ceiling"))
this.hasCeiling = 1 == (byte)nbt["has_ceiling"];
}
}
}

View file

@ -0,0 +1,132 @@
using System;
using System.Collections.Generic;
namespace MinecraftClient.Mapping.EntityPalettes
{
public class EntityPalette117 : EntityPalette
{
private static Dictionary<int, EntityType> mappings = new Dictionary<int, EntityType>();
static EntityPalette117()
{
mappings[0] = EntityType.AreaEffectCloud;
mappings[1] = EntityType.ArmorStand;
mappings[2] = EntityType.Arrow;
mappings[3] = EntityType.Axolotl;
mappings[4] = EntityType.Bat;
mappings[5] = EntityType.Bee;
mappings[6] = EntityType.Blaze;
mappings[7] = EntityType.Boat;
mappings[8] = EntityType.Cat;
mappings[9] = EntityType.CaveSpider;
mappings[10] = EntityType.Chicken;
mappings[11] = EntityType.Cod;
mappings[12] = EntityType.Cow;
mappings[13] = EntityType.Creeper;
mappings[14] = EntityType.Dolphin;
mappings[15] = EntityType.Donkey;
mappings[16] = EntityType.DragonFireball;
mappings[17] = EntityType.Drowned;
mappings[18] = EntityType.ElderGuardian;
mappings[19] = EntityType.EndCrystal;
mappings[20] = EntityType.EnderDragon;
mappings[21] = EntityType.Enderman;
mappings[22] = EntityType.Endermite;
mappings[23] = EntityType.Evoker;
mappings[24] = EntityType.EvokerFangs;
mappings[25] = EntityType.ExperienceOrb;
mappings[26] = EntityType.EyeOfEnder;
mappings[27] = EntityType.FallingBlock;
mappings[28] = EntityType.FireworkRocket;
mappings[29] = EntityType.Fox;
mappings[30] = EntityType.Ghast;
mappings[31] = EntityType.Giant;
mappings[32] = EntityType.GlowItemFrame;
mappings[33] = EntityType.GlowSquid;
mappings[34] = EntityType.Goat;
mappings[35] = EntityType.Guardian;
mappings[36] = EntityType.Hoglin;
mappings[37] = EntityType.Horse;
mappings[38] = EntityType.Husk;
mappings[39] = EntityType.Illusioner;
mappings[40] = EntityType.IronGolem;
mappings[41] = EntityType.Item;
mappings[42] = EntityType.ItemFrame;
mappings[43] = EntityType.Fireball;
mappings[44] = EntityType.LeashKnot;
mappings[45] = EntityType.LightningBolt;
mappings[46] = EntityType.Llama;
mappings[47] = EntityType.LlamaSpit;
mappings[48] = EntityType.MagmaCube;
mappings[49] = EntityType.Marker;
mappings[50] = EntityType.Minecart;
mappings[51] = EntityType.ChestMinecart;
mappings[52] = EntityType.CommandBlockMinecart;
mappings[53] = EntityType.FurnaceMinecart;
mappings[54] = EntityType.HopperMinecart;
mappings[55] = EntityType.SpawnerMinecart;
mappings[56] = EntityType.TntMinecart;
mappings[57] = EntityType.Mule;
mappings[58] = EntityType.Mooshroom;
mappings[59] = EntityType.Ocelot;
mappings[60] = EntityType.Painting;
mappings[61] = EntityType.Panda;
mappings[62] = EntityType.Parrot;
mappings[63] = EntityType.Phantom;
mappings[64] = EntityType.Pig;
mappings[65] = EntityType.Piglin;
mappings[66] = EntityType.PiglinBrute;
mappings[67] = EntityType.Pillager;
mappings[68] = EntityType.PolarBear;
mappings[69] = EntityType.Tnt;
mappings[70] = EntityType.Pufferfish;
mappings[71] = EntityType.Rabbit;
mappings[72] = EntityType.Ravager;
mappings[73] = EntityType.Salmon;
mappings[74] = EntityType.Sheep;
mappings[75] = EntityType.Shulker;
mappings[76] = EntityType.ShulkerBullet;
mappings[77] = EntityType.Silverfish;
mappings[78] = EntityType.Skeleton;
mappings[79] = EntityType.SkeletonHorse;
mappings[80] = EntityType.Slime;
mappings[81] = EntityType.SmallFireball;
mappings[82] = EntityType.SnowGolem;
mappings[83] = EntityType.Snowball;
mappings[84] = EntityType.SpectralArrow;
mappings[85] = EntityType.Spider;
mappings[86] = EntityType.Squid;
mappings[87] = EntityType.Stray;
mappings[88] = EntityType.Strider;
mappings[89] = EntityType.Egg;
mappings[90] = EntityType.EnderPearl;
mappings[91] = EntityType.ExperienceBottle;
mappings[92] = EntityType.Potion;
mappings[93] = EntityType.Trident;
mappings[94] = EntityType.TraderLlama;
mappings[95] = EntityType.TropicalFish;
mappings[96] = EntityType.Turtle;
mappings[97] = EntityType.Vex;
mappings[98] = EntityType.Villager;
mappings[99] = EntityType.Vindicator;
mappings[100] = EntityType.WanderingTrader;
mappings[101] = EntityType.Witch;
mappings[102] = EntityType.Wither;
mappings[103] = EntityType.WitherSkeleton;
mappings[104] = EntityType.WitherSkull;
mappings[105] = EntityType.Wolf;
mappings[106] = EntityType.Zoglin;
mappings[107] = EntityType.Zombie;
mappings[108] = EntityType.ZombieHorse;
mappings[109] = EntityType.ZombieVillager;
mappings[110] = EntityType.ZombifiedPiglin;
mappings[111] = EntityType.Player;
mappings[112] = EntityType.FishingBobber;
}
protected override Dictionary<int, EntityType> GetDict()
{
return mappings;
}
}
}

View file

@ -17,6 +17,7 @@ namespace MinecraftClient.Mapping
AreaEffectCloud,
ArmorStand,
Arrow,
Axolotl,
Bat,
Bee,
Blaze,
@ -53,6 +54,9 @@ namespace MinecraftClient.Mapping
FurnaceMinecart,
Ghast,
Giant,
GlowItemFrame,
GlowSquid,
Goat,
Guardian,
Hoglin,
HopperMinecart,
@ -67,6 +71,7 @@ namespace MinecraftClient.Mapping
Llama,
LlamaSpit,
MagmaCube,
Marker,
Minecart,
Mooshroom,
Mule,

View file

@ -62,6 +62,7 @@ namespace MinecraftClient.Mapping
{
switch (e)
{
case EntityType.GlowItemFrame:
case EntityType.Item:
case EntityType.ItemFrame:
case EntityType.EyeOfEnder:

View file

@ -14,7 +14,7 @@ namespace MinecraftClient.Mapping
/// The X Coordinate
/// </summary>
public double X;
/// <summary>
/// The Y Coordinate (vertical)
/// </summary>
@ -79,7 +79,7 @@ namespace MinecraftClient.Mapping
{
get
{
return (int)Math.Floor(Y / Chunk.SizeY);
return (int)Math.Floor((Y - World.GetDimension().minY) / Chunk.SizeY);
}
}
@ -299,7 +299,7 @@ namespace MinecraftClient.Mapping
/// <returns>String representation of the location</returns>
public override string ToString()
{
return String.Format("X:{0} Y:{1} Z:{2}", X, Y, Z);
return String.Format("X:{0:0.00} Y:{1:0.00} Z:{2:0.00}", X, Y, Z);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -42,9 +42,11 @@ namespace MinecraftClient.Mapping
Material.BrownGlazedTerracotta,
Material.BrownShulkerBox,
Material.BrownTerracotta,
Material.Calcite,
Material.Cauldron,
Material.Chain,
Material.ChippedAnvil,
Material.ChiseledDeepslate,
Material.ChiseledNetherBricks,
Material.ChiseledPolishedBlackstone,
Material.ChiseledQuartzBlock,
@ -53,11 +55,17 @@ namespace MinecraftClient.Mapping
Material.ChiseledStoneBricks,
Material.CoalBlock,
Material.CoalOre,
Material.CobbledDeepslate,
Material.CobbledDeepslateSlab,
Material.CobbledDeepslateStairs,
Material.CobbledDeepslateWall,
Material.Cobblestone,
Material.CobblestoneSlab,
Material.CobblestoneStairs,
Material.CobblestoneWall,
Material.Conduit,
Material.CrackedDeepslateBricks,
Material.CrackedDeepslateTiles,
Material.CrackedNetherBricks,
Material.CrackedPolishedBlackstoneBricks,
Material.CrackedStoneBricks,
@ -74,12 +82,23 @@ namespace MinecraftClient.Mapping
Material.DarkPrismarine,
Material.DarkPrismarineSlab,
Material.DarkPrismarineStairs,
Material.Deepslate,
Material.DeepslateBrickSlab,
Material.DeepslateBrickStairs,
Material.DeepslateBrickWall,
Material.DeepslateBricks,
Material.DeepslateCoalOre,
Material.DeepslateTileSlab,
Material.DeepslateTileStairs,
Material.DeepslateTileWall,
Material.DeepslateTiles,
Material.DetectorRail,
Material.Diorite,
Material.DioriteSlab,
Material.DioriteStairs,
Material.DioriteWall,
Material.Dispenser,
Material.DripstoneBlock,
Material.Dropper,
Material.EnchantingTable,
Material.EndRod,
@ -113,6 +132,7 @@ namespace MinecraftClient.Mapping
Material.IronDoor,
Material.IronTrapdoor,
Material.Lantern,
Material.LavaCauldron,
Material.LightBlueConcrete,
Material.LightBlueGlazedTerracotta,
Material.LightBlueShulkerBox,
@ -160,6 +180,7 @@ namespace MinecraftClient.Mapping
Material.PinkShulkerBox,
Material.PinkTerracotta,
Material.Piston,
Material.PointedDripstone,
Material.PolishedAndesite,
Material.PolishedAndesiteSlab,
Material.PolishedAndesiteStairs,
@ -180,6 +201,7 @@ namespace MinecraftClient.Mapping
Material.PolishedGranite,
Material.PolishedGraniteSlab,
Material.PolishedGraniteStairs,
Material.PowderSnowCauldron,
Material.PoweredRail,
Material.Prismarine,
Material.PrismarineBrickSlab,
@ -221,6 +243,7 @@ namespace MinecraftClient.Mapping
Material.SandstoneWall,
Material.ShulkerBox,
Material.Smoker,
Material.SmoothBasalt,
Material.SmoothQuartz,
Material.SmoothQuartzSlab,
Material.SmoothQuartzStairs,
@ -245,7 +268,9 @@ namespace MinecraftClient.Mapping
Material.StoneStairs,
Material.Stonecutter,
Material.Terracotta,
Material.Tuff,
Material.WarpedNylium,
Material.WaterCauldron,
Material.WhiteConcrete,
Material.WhiteGlazedTerracotta,
Material.WhiteShulkerBox,
@ -253,26 +278,70 @@ namespace MinecraftClient.Mapping
Material.YellowConcrete,
Material.YellowGlazedTerracotta,
Material.YellowShulkerBox,
Material.YellowTerracotta
Material.YellowTerracotta,
};
// Minable by Stone, iron, diamond, netherite.
private static readonly List<Material> pickaxeTier1 = new List<Material>()
{
Material.CopperOre,
Material.CopperBlock,
Material.CutCopperSlab,
Material.CutCopperStairs,
Material.CutCopper,
Material.DeepslateCopperOre,
Material.DeepslateIronOre,
Material.DeepslateLapisOre,
Material.ExposedCopper,
Material.ExposedCutCopperSlab,
Material.ExposedCutCopperStairs,
Material.ExposedCutCopper,
Material.IronBlock,
Material.IronOre,
Material.LapisBlock,
Material.LapisOre,
Material.LightningRod,
Material.OxidizedCopper,
Material.OxidizedCutCopperSlab,
Material.OxidizedCutCopperStairs,
Material.OxidizedCutCopper,
Material.RawCopperBlock,
Material.RawIronBlock,
Material.Terracotta,
Material.WaxedCopperBlock,
Material.WaxedCutCopperSlab,
Material.WaxedCutCopperStairs,
Material.WaxedCutCopper,
Material.WaxedExposedCopper,
Material.WaxedExposedCutCopperSlab,
Material.WaxedExposedCutCopperStairs,
Material.WaxedExposedCutCopper,
Material.WaxedOxidizedCopper,
Material.WaxedOxidizedCutCopperSlab,
Material.WaxedOxidizedCutCopperStairs,
Material.WaxedOxidizedCutCopper,
Material.WaxedWeatheredCopper,
Material.WaxedWeatheredCutCopperSlab,
Material.WaxedWeatheredCutCopperStairs,
Material.WaxedWeatheredCutCopper,
Material.WeatheredCopper,
Material.WeatheredCutCopperSlab,
Material.WeatheredCutCopperStairs,
Material.WeatheredCutCopper,
};
// Minable by Iron, diamond, netherite.
private static readonly List<Material> pickaxeTier2 = new List<Material>()
{
Material.DeepslateDiamondOre,
Material.DeepslateEmeraldOre,
Material.DeepslateGoldOre,
Material.DeepslateRedstoneOre,
Material.DiamondBlock,
Material.DiamondOre,
Material.EmeraldBlock,
Material.EmeraldOre,
Material.GoldBlock,
Material.GoldOre,
Material.RawGoldBlock,
Material.RedstoneOre,
};
// Minable by Diamond, Netherite.
@ -314,13 +383,14 @@ namespace MinecraftClient.Mapping
Material.PurpleConcretePowder,
Material.RedConcretePowder,
Material.RedSand,
Material.RootedDirt,
Material.Sand,
Material.Snow,
Material.SnowBlock,
Material.SoulSand,
Material.SoulSoil,
Material.WhiteConcretePowder,
Material.YellowConcretePowder
Material.YellowConcretePowder,
};
// Every axe can mine every block (speed difference).
private static readonly List<Material> axe = new List<Material>()
@ -341,6 +411,7 @@ namespace MinecraftClient.Mapping
Material.Barrel,
Material.BeeNest,
Material.Beehive,
Material.BigDripleaf,
Material.BirchButton,
Material.BirchDoor,
Material.BirchFence,
@ -504,12 +575,13 @@ namespace MinecraftClient.Mapping
Material.WhiteBanner,
Material.WhiteWallBanner,
Material.YellowBanner,
Material.YellowWallBanner
Material.YellowWallBanner,
};
// Every block a shear can mine.
private static readonly List<Material> shears = new List<Material>()
{
Material.AcaciaLeaves,
Material.AzaleaLeaves,
Material.BirchLeaves,
Material.BlackWool,
Material.BlueWool,
@ -517,6 +589,7 @@ namespace MinecraftClient.Mapping
Material.Cobweb,
Material.CyanWool,
Material.DarkOakLeaves,
Material.FloweringAzaleaLeaves,
Material.GrayWool,
Material.GreenWool,
Material.JungleLeaves,
@ -539,6 +612,7 @@ namespace MinecraftClient.Mapping
Material.Bamboo,
Material.Cobweb,
Material.InfestedChiseledStoneBricks,
Material.InfestedDeepslate,
Material.InfestedCobblestone,
Material.InfestedCrackedStoneBricks,
Material.InfestedMossyStoneBricks,
@ -553,8 +627,10 @@ namespace MinecraftClient.Mapping
Material.DarkOakLeaves,
Material.HayBlock,
Material.JungleLeaves,
Material.MossBlock,
Material.NetherWartBlock,
Material.OakLeaves,
Material.SculkSensor,
Material.Shroomlight,
Material.Sponge,
Material.SpruceLeaves,
@ -565,7 +641,7 @@ namespace MinecraftClient.Mapping
// Liquids
private static readonly List<Material> bucket = new List<Material>()
{
Material.Lava,
Material.Lava,
Material.Water
};
@ -597,7 +673,7 @@ namespace MinecraftClient.Mapping
{
if (pickaxeTier0.Contains(block))
{
return new ItemType[]
return new ItemType[]
{
ItemType.NetheritePickaxe,
ItemType.DiamondPickaxe,
@ -609,7 +685,7 @@ namespace MinecraftClient.Mapping
}
else if (pickaxeTier1.Contains(block))
{
return new ItemType[]
return new ItemType[]
{
ItemType.NetheritePickaxe,
ItemType.DiamondPickaxe,
@ -620,7 +696,7 @@ namespace MinecraftClient.Mapping
}
else if (pickaxeTier2.Contains(block))
{
return new ItemType[]
return new ItemType[]
{
ItemType.NetheritePickaxe,
ItemType.DiamondPickaxe,
@ -629,7 +705,7 @@ namespace MinecraftClient.Mapping
}
else if (pickaxeTier3.Contains(block))
{
return new ItemType[]
return new ItemType[]
{
ItemType.NetheritePickaxe,
ItemType.DiamondPickaxe,
@ -637,7 +713,7 @@ namespace MinecraftClient.Mapping
}
else if (shovel.Contains(block))
{
return new ItemType[]
return new ItemType[]
{
ItemType.NetheriteShovel,
ItemType.DiamondShovel,
@ -649,7 +725,7 @@ namespace MinecraftClient.Mapping
}
else if (axe.Contains(block))
{
return new ItemType[]
return new ItemType[]
{
ItemType.NetheriteAxe,
ItemType.DiamondAxe,
@ -661,14 +737,14 @@ namespace MinecraftClient.Mapping
}
else if (shears.Contains(block))
{
return new ItemType[]
return new ItemType[]
{
ItemType.Shears,
};
}
else if (sword.Contains(block))
{
return new ItemType[]
return new ItemType[]
{
ItemType.NetheriteSword,
ItemType.DiamondSword,
@ -680,7 +756,7 @@ namespace MinecraftClient.Mapping
}
else if (hoe.Contains(block))
{
return new ItemType[]
return new ItemType[]
{
ItemType.NetheriteHoe,
ItemType.DiamondHoe,
@ -692,7 +768,7 @@ namespace MinecraftClient.Mapping
}
else if (bucket.Contains(block))
{
return new ItemType[]
return new ItemType[]
{
ItemType.Bucket,
};

View file

@ -74,6 +74,8 @@ namespace MinecraftClient.Mapping
case Material.JungleLeaves:
case Material.AcaciaLeaves:
case Material.DarkOakLeaves:
case Material.AzaleaLeaves:
case Material.FloweringAzaleaLeaves:
case Material.Sponge:
case Material.WetSponge:
case Material.Glass:
@ -202,6 +204,9 @@ namespace MinecraftClient.Mapping
case Material.EnchantingTable:
case Material.BrewingStand:
case Material.Cauldron:
case Material.WaterCauldron:
case Material.LavaCauldron:
case Material.PowderSnowCauldron:
case Material.EndPortalFrame:
case Material.EndStone:
case Material.DragonEgg:
@ -518,6 +523,119 @@ namespace MinecraftClient.Mapping
case Material.Beehive:
case Material.HoneyBlock:
case Material.HoneycombBlock:
case Material.Candle:
case Material.WhiteCandle:
case Material.OrangeCandle:
case Material.MagentaCandle:
case Material.LightBlueCandle:
case Material.YellowCandle:
case Material.LimeCandle:
case Material.PinkCandle:
case Material.GrayCandle:
case Material.LightGrayCandle:
case Material.CyanCandle:
case Material.PurpleCandle:
case Material.BlueCandle:
case Material.BrownCandle:
case Material.GreenCandle:
case Material.RedCandle:
case Material.BlackCandle:
case Material.CandleCake:
case Material.WhiteCandleCake:
case Material.OrangeCandleCake:
case Material.MagentaCandleCake:
case Material.LightBlueCandleCake:
case Material.YellowCandleCake:
case Material.LimeCandleCake:
case Material.PinkCandleCake:
case Material.GrayCandleCake:
case Material.LightGrayCandleCake:
case Material.CyanCandleCake:
case Material.PurpleCandleCake:
case Material.BlueCandleCake:
case Material.BrownCandleCake:
case Material.GreenCandleCake:
case Material.RedCandleCake:
case Material.BlackCandleCake:
case Material.AmethystBlock:
case Material.BuddingAmethyst:
case Material.AmethystCluster:
case Material.LargeAmethystBud:
case Material.MediumAmethystBud:
case Material.SmallAmethystBud:
case Material.Tuff:
case Material.Calcite:
case Material.TintedGlass:
case Material.SculkSensor:
case Material.OxidizedCopper:
case Material.WeatheredCopper:
case Material.ExposedCopper:
case Material.CopperBlock:
case Material.CopperOre:
case Material.DeepslateCopperOre:
case Material.OxidizedCutCopper:
case Material.WeatheredCutCopper:
case Material.ExposedCutCopper:
case Material.CutCopper:
case Material.OxidizedCutCopperStairs:
case Material.WeatheredCutCopperStairs:
case Material.ExposedCutCopperStairs:
case Material.CutCopperStairs:
case Material.OxidizedCutCopperSlab:
case Material.WeatheredCutCopperSlab:
case Material.ExposedCutCopperSlab:
case Material.CutCopperSlab:
case Material.WaxedCopperBlock:
case Material.WaxedWeatheredCopper:
case Material.WaxedExposedCopper:
case Material.WaxedOxidizedCopper:
case Material.WaxedOxidizedCutCopper:
case Material.WaxedWeatheredCutCopper:
case Material.WaxedExposedCutCopper:
case Material.WaxedCutCopper:
case Material.WaxedOxidizedCutCopperStairs:
case Material.WaxedWeatheredCutCopperStairs:
case Material.WaxedExposedCutCopperStairs:
case Material.WaxedCutCopperStairs:
case Material.WaxedOxidizedCutCopperSlab:
case Material.WaxedWeatheredCutCopperSlab:
case Material.WaxedExposedCutCopperSlab:
case Material.WaxedCutCopperSlab:
case Material.LightningRod:
case Material.PointedDripstone:
case Material.DripstoneBlock:
case Material.Azalea:
case Material.FloweringAzalea:
case Material.MossCarpet:
case Material.MossBlock:
case Material.RootedDirt:
case Material.Deepslate:
case Material.CobbledDeepslate:
case Material.CobbledDeepslateStairs:
case Material.CobbledDeepslateSlab:
case Material.CobbledDeepslateWall:
case Material.PolishedDeepslate:
case Material.PolishedDeepslateStairs:
case Material.PolishedDeepslateSlab:
case Material.PolishedDeepslateWall:
case Material.DeepslateTiles:
case Material.DeepslateTileStairs:
case Material.DeepslateTileSlab:
case Material.DeepslateTileWall:
case Material.DeepslateBricks:
case Material.DeepslateBrickStairs:
case Material.DeepslateBrickSlab:
case Material.DeepslateBrickWall:
case Material.ChiseledDeepslate:
case Material.CrackedDeepslateBricks:
case Material.CrackedDeepslateTiles:
case Material.InfestedDeepslate:
case Material.SmoothBasalt:
case Material.RawIronBlock:
case Material.RawCopperBlock:
case Material.RawGoldBlock:
case Material.PottedAzaleaBush:
case Material.PottedFloweringAzaleaBush:
return true;
default:
return false;
@ -538,6 +656,7 @@ namespace MinecraftClient.Mapping
case Material.Lava:
case Material.MagmaBlock:
case Material.Campfire:
case Material.PowderSnow:
return true;
default:
return false;

View file

@ -32,7 +32,7 @@ namespace MinecraftClient.Mapping
}
if (!IsOnGround(world, location) && !IsSwimming(world, location))
{
while (!IsOnGround(world, belowFoots) && belowFoots.Y >= 1)
while (!IsOnGround(world, belowFoots) && belowFoots.Y >= 1 + World.GetDimension().minY)
belowFoots = Move(belowFoots, Direction.Down);
location = Move2Steps(location, belowFoots, ref motionY, true).Dequeue();
}
@ -446,6 +446,9 @@ namespace MinecraftClient.Mapping
/// <returns>True if the specified location is on the ground</returns>
public static bool IsOnGround(World world, Location location)
{
if (world.GetChunkColumn(location) == null || world.GetChunkColumn(location).FullyLoaded == false)
return true; // avoid moving downward in a not loaded chunk
return world.GetBlock(Move(location, Direction.Down)).Type.IsSolid()
&& (location.Y <= Math.Truncate(location.Y) + 0.0001);
}

View file

@ -16,11 +16,22 @@ namespace MinecraftClient.Mapping
/// </summary>
private Dictionary<int, Dictionary<int, ChunkColumn>> chunks = new Dictionary<int, Dictionary<int, ChunkColumn>>();
/// <summary>
/// The dimension info of the world
/// </summary>
private static Dimension dimension = new Dimension();
/// <summary>
/// Lock for thread safety
/// </summary>
private readonly ReaderWriterLockSlim chunksLock = new ReaderWriterLockSlim();
/// <summary>
/// Chunk data parsing progress
/// </summary>
public int chunkCnt = 0;
public int chunkLoadNotCompleted = 0;
/// <summary>
/// Read, set or unload the specified chunk column
/// </summary>
@ -78,6 +89,26 @@ namespace MinecraftClient.Mapping
}
}
/// <summary>
/// Set dimension type
/// </summary>
/// <param name="name"> The name of the dimension type</param>
/// <param name="nbt">The dimension type (NBT Tag Compound)</param>
public static void SetDimension(string name, Dictionary<string, object> nbt)
{
// will change in 1.19 and above
dimension = new Dimension(name, nbt);
}
/// <summary>
/// Get current dimension
/// </summary>
/// <returns>Current dimension</returns>
public static Dimension GetDimension()
{
return dimension;
}
/// <summary>
/// Get chunk column at the specified location
/// </summary>