├── TrueCraft ├── Logic │ └── Discover.cs ├── World │ ├── INoise.cs │ ├── IDecoration.cs │ ├── IChunkProvider.cs │ ├── IChunkDecorator.cs │ ├── IDimensionFactory.cs │ └── IBiomeMap.cs ├── Inventory │ ├── IChestWindow.cs │ ├── IServerSlots.cs │ └── SlotFactory.cs ├── Commands │ ├── ICommandManager.cs │ ├── ICommand.cs │ ├── Command.cs │ └── PingCommand.cs ├── Exceptions │ └── PlayerDisconnectException.cs ├── IServerServiceLocator.cs ├── TerrainGen │ ├── Noise │ │ ├── InvertNoise.cs │ │ └── ScaleNoise.cs │ ├── EmptyGenerator.cs │ ├── Biomes │ │ ├── PlainsBiome.cs │ │ ├── ForestBiome.cs │ │ ├── SeasonalForestBiome.cs │ │ ├── TaigaBiome.cs │ │ ├── ShrublandBiome.cs │ │ ├── SwamplandBiome.cs │ │ ├── SavannaBiome.cs │ │ └── RainforestBiome.cs │ └── Generator.cs ├── Rules │ └── OverworldSpawnRules.cs ├── AccessConfiguration.cs └── Properties │ └── AssemblyInfo.cs ├── TrueCraft.Client ├── Content │ ├── pack.txt │ ├── default-pack.txt │ ├── gui.png │ ├── moon.png │ ├── pack.png │ ├── sun.png │ ├── icons.png │ ├── items.png │ ├── crafting.png │ ├── furnace.png │ ├── inventory.png │ ├── terrain.png │ ├── generic_27.png │ ├── generic_54.png │ ├── default-pack.png │ ├── Audio │ │ ├── default_hurt.wav │ │ ├── default_dig_choppy.ogg │ │ ├── default_dig_cracky.ogg │ │ ├── default_dug_node.1.ogg │ │ ├── default_dug_node.2.ogg │ │ ├── default_cool_lava.1.ogg │ │ ├── default_cool_lava.2.ogg │ │ ├── default_cool_lava.3.ogg │ │ ├── default_dig_crumbly.ogg │ │ ├── default_place_node.1.ogg │ │ ├── default_place_node.2.ogg │ │ ├── default_place_node.3.ogg │ │ ├── default_break_glass.1.ogg │ │ ├── default_break_glass.2.ogg │ │ ├── default_break_glass.3.ogg │ │ ├── default_dirt_footstep.1.ogg │ │ ├── default_dirt_footstep.2.ogg │ │ ├── default_glass_footstep.ogg │ │ ├── default_hard_footstep.1.ogg │ │ ├── default_hard_footstep.2.ogg │ │ ├── default_hard_footstep.3.ogg │ │ ├── default_sand_footstep.1.ogg │ │ ├── default_sand_footstep.2.ogg │ │ ├── default_snow_footstep.1.ogg │ │ ├── default_snow_footstep.2.ogg │ │ ├── default_snow_footstep.3.ogg │ │ ├── default_wood_footstep.1.ogg │ │ ├── default_wood_footstep.2.ogg │ │ ├── default_dig_dig_immediate.ogg │ │ ├── default_grass_footstep.1.ogg │ │ ├── default_grass_footstep.2.ogg │ │ ├── default_grass_footstep.3.ogg │ │ ├── default_gravel_footstep.1.ogg │ │ ├── default_gravel_footstep.2.ogg │ │ ├── default_gravel_footstep.3.ogg │ │ ├── default_gravel_footstep.4.ogg │ │ ├── default_place_node_hard.1.ogg │ │ ├── default_place_node_hard.2.ogg │ │ ├── default_dig_oddly_breakable_by_hand.ogg │ │ └── credits.txt │ └── Fonts │ │ ├── DejaVu_Bold_0.png │ │ ├── Pixel_Bold_0.png │ │ ├── DejaVu_Italic_0.png │ │ ├── Pixel_Italic_0.png │ │ ├── Pixel_Italic_1.png │ │ ├── Pixel_Regular_0.png │ │ ├── DejaVu_Regular_0.png │ │ └── pixel-license.txt ├── Input │ ├── GamePadEventArgs.cs │ ├── GamePadButtonEventArgs.cs │ ├── KeyboardEventArgs.cs │ ├── MouseButton.cs │ ├── MouseEventArgs.cs │ └── KeyboardKeyEventArgs.cs ├── Modules │ ├── IHeldItem.cs │ ├── IGameplayModule.cs │ ├── IGraphicalModule.cs │ └── IInputModule.cs ├── Events │ ├── ChatMessageEventArgs.cs │ └── ChunkEventArgs.cs ├── Inventory │ ├── IClickHandler.cs │ ├── IFurnaceProgress.cs │ └── SlotFactory.cs ├── Modelling │ ├── Blocks │ │ ├── VisibleFaces.cs │ │ ├── CobwebModeller.cs │ │ └── SugarcaneModeller.cs │ └── ModellerEventArgs.cs ├── World │ └── IDimensionClient.cs ├── Handlers │ ├── ActionList.cs │ └── ActionConfirmation.cs ├── Rendering │ └── FontStyle.cs └── Properties │ └── AssemblyInfo.cs ├── TrueCraft.Launcher ├── Content │ ├── default-pack.txt │ ├── Xwt.WPF.dll │ ├── default-pack.png │ ├── truecraft-logo.png │ ├── truecraft_logo.png │ └── default-server-icon.png ├── truecraft ├── Singleplayer │ └── WorldInfo.cs └── Properties │ └── AssemblyInfo.cs ├── lib ├── osx-x64 │ ├── SDL2.dll │ ├── libopenal32.dll │ ├── README.sources.txt │ └── SDL2.dll.LICENSE └── Ionic.Zip.Reduced.dll ├── Test ├── TrueCraft.Test │ ├── Files │ │ ├── manifest.nbt │ │ ├── TestChunk.nbt │ │ └── region │ │ │ ├── r.-1.0.mcr │ │ │ ├── r.0.-1.mcr │ │ │ ├── r.0.0.mcr │ │ │ └── r.-1.-1.mcr │ └── World │ │ └── RegionTest.cs └── TrueCraft.Core.Test │ └── Utility.cs ├── TrueCraft.Core ├── Assets │ └── TrueCraft.xml.gz ├── Logic │ ├── IRegisterRecipe.cs │ ├── ICraftingRepository.cs │ ├── Items │ │ ├── AxeItem.cs │ │ ├── SwordItem.cs │ │ ├── PickaxeItem.cs │ │ ├── ShovelItem.cs │ │ ├── IFoodItem.cs │ │ ├── IDurableItem.cs │ │ ├── ArrowItem.cs │ │ ├── MusicDiscItem.cs │ │ ├── RedstoneRepeaterItem.cs │ │ ├── BowItem.cs │ │ ├── BoatItem.cs │ │ ├── ArmorKind.cs │ │ ├── ClockItem.cs │ │ ├── MapItem.cs │ │ ├── SnowballItem.cs │ │ ├── ClayItem.cs │ │ ├── CompassItem.cs │ │ ├── PaintingItem.cs │ │ ├── SaddleItem.cs │ │ ├── StringItem.cs │ │ ├── EggItem.cs │ │ ├── StickItem.cs │ │ ├── ShearsItem.cs │ │ ├── CoalItem.cs │ │ ├── FishingRodItem.cs │ │ ├── IArmorItem.cs │ │ ├── IToolItem.cs │ │ ├── MinecartItem.cs │ │ ├── HoeItem.cs │ │ ├── SeedsItem.cs │ │ ├── SignItem.cs │ │ ├── CakeItem.cs │ │ └── RedstoneItem.cs │ ├── ICraftingRecipe.cs │ ├── SoundEffectClass.cs │ ├── IRegisterItemProvider.cs │ ├── IBurnableItem.cs │ ├── ISmeltableItem.cs │ ├── BlockDescriptor.cs │ ├── IRegisterBlockProvider.cs │ ├── IItemRepository.cs │ ├── IBlockRepository.cs │ ├── ToolType.cs │ ├── Blocks │ │ ├── ButtonBlock.cs │ │ ├── BedrockBlock.cs │ │ ├── BricksBlock.cs │ │ ├── MossStoneBlock.cs │ │ ├── NetherrackBlock.cs │ │ ├── SandstoneBlock.cs │ │ ├── CobblestoneBlock.cs │ │ ├── JukeboxBlock.cs │ │ ├── NoteBlockBlock.cs │ │ ├── TNTBlock.cs │ │ ├── DirtBlock.cs │ │ ├── SpongeBlock.cs │ │ ├── SoulSandBlock.cs │ │ ├── MonsterSpawnerBlock.cs │ │ ├── LeverBlock.cs │ │ ├── PortalBlock.cs │ │ ├── WoolBlock.cs │ │ ├── DispenserBlock.cs │ │ ├── BookshelfBlock.cs │ │ ├── LockedChestBlock.cs │ │ ├── WoodenPlanksBlock.cs │ │ └── ObsidianBlock.cs │ ├── IDiscover.cs │ ├── OreTypes.cs │ ├── Metadata │ │ ├── MetadataByte.cs │ │ ├── MetadataInt.cs │ │ ├── MetadataFloat.cs │ │ └── MetadataShort.cs │ ├── BlockFace.cs │ ├── PlantSpecies.cs │ └── ArmorMaterial.cs ├── Strings.cs ├── Logging │ ├── ILogProvider.cs │ ├── FileLogProvider.cs │ ├── LogCategory.cs │ └── PacketLogging.cs ├── AI │ ├── IMobState.cs │ ├── ISpawnRule.cs │ ├── IdleState.cs │ └── PriorityQueue.cs ├── Networking │ ├── IPacket.cs │ ├── IPacketSegmentProcessor.cs │ ├── Packets │ │ ├── UselessEntityPacket.cs │ │ ├── DestroyEntityPacket.cs │ │ ├── PlayerGroundedPacket.cs │ │ ├── KeepAlivePacket.cs │ │ ├── HandshakePacket.cs │ │ ├── UpdateHealthPacket.cs │ │ ├── UpdateStatisticPacket.cs │ │ ├── DisconnectPacket.cs │ │ ├── AttachEntityPacket.cs │ │ ├── CloseWindowPacket.cs │ │ ├── RespawnPacket.cs │ │ ├── PlayerActionPacket.cs │ │ ├── EntityLookPacket.cs │ │ ├── EntityRelativeMovePacket.cs │ │ ├── PlayerLookPacket.cs │ │ ├── TimeUpdatePacket.cs │ │ ├── EnvironmentStatePacket.cs │ │ ├── UseEntityPacket.cs │ │ ├── EntityMetadataPacket.cs │ │ ├── MapDataPacket.cs │ │ ├── ChangeHeldItemPacket.cs │ │ ├── ChatMessagePacket.cs │ │ ├── LightningPacket.cs │ │ ├── HandshakeResponsePacket.cs │ │ ├── CollectItemPacket.cs │ │ ├── SpawnPositionPacket.cs │ │ ├── EntityStatusPacket.cs │ │ ├── EntityLookAndRelativeMovePacket.cs │ │ ├── ChunkPreamblePacket.cs │ │ ├── UseBedPacket.cs │ │ ├── EntityVelocityPacket.cs │ │ ├── AnimationPacket.cs │ │ └── LoginRequestPacket.cs │ └── IPacketReader.cs ├── Entities │ ├── EntityFlags.cs │ ├── EntityEventArgs.cs │ ├── IMobEntity.cs │ ├── PigEntity.cs │ ├── CowEntity.cs │ ├── HenEntity.cs │ ├── SquidEntity.cs │ ├── SheepEntity.cs │ ├── WolfEntity.cs │ ├── CreeperEntity.cs │ ├── ZombieEntity.cs │ ├── SkeletonEntity.cs │ ├── SpiderEntity.cs │ ├── ZombiePigmanEntity.cs │ ├── ObjectEntity.cs │ ├── GhastEntity.cs │ ├── GiantZombieEntity.cs │ └── FallingBlockEntity.cs ├── Server │ ├── IFurnaceSlots.cs │ ├── WindowIDs.cs │ ├── IEventSubject.cs │ ├── PlayerJoinedQuitEventArgs.cs │ ├── GameMode.cs │ ├── ServerOnly.cs │ ├── Difficulty.cs │ ├── ChatMessageEventArgs.cs │ ├── IAccessConfiguration.cs │ ├── IEntityManager.cs │ └── IEventScheduler.cs ├── Lighting │ └── ILighter.cs ├── World │ ├── ChunkLoadedEventArgs.cs │ ├── IBiomeRepository.cs │ ├── BlockChangeEventArgs.cs │ ├── IBiomeProvider.cs │ ├── DimensionID.cs │ └── WorldConstants.cs ├── TrueCraftUser.cs ├── Windows │ └── WindowType.cs ├── Inventory │ ├── WindowClosedEventArgs.cs │ ├── ICraftingBenchWindow.cs │ ├── IChestWindow.cs │ ├── ISlotFactory.cs │ ├── IFurnaceWindow.cs │ ├── IInventoryWindow.cs │ ├── ISlot.cs │ └── SlotFactory.cs ├── IServiceLocator.cs └── MissingProviderException.cs ├── .gitmodules ├── References └── References.txt ├── .gitignore ├── scripts ├── findicon └── templates │ └── Block.cs ├── .editorconfig ├── .travis.yml ├── Directory.Build.props ├── TrueCraft.Profiling ├── TrueCraft.Profiling.csproj └── Properties │ └── AssemblyInfo.cs └── LICENSE /TrueCraft/Logic/Discover.cs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /TrueCraft.Client/Content/pack.txt: -------------------------------------------------------------------------------- 1 | Vanilla TrueCraft! -------------------------------------------------------------------------------- /TrueCraft.Client/Content/default-pack.txt: -------------------------------------------------------------------------------- 1 | No description available. -------------------------------------------------------------------------------- /TrueCraft.Launcher/Content/default-pack.txt: -------------------------------------------------------------------------------- 1 | No description available. -------------------------------------------------------------------------------- /TrueCraft.Launcher/truecraft: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mono ./TrueCraft.Launcher.exe 3 | -------------------------------------------------------------------------------- /lib/osx-x64/SDL2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/lib/osx-x64/SDL2.dll -------------------------------------------------------------------------------- /lib/Ionic.Zip.Reduced.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/lib/Ionic.Zip.Reduced.dll -------------------------------------------------------------------------------- /lib/osx-x64/libopenal32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/lib/osx-x64/libopenal32.dll -------------------------------------------------------------------------------- /TrueCraft.Client/Content/gui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/gui.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/moon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/moon.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/pack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/pack.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/sun.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/icons.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/items.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/items.png -------------------------------------------------------------------------------- /Test/TrueCraft.Test/Files/manifest.nbt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/Test/TrueCraft.Test/Files/manifest.nbt -------------------------------------------------------------------------------- /TrueCraft.Client/Content/crafting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/crafting.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/furnace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/furnace.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/inventory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/inventory.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/terrain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/terrain.png -------------------------------------------------------------------------------- /TrueCraft.Core/Assets/TrueCraft.xml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Core/Assets/TrueCraft.xml.gz -------------------------------------------------------------------------------- /TrueCraft.Launcher/Content/Xwt.WPF.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Launcher/Content/Xwt.WPF.dll -------------------------------------------------------------------------------- /Test/TrueCraft.Test/Files/TestChunk.nbt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/Test/TrueCraft.Test/Files/TestChunk.nbt -------------------------------------------------------------------------------- /TrueCraft.Client/Content/generic_27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/generic_27.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/generic_54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/generic_54.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "externals/fNbt"] 2 | path = externals/fNbt 3 | url = https://github.com/mrj001/fNbt.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /Test/TrueCraft.Test/Files/region/r.-1.0.mcr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/Test/TrueCraft.Test/Files/region/r.-1.0.mcr -------------------------------------------------------------------------------- /Test/TrueCraft.Test/Files/region/r.0.-1.mcr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/Test/TrueCraft.Test/Files/region/r.0.-1.mcr -------------------------------------------------------------------------------- /Test/TrueCraft.Test/Files/region/r.0.0.mcr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/Test/TrueCraft.Test/Files/region/r.0.0.mcr -------------------------------------------------------------------------------- /TrueCraft.Client/Content/default-pack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/default-pack.png -------------------------------------------------------------------------------- /TrueCraft.Launcher/Content/default-pack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Launcher/Content/default-pack.png -------------------------------------------------------------------------------- /Test/TrueCraft.Test/Files/region/r.-1.-1.mcr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/Test/TrueCraft.Test/Files/region/r.-1.-1.mcr -------------------------------------------------------------------------------- /TrueCraft.Launcher/Content/truecraft-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Launcher/Content/truecraft-logo.png -------------------------------------------------------------------------------- /TrueCraft.Launcher/Content/truecraft_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Launcher/Content/truecraft_logo.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_hurt.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_hurt.wav -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Fonts/DejaVu_Bold_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Fonts/DejaVu_Bold_0.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Fonts/Pixel_Bold_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Fonts/Pixel_Bold_0.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Fonts/DejaVu_Italic_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Fonts/DejaVu_Italic_0.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Fonts/Pixel_Italic_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Fonts/Pixel_Italic_0.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Fonts/Pixel_Italic_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Fonts/Pixel_Italic_1.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Fonts/Pixel_Regular_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Fonts/Pixel_Regular_0.png -------------------------------------------------------------------------------- /TrueCraft.Launcher/Content/default-server-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Launcher/Content/default-server-icon.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_dig_choppy.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_dig_choppy.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_dig_cracky.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_dig_cracky.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_dug_node.1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_dug_node.1.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_dug_node.2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_dug_node.2.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Fonts/DejaVu_Regular_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Fonts/DejaVu_Regular_0.png -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_cool_lava.1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_cool_lava.1.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_cool_lava.2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_cool_lava.2.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_cool_lava.3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_cool_lava.3.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_dig_crumbly.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_dig_crumbly.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_place_node.1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_place_node.1.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_place_node.2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_place_node.2.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_place_node.3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_place_node.3.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_break_glass.1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_break_glass.1.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_break_glass.2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_break_glass.2.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_break_glass.3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_break_glass.3.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_dirt_footstep.1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_dirt_footstep.1.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_dirt_footstep.2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_dirt_footstep.2.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_glass_footstep.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_glass_footstep.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_hard_footstep.1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_hard_footstep.1.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_hard_footstep.2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_hard_footstep.2.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_hard_footstep.3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_hard_footstep.3.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_sand_footstep.1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_sand_footstep.1.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_sand_footstep.2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_sand_footstep.2.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_snow_footstep.1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_snow_footstep.1.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_snow_footstep.2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_snow_footstep.2.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_snow_footstep.3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_snow_footstep.3.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_wood_footstep.1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_wood_footstep.1.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_wood_footstep.2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_wood_footstep.2.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_dig_dig_immediate.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_dig_dig_immediate.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_grass_footstep.1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_grass_footstep.1.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_grass_footstep.2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_grass_footstep.2.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_grass_footstep.3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_grass_footstep.3.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_gravel_footstep.1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_gravel_footstep.1.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_gravel_footstep.2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_gravel_footstep.2.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_gravel_footstep.3.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_gravel_footstep.3.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_gravel_footstep.4.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_gravel_footstep.4.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_place_node_hard.1.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_place_node_hard.1.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_place_node_hard.2.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_place_node_hard.2.ogg -------------------------------------------------------------------------------- /TrueCraft.Client/Input/GamePadEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Client.Input 4 | { 5 | public class GamePadEventArgs : EventArgs 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/default_dig_oddly_breakable_by_hand.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrj001/TrueCraft/HEAD/TrueCraft.Client/Content/Audio/default_dig_oddly_breakable_by_hand.ogg -------------------------------------------------------------------------------- /References/References.txt: -------------------------------------------------------------------------------- 1 | A. An Efficient and Robust Ray-Box Intersection Algorithm, Amy Williams, et al, University of Utah 2 | https://web.archive.org/web/20130420103121/http://www.cs.utah.edu/~awilliam/box/ 3 | 4 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/IRegisterRecipe.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic 4 | { 5 | public interface IRegisterRecipe 6 | { 7 | void RegisterRecipe(ICraftingRecipe recipe); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/osx-x64/README.sources.txt: -------------------------------------------------------------------------------- 1 | Source code for various dependencies can be found in the following locations: 2 | 3 | OpenAL-Soft: 4 | https://github.com/kcat/openal-soft 5 | 6 | SDL2: 7 | https://github.com/libsdl-org/SDL.git 8 | 9 | -------------------------------------------------------------------------------- /TrueCraft.Client/Modules/IHeldItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core; 3 | 4 | namespace TrueCraft.Client.Modules 5 | { 6 | public interface IHeldItem 7 | { 8 | ItemStack HeldItem { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /TrueCraft.Core/Strings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace TrueCraft.Core 3 | { 4 | public static class Strings 5 | { 6 | public const string SERVER_CODE_ON_CLIENT = "Server-side only code detected executing on client"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /TrueCraft.Client/Modules/IGameplayModule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework; 3 | 4 | namespace TrueCraft.Client.Modules 5 | { 6 | public interface IGameplayModule 7 | { 8 | void Update(GameTime gameTime); 9 | } 10 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logging/ILogProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logging 4 | { 5 | public interface ILogProvider 6 | { 7 | void Log(LogCategory category, string text, params object[] parameters); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Fonts/pixel-license.txt: -------------------------------------------------------------------------------- 1 | The FontStruction “Pixel UniCode” 2 | (http://fontstruct.com/fontstructions/show/908795) by “ivancr72” is licensed 3 | under a Creative Commons Attribution license 4 | (http://creativecommons.org/licenses/by/3.0/). 5 | -------------------------------------------------------------------------------- /TrueCraft.Client/Modules/IGraphicalModule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework; 3 | 4 | namespace TrueCraft.Client.Modules 5 | { 6 | public interface IGraphicalModule : IGameplayModule 7 | { 8 | void Draw(GameTime gameTime); 9 | } 10 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/ICraftingRepository.cs: -------------------------------------------------------------------------------- 1 | using TrueCraft.Core.Inventory; 2 | 3 | 4 | namespace TrueCraft.Core.Logic 5 | { 6 | public interface ICraftingRepository 7 | { 8 | ICraftingRecipe? GetRecipe(CraftingPattern craftingArea); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/AxeItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class AxeItem : ToolItem 7 | { 8 | public AxeItem(XmlNode node) : base(node) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/SwordItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class SwordItem : ToolItem 7 | { 8 | public SwordItem(XmlNode node) : base(node) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /TrueCraft.Client/Input/GamePadButtonEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework.Input; 3 | 4 | namespace TrueCraft.Client.Input 5 | { 6 | public class GamePadButtonEventArgs : GamePadEventArgs 7 | { 8 | public Buttons Button { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /TrueCraft.Client/Input/KeyboardEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Client.Input 4 | { 5 | /// 6 | /// Provides the event data for keyboard events. 7 | /// 8 | public class KeyboardEventArgs : EventArgs 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /TrueCraft.Core/AI/IMobState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.Entities; 4 | 5 | namespace TrueCraft.Core.AI 6 | { 7 | public interface IMobState 8 | { 9 | void Update(IMobEntity entity, IEntityManager manager); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/PickaxeItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class PickaxeItem : ToolItem 7 | { 8 | public PickaxeItem(XmlNode node) : base(node) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/ShovelItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class ShovelItem : ToolItem 7 | { 8 | public ShovelItem(XmlNode node) : base(node) 9 | { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | obj/ 3 | *.user 4 | *.userprefs 5 | *.suo 6 | *.pidb 7 | *.swp 8 | _ReSharper*/ 9 | TestResults/ 10 | *.mdf 11 | *.psess 12 | *.vsp 13 | packages/ 14 | .vs/ 15 | 16 | config.yaml 17 | 18 | packets.log 19 | 20 | world/manifest.nbt 21 | TestResult.xml 22 | 23 | References/*.pdf 24 | -------------------------------------------------------------------------------- /TrueCraft.Client/Content/Audio/credits.txt: -------------------------------------------------------------------------------- 1 | The footstep and mining/placement sound effects were sourced from Minetest under CC-BY-SA: https://github.com/minetest/minetest_game 2 | default_hurt.wav is the same sound effect Minecraft uses, which is CC-BY-SA from http://freesound.org/people/thecheeseman/sounds/44429/ -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/IFoodItem.cs: -------------------------------------------------------------------------------- 1 | namespace TrueCraft.Core.Logic.Items 2 | { 3 | public interface IFoodItem : IItemProvider 4 | { 5 | /// 6 | /// The amount of health this food restores. 7 | /// 8 | float Restores { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/IPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking 4 | { 5 | public interface IPacket 6 | { 7 | byte ID { get; } 8 | void ReadPacket(IMinecraftStream stream); 9 | void WritePacket(IMinecraftStream stream); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/EntityFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Entities 4 | { 5 | [Flags] 6 | public enum EntityFlags 7 | { 8 | Fire = 0x01, 9 | Crouched = 0x02, 10 | Riding = 0x04, 11 | Sprinting = 0x08, 12 | Eating = 0x10, 13 | } 14 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/ICraftingRecipe.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core; 3 | 4 | namespace TrueCraft.Core.Logic 5 | { 6 | public interface ICraftingRecipe : IEquatable 7 | { 8 | CraftingPattern Pattern { get; } 9 | 10 | ItemStack Output { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/IDurableItem.cs: -------------------------------------------------------------------------------- 1 | namespace TrueCraft.Core.Logic.Items 2 | { 3 | public interface IDurableItem : IItemProvider 4 | { 5 | /// 6 | /// Gets the Durability of the Durable Item when newly crafted. 7 | /// 8 | short Durability { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /TrueCraft/World/INoise.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace TrueCraft.World 7 | { 8 | public interface INoise 9 | { 10 | double Value2D(double x, double y); 11 | double Value3D(double x, double y, double z); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/SoundEffectClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic 4 | { 5 | public enum SoundEffectClass 6 | { 7 | None, 8 | Cloth, 9 | Grass, 10 | Gravel, 11 | Sand, 12 | Snow, 13 | Stone, 14 | Wood, 15 | Glass 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /TrueCraft.Core/Server/IFurnaceSlots.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Inventory; 3 | 4 | namespace TrueCraft.Core.Server 5 | { 6 | public interface IFurnaceSlots 7 | { 8 | IServerSlot IngredientSlot { get; } 9 | IServerSlot FuelSlot { get; } 10 | IServerSlot OutputSlot { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /TrueCraft.Core/Lighting/ILighter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Lighting 4 | { 5 | public interface ILighter 6 | { 7 | /// 8 | /// 9 | /// 10 | /// 11 | void DoLightingOperation(LightingOperation operation); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/EntityEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Entities 4 | { 5 | public class EntityEventArgs : EventArgs 6 | { 7 | public IEntity Entity { get; set; } 8 | 9 | public EntityEventArgs(IEntity entity) 10 | { 11 | Entity = entity; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/ArrowItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class ArrowItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x106; 9 | 10 | public ArrowItem(XmlNode node) : base(node) 11 | { 12 | 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /TrueCraft.Core/World/ChunkLoadedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.World 4 | { 5 | public class ChunkLoadedEventArgs : EventArgs 6 | { 7 | public IChunk Chunk { get; } 8 | 9 | public ChunkLoadedEventArgs(IChunk chunk) 10 | { 11 | Chunk = chunk; 12 | } 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/MusicDiscItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class MusicDiscItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x8D1; 9 | 10 | public MusicDiscItem(XmlNode node) : base(node) 11 | { 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/IPacketSegmentProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace TrueCraft.Core.Networking 5 | { 6 | public interface IPacketSegmentProcessor 7 | { 8 | bool ProcessNextSegment(byte[] nextSegment, int offset, int len, [MaybeNullWhen(false)] out IPacket packet); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /TrueCraft.Client/Events/ChatMessageEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Client.Events 4 | { 5 | public class ChatMessageEventArgs : EventArgs 6 | { 7 | public string Message { get; set; } 8 | 9 | public ChatMessageEventArgs(string message) 10 | { 11 | Message = message; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /TrueCraft.Client/Events/ChunkEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.World; 3 | 4 | namespace TrueCraft.Client.Events 5 | { 6 | public class ChunkEventArgs : EventArgs 7 | { 8 | public IChunk Chunk { get; } 9 | 10 | public ChunkEventArgs(IChunk chunk) 11 | { 12 | Chunk = chunk; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /TrueCraft.Client/Inventory/IClickHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Client.Handlers; 3 | using TrueCraft.Client.Modules; 4 | 5 | namespace TrueCraft.Client.Inventory 6 | { 7 | public interface IClickHandler 8 | { 9 | ActionConfirmation? HandleClick(int slotIndex, bool rightClick, bool shiftClick, IHeldItem heldItem); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/IRegisterItemProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic 4 | { 5 | public interface IRegisterItemProvider 6 | { 7 | /// 8 | /// 9 | /// 10 | /// 11 | void RegisterItemProvider(IItemProvider itemProvider); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /scripts/findicon: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | icon=$(cat icons.json | jq ".[] | select(.id==$(printf "%d" $1)) | .icon") 3 | x=$(printf "%s" $icon | jq ".x") 4 | y=$(printf "%s" $icon | jq ".y") 5 | 6 | cat < GetIconTexture(byte metadata) 9 | { 10 | return new Tuple($x, $y); 11 | } 12 | EOF 13 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/RedstoneRepeaterItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class RedstoneRepeaterItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x164; 9 | 10 | public RedstoneRepeaterItem(XmlNode node) : base(node) 11 | { 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/BowItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class BowItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x105; 9 | 10 | public BowItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | // TODO: add behaviour (Server-side) 15 | } 16 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Server/WindowIDs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Server 4 | { 5 | // TODO: refactor to server-side only 6 | public static class WindowIDs 7 | { 8 | private static sbyte _curID = 0; 9 | 10 | public static sbyte GetWindowID() 11 | { 12 | _curID++; 13 | return _curID; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/BoatItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class BoatItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x14D; 9 | 10 | public BoatItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | // TODO: Add Behaviour (server-side) 15 | } 16 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/ArmorKind.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace TrueCraft.Core.Logic.Items 3 | { 4 | /// 5 | /// Defines the different kinds of Armor - Helmet, Chestplate, Leggings and Boots. 6 | /// 7 | public enum ArmorKind 8 | { 9 | Helmet = 0, 10 | Chestplate = 1, 11 | Leggings = 2, 12 | Boots = 3 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /TrueCraft.Core/Server/IEventSubject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core 4 | { 5 | /// 6 | /// The subject of an event. When it's disposed, it raises an event and the associated 7 | /// scheduled events are discarded. 8 | /// 9 | public interface IEventSubject : IDisposable 10 | { 11 | event EventHandler Disposed; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /TrueCraft/World/IDecoration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.World; 3 | 4 | namespace TrueCraft.World 5 | { 6 | // TODO: this interface should be moved to server-side only 7 | public interface IDecoration 8 | { 9 | bool ValidLocation(LocalVoxelCoordinates location); 10 | bool GenerateAt(int seed, IChunk chunk, LocalVoxelCoordinates location); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/ClockItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class ClockItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x15B; 9 | 10 | public ClockItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | // TODO: Requires custom client-side drawing. 15 | } 16 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/MapItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class MapItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x166; 9 | 10 | public MapItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | // TODO: This will need (server-side) behaviour 15 | } 16 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root=true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | indent_style = space 7 | charset = utf-8 8 | trim-trailing-whitespace = true 9 | 10 | [*.cs] 11 | indent_size = 4 12 | tab_width = 4 13 | csharp_new_line_before_open_brace = all 14 | csharp_indent_block_contents = true 15 | csharp_indent_braces = false 16 | 17 | [*.xml] 18 | indent_size = 2 19 | tab_width = 2 20 | 21 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/SnowballItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class SnowballItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x14C; 9 | 10 | public SnowballItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | // TODO: Has behavior (can be thrown) 15 | } 16 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/ClayItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class ClayItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x151; 9 | 10 | public ClayItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | // TODO: Check if this should be smeltable into a brick. 15 | } 16 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/CompassItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class CompassItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x159; 9 | 10 | public CompassItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | // TODO: requires custom client-side drawning. 15 | } 16 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/PaintingItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class PaintingItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x141; 9 | 10 | public PaintingItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | // TODO: will require (server-side) behaviour 15 | } 16 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/SaddleItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class SaddleItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x149; 9 | 10 | public SaddleItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | // TODO: requires (server-side) ItemUsedOnEntity. 15 | } 16 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/StringItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class StringItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x11F; 9 | 10 | public StringItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | // TODO: check if string can be placed in Beta 1.7.3 15 | } 16 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Server/PlayerJoinedQuitEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Networking; 3 | 4 | namespace TrueCraft.Core.Server 5 | { 6 | public class PlayerJoinedQuitEventArgs : EventArgs 7 | { 8 | public IRemoteClient Client { get; set; } 9 | 10 | public PlayerJoinedQuitEventArgs(IRemoteClient client) 11 | { 12 | Client = client; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /TrueCraft.Client/Modelling/Blocks/VisibleFaces.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Client.Modelling.Blocks 4 | { 5 | [Flags] 6 | public enum VisibleFaces 7 | { 8 | None = 0, 9 | North = 1, 10 | South = 2, 11 | East = 4, 12 | West = 8, 13 | Top = 16, 14 | Bottom = 32, 15 | All = North | South | East | West | Top | Bottom 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/EggItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class EggItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x158; 9 | 10 | public EggItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | // TODO: (server-side) Eggs have behaviour (be thrown, possible hatch...) 15 | } 16 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/IBurnableItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic 4 | { 5 | /// 6 | /// Describes an item that can be burnt as fuel in a furnace. 7 | /// 8 | public interface IBurnableItem 9 | { 10 | /// 11 | /// The duration of time this item can act as fuel. 12 | /// 13 | TimeSpan BurnTime { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /TrueCraft/Inventory/IChestWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Inventory 6 | { 7 | public interface IChestWindow : TrueCraft.Core.Inventory.IChestWindow 8 | { 9 | IDimension Dimension { get; } 10 | 11 | GlobalVoxelCoordinates Location { get; } 12 | 13 | GlobalVoxelCoordinates? OtherHalf { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/StickItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class StickItem : ItemProvider, IBurnableItem 7 | { 8 | public static readonly short ItemID = 0x118; 9 | 10 | public StickItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | public TimeSpan BurnTime { get { return TimeSpan.FromSeconds(5); } } 15 | } 16 | } -------------------------------------------------------------------------------- /TrueCraft.Client/World/IDimensionClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.World; 3 | 4 | namespace TrueCraft.Client.World 5 | { 6 | public interface IDimensionClient : IDimension 7 | { 8 | /// 9 | /// Adds the given Chunk to the client's current Dimension. 10 | /// 11 | /// The Chunk to add. 12 | void AddChunk(IChunk chunk); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/ISmeltableItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic 4 | { 5 | /// 6 | /// Describes an item that can be smelted in a furnace to produce a new item. 7 | /// 8 | public interface ISmeltableItem 9 | { 10 | /// 11 | /// The item this becomes when smelted. 12 | /// 13 | ItemStack SmeltingOutput { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /TrueCraft.Core/World/IBiomeRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace TrueCraft.Core.World 7 | { 8 | public interface IBiomeRepository 9 | { 10 | IBiomeProvider GetBiome(Biome id); 11 | IBiomeProvider GetBiome(double temperature, double rainfall, bool spawn); 12 | void RegisterBiomeProvider(IBiomeProvider provider); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /TrueCraft/Commands/ICommandManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using TrueCraft.Core.Networking; 4 | 5 | namespace TrueCraft.Commands 6 | { 7 | public interface ICommandManager : IList 8 | { 9 | ICommand? FindByName(string name); 10 | 11 | ICommand? FindByAlias(string alias); 12 | 13 | void HandleCommand(IRemoteClient Client, string Alias, string[] Arguments); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/ShearsItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class ShearsItem : ItemProvider, IDurableItem 7 | { 8 | public static readonly short ItemID = 0x167; 9 | 10 | public ShearsItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | /// 15 | public short Durability { get { return 239; } } 16 | } 17 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/BlockDescriptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.World; 3 | 4 | namespace TrueCraft.Core.Logic 5 | { 6 | public struct BlockDescriptor 7 | { 8 | public byte ID; 9 | public byte Metadata; 10 | public byte BlockLight; 11 | public byte SkyLight; 12 | // Optional 13 | public GlobalVoxelCoordinates Coordinates; 14 | // Optional 15 | public IChunk Chunk; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /TrueCraft.Core/TrueCraftUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core 4 | { 5 | public class TrueCraftUser 6 | { 7 | public static string AuthServer = "https://truecraft.io"; 8 | 9 | public TrueCraftUser() 10 | { 11 | Username = string.Empty; 12 | SessionId = string.Empty; 13 | } 14 | 15 | public string Username { get; set; } 16 | public string SessionId { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /TrueCraft/World/IChunkProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.World; 3 | 4 | namespace TrueCraft.World 5 | { 6 | /// 7 | /// Provides new chunks to worlds. Generally speaking this is a terrain generator. 8 | /// 9 | public interface IChunkProvider 10 | { 11 | IChunk GenerateChunk(GlobalChunkCoordinates coordinates); 12 | 13 | GlobalVoxelCoordinates GetSpawn(IDimension dimension); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/IMobEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.AI; 3 | using TrueCraft.Core.Physics; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public interface IMobEntity : IEntity 8 | { 9 | event EventHandler PathComplete; 10 | PathResult? CurrentPath { get; set; } 11 | bool AdvancePath(TimeSpan time, bool faceRoute = true); 12 | IMobState? CurrentState { get; set; } 13 | void Face(Vector3 target); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /TrueCraft.Core/Server/GameMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core 4 | { 5 | /// 6 | /// Enumerates the different game modes in TrueCraft. 7 | /// 8 | public enum GameMode 9 | { 10 | /// 11 | /// The survival game mode. 12 | /// 13 | Survival = 0, 14 | 15 | /// 16 | /// The creative game mode. 17 | /// 18 | Creative = 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /TrueCraft.Client/Input/MouseButton.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Client.Input 4 | { 5 | /// 6 | /// 7 | /// 8 | public enum MouseButton 9 | { 10 | /// 11 | /// 12 | /// 13 | Left, 14 | 15 | /// 16 | /// 17 | /// 18 | Right, 19 | 20 | /// 21 | /// 22 | /// 23 | Middle 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /TrueCraft.Core/Server/ServerOnly.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace TrueCraft.Core.Server 5 | { 6 | public static class ServerOnly 7 | { 8 | /// 9 | /// 10 | /// 11 | [Conditional("DEBUG")] 12 | public static void Assert() 13 | { 14 | if (WhoAmI.Answer != IAm.Server) 15 | throw new ApplicationException(Strings.SERVER_CODE_ON_CLIENT); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /TrueCraft.Core/Windows/WindowType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Windows 4 | { 5 | /// 6 | /// An enum to specify types of child windows. 7 | /// 8 | /// These values are the ones used in the Type field of the OpenWindowPacket. 9 | public enum WindowType : sbyte 10 | { 11 | Inventory = -1, 12 | Chest = 0, 13 | CraftingBench = 1, 14 | Furnace = 2, 15 | Dispenser = 3 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | solution: TrueCraft.sln 3 | mono: 4 | - latest 5 | before_install: 6 | - git submodule update --init --recursive 7 | install: 8 | - nuget restore TrueCraft.sln 9 | - nuget install NUnit.Runners -Version 3.2.1 -OutputDirectory testrunner 10 | script: 11 | - xbuild TrueCraft.sln 12 | - | 13 | mono \ 14 | ./testrunner/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe \ 15 | ./TrueCraft.Core.Test/TrueCraft.Core.Test.csproj 16 | -------------------------------------------------------------------------------- /TrueCraft.Client/Modelling/Blocks/CobwebModeller.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework; 3 | using TrueCraft.Core.Logic.Blocks; 4 | 5 | namespace TrueCraft.Client.Modelling.Blocks 6 | { 7 | public class CobwebModeller : FlatQuadModeller 8 | { 9 | static CobwebModeller() 10 | { 11 | RegisterRenderer(CobwebBlock.BlockID, new CobwebModeller()); 12 | } 13 | 14 | protected override Vector2 TextureMap { get { return new Vector2(11, 0); } } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/IRegisterBlockProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic 4 | { 5 | public interface IRegisterBlockProvider 6 | { 7 | /// 8 | /// Registers a new block provider. This overrides any existing block providers that use the 9 | /// same block ID. 10 | /// 11 | /// The Block Provider to be registered 12 | void RegisterBlockProvider(IBlockProvider provider); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /TrueCraft.Client/Modelling/Blocks/SugarcaneModeller.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework; 3 | using TrueCraft.Core.Logic.Blocks; 4 | 5 | namespace TrueCraft.Client.Modelling.Blocks 6 | { 7 | public class SugarcaneModeller : FlatQuadModeller 8 | { 9 | static SugarcaneModeller() 10 | { 11 | RegisterRenderer(SugarcaneBlock.BlockID, new SugarcaneModeller()); 12 | } 13 | 14 | protected override Vector2 TextureMap { get { return new Vector2(9, 4); } } 15 | } 16 | } -------------------------------------------------------------------------------- /TrueCraft/Exceptions/PlayerDisconnectException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Exceptions 4 | { 5 | public class PlayerDisconnectException : Exception 6 | { 7 | /// 8 | /// True if the disconnection was the result of player actions. 9 | /// 10 | public bool PlayerInitiated { get; set; } 11 | 12 | public PlayerDisconnectException(bool playerInitiated) 13 | { 14 | PlayerInitiated = playerInitiated; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Inventory/WindowClosedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Inventory 4 | { 5 | public class WindowClosedEventArgs : EventArgs 6 | { 7 | private readonly sbyte _windowID; 8 | 9 | public WindowClosedEventArgs(sbyte windowID) 10 | { 11 | _windowID = windowID; 12 | } 13 | 14 | /// 15 | /// Gets the ID of the Window which was closed. 16 | /// 17 | public sbyte WindowID { get => _windowID; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/IItemRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic 4 | { 5 | /// 6 | /// Providers item providers for a server. 7 | /// 8 | public interface IItemRepository 9 | { 10 | /// 11 | /// Gets this repository's item provider for the specified item ID. This may return null 12 | /// if the item ID in question has no corresponding block provider. 13 | /// 14 | IItemProvider? GetItemProvider(short id); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/IBlockRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic 4 | { 5 | /// 6 | /// Providers block providers for a server. 7 | /// 8 | public interface IBlockRepository 9 | { 10 | /// 11 | /// Gets this repository's block provider for the specified block ID. This may return null 12 | /// if the block ID in question has no corresponding block provider. 13 | /// 14 | IBlockProvider GetBlockProvider(byte id); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/PigEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class PigEntity : MobEntity 8 | { 9 | public PigEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager, 10, new Size(0.9)) 11 | { 12 | } 13 | 14 | public override sbyte MobType 15 | { 16 | get 17 | { 18 | return 90; 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/CoalItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class CoalItem : ItemProvider, IBurnableItem 7 | { 8 | public enum MetaData : short 9 | { 10 | Coal = 0, 11 | Charcoal = 1 12 | } 13 | 14 | public static readonly short ItemID = 0x107; 15 | 16 | public CoalItem(XmlNode node) : base(node) 17 | { 18 | } 19 | 20 | public TimeSpan BurnTime { get { return TimeSpan.FromSeconds(80); } } 21 | } 22 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/UselessEntityPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | public struct UselessEntityPacket : IPacket 6 | { 7 | public byte ID { get { return 0x1E; } } 8 | 9 | public int EntityID; 10 | 11 | public void ReadPacket(IMinecraftStream stream) 12 | { 13 | EntityID = stream.ReadInt32(); 14 | } 15 | 16 | public void WritePacket(IMinecraftStream stream) 17 | { 18 | stream.WriteInt32(EntityID); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /TrueCraft/Commands/ICommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using TrueCraft.Core.Networking; 6 | using TrueCraft.Inventory; 7 | 8 | namespace TrueCraft.Commands 9 | { 10 | public interface ICommand 11 | { 12 | string Name { get; } 13 | string Description { get; } 14 | string[] Aliases { get; } 15 | void Handle(IRemoteClient client, string alias, string[] arguments); 16 | void Help(IRemoteClient client, string alias, string[] arguments); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/CowEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class CowEntity : MobEntity 8 | { 9 | public CowEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager, 10, new Size(0.9, 1.3, 0.9)) 11 | { 12 | } 13 | 14 | public override sbyte MobType 15 | { 16 | get 17 | { 18 | return 92; 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/HenEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class HenEntity : MobEntity 8 | { 9 | public HenEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager, 4, new Size(0.4, 0.3, 0.4)) 11 | { 12 | } 13 | 14 | public override sbyte MobType 15 | { 16 | get 17 | { 18 | return 93; 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/FishingRodItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class FishingRodItem : ItemProvider, IDurableItem 7 | { 8 | public static readonly short ItemID = 0x15A; 9 | 10 | public FishingRodItem(XmlNode node) : base(node) 11 | { 12 | } 13 | 14 | /// 15 | public short Durability { get { return 65; } } 16 | 17 | // TODO: requires server-side behavior 18 | // TODO: requires client-side rendering support. 19 | } 20 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Inventory/ICraftingBenchWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Inventory 4 | { 5 | public interface ICraftingBenchWindow : IWindow where T : ISlot 6 | { 7 | /// 8 | /// Gets the 3x3 Crafting Grid (plus output slot) of the Crafting Bench Window. 9 | /// 10 | ICraftingArea CraftingGrid { get; } 11 | 12 | /// 13 | /// Gets the Slot Index (within the Window) of the Output Slot. 14 | /// 15 | int CraftingOutputSlotIndex { get; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /TrueCraft.Client/Inventory/IFurnaceProgress.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Client.Inventory 4 | { 5 | public interface IFurnaceProgress 6 | { 7 | /// 8 | /// Gets or sets the progress of the current smelting operation 9 | /// 10 | int SmeltingProgress { get; set; } 11 | 12 | /// 13 | /// Gets or sets the height of the flame in the Furnace, which indicates 14 | /// the fraction of the original burn time remaining. 15 | /// 16 | int BurnProgress { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/SquidEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class SquidEntity : MobEntity 8 | { 9 | public SquidEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager, 10, new Size(0.95)) // TODO: Size seems wrong... 11 | { 12 | } 13 | 14 | public override sbyte MobType 15 | { 16 | get 17 | { 18 | return 94; 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/IPacketReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Collections.Generic; 4 | 5 | namespace TrueCraft.Core.Networking 6 | { 7 | public interface IPacketReader 8 | { 9 | int ProtocolVersion { get; } 10 | 11 | ConcurrentDictionary Processors { get; } 12 | void RegisterPacketType(bool clientbound = true, bool serverbound = true) where T : IPacket; 13 | IEnumerable ReadPackets(object key, byte[] buffer, int offset, int length, bool serverbound = true); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /TrueCraft/IServerServiceLocator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.World; 4 | 5 | namespace TrueCraft 6 | { 7 | public interface IServerServiceLocator : IServiceLocator 8 | { 9 | /// 10 | /// Gets or sets the World of this Server. 11 | /// 12 | /// 13 | /// The World may only be set once. 14 | /// 15 | IWorld World { get; set; } 16 | 17 | /// 18 | /// 19 | /// 20 | IMultiplayerServer Server { get; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /TrueCraft/World/IChunkDecorator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using TrueCraft.Core.Logic; 6 | using TrueCraft.Core.World; 7 | 8 | namespace TrueCraft.World 9 | { 10 | // TODO: this interface should be server-side only. 11 | /// 12 | /// Used to decorate chunks with "decorations" such as trees, flowers, ores, etc. 13 | /// 14 | public interface IChunkDecorator 15 | { 16 | void Decorate(int seed, IChunk chunk, IBlockRepository blockRepository, IBiomeRepository biomes); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | true 5 | true 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/SheepEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class SheepEntity : MobEntity 8 | { 9 | public SheepEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager, 8, new Size(0.9, 1.3, 0.9)) // TODO: sheep is taller than long? 11 | { 12 | } 13 | 14 | public override sbyte MobType 15 | { 16 | get 17 | { 18 | return 91; 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /TrueCraft.Core/IServiceLocator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Logic; 3 | 4 | namespace TrueCraft 5 | { 6 | public interface IServiceLocator 7 | { 8 | /// 9 | /// Gets the Block Repository. 10 | /// 11 | IBlockRepository BlockRepository { get; } 12 | 13 | /// 14 | /// Gets the Item Repository. 15 | /// 16 | IItemRepository ItemRepository { get; } 17 | 18 | /// 19 | /// Gets the Crafting Repository 20 | /// 21 | ICraftingRepository CraftingRepository { get; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /TrueCraft.Core/World/BlockChangeEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Logic; 3 | 4 | namespace TrueCraft.Core.World 5 | { 6 | public class BlockChangeEventArgs : EventArgs 7 | { 8 | public BlockChangeEventArgs(GlobalVoxelCoordinates position, BlockDescriptor oldBlock, BlockDescriptor newBlock) 9 | { 10 | Position = position; 11 | OldBlock = oldBlock; 12 | NewBlock = newBlock; 13 | } 14 | 15 | public GlobalVoxelCoordinates Position { get; } 16 | public BlockDescriptor OldBlock { get; } 17 | public BlockDescriptor NewBlock { get; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/ToolType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core 4 | { 5 | /// 6 | /// Specifies the type of the Tool. 7 | /// 8 | /// 9 | /// 10 | /// Note; values in this enum must correspond to values in the 11 | /// toolKindType in the TrueCraft.xsd file. 12 | /// 13 | /// 14 | [Flags] 15 | public enum ToolType 16 | { 17 | None = 1, 18 | Pickaxe = 2, 19 | Axe = 4, 20 | Shovel = 8, 21 | Hoe = 16, 22 | Sword = 32, 23 | All = None | Pickaxe | Axe | Shovel | Hoe | Sword 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/WolfEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class WolfEntity : MobEntity 8 | { 9 | public WolfEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager, 10, 11 | new Size(0.6, 1.8, 0.6)) // TODO: Fix Size: A Wolf is not the same size as a Player 12 | { 13 | } 14 | 15 | public override sbyte MobType 16 | { 17 | get 18 | { 19 | return 95; 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /TrueCraft/TerrainGen/Noise/InvertNoise.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.World; 3 | 4 | namespace TrueCraft.TerrainGen.Noise 5 | { 6 | public class InvertNoise : NoiseGen 7 | { 8 | public INoise Noise { get; set; } 9 | public InvertNoise(INoise Noise) 10 | { 11 | this.Noise = Noise; 12 | } 13 | 14 | public override double Value2D(double X, double Y) 15 | { 16 | return -Noise.Value2D(X, Y); 17 | } 18 | 19 | public override double Value3D(double X, double Y, double Z) 20 | { 21 | return -Noise.Value3D(X, Y, Z); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/IArmorItem.cs: -------------------------------------------------------------------------------- 1 | namespace TrueCraft.Core.Logic.Items 2 | { 3 | public interface IArmorItem : IDurableItem 4 | { 5 | /// 6 | /// Gets the Kind of Armor represented by this ArmorItem. 7 | /// 8 | ArmorKind Kind { get; } 9 | 10 | /// 11 | /// Gets the Material from which the ArmorItem is made. 12 | /// 13 | ArmorMaterial Material { get; } 14 | 15 | /// 16 | /// Gets the number of Defence Points of protection provided by the ArmorItem. 17 | /// 18 | float DefencePoints { get; } 19 | } 20 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/IToolItem.cs: -------------------------------------------------------------------------------- 1 | namespace TrueCraft.Core.Logic.Items 2 | { 3 | public interface IToolItem : IDurableItem 4 | { 5 | /// 6 | /// Gets the ToolMaterial of the ToolItem. 7 | /// 8 | ToolMaterial Material { get; } 9 | 10 | /// 11 | /// Gets the type of the ToolItem. 12 | /// 13 | ToolType ToolType { get; } 14 | 15 | /// 16 | /// Gets the amount of additional damage dealt to mobs when they are 17 | /// attacked while the ToolItem is being held by the Player. 18 | /// 19 | float Damage { get; } 20 | } 21 | } -------------------------------------------------------------------------------- /TrueCraft/TerrainGen/EmptyGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using TrueCraft.Core.World; 4 | using TrueCraft.World; 5 | 6 | namespace TrueCraft.TerrainGen 7 | { 8 | public class EmptyGenerator : Generator 9 | { 10 | public EmptyGenerator(int seed) : base(seed) 11 | { 12 | 13 | } 14 | 15 | public override IChunk GenerateChunk(GlobalChunkCoordinates coordinates) 16 | { 17 | return new Chunk(coordinates); 18 | } 19 | 20 | public override GlobalVoxelCoordinates GetSpawn(IDimension dimension) 21 | { 22 | return GlobalVoxelCoordinates.Zero; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/DestroyEntityPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | public struct DestroyEntityPacket : IPacket 6 | { 7 | public byte ID { get { return 0x1D; } } 8 | 9 | public int EntityID; 10 | 11 | public DestroyEntityPacket(int entityID) 12 | { 13 | EntityID = entityID; 14 | } 15 | 16 | public void ReadPacket(IMinecraftStream stream) 17 | { 18 | EntityID = stream.ReadInt32(); 19 | } 20 | 21 | public void WritePacket(IMinecraftStream stream) 22 | { 23 | stream.WriteInt32(EntityID); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Server/Difficulty.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core 4 | { 5 | /// 6 | /// Enumerates the difficulty levels in TrueCraft. 7 | /// 8 | public enum Difficulty 9 | { 10 | /// 11 | /// Peaceful difficulty. 12 | /// 13 | Peaceful = 0, 14 | 15 | /// 16 | /// Easy difficulty. 17 | /// 18 | Easy = 1, 19 | 20 | /// 21 | /// Normal difficulty. 22 | /// 23 | Normal = 2, 24 | 25 | /// 26 | /// Hard difficulty. 27 | /// 28 | Hard = 3 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /TrueCraft.Core/MissingProviderException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core 4 | { 5 | /// 6 | /// Throw an Exception of this Type if a provider class could not be found 7 | /// 8 | public class MissingProviderException : ApplicationException 9 | { 10 | /// 11 | /// Constructs the MissingProviderException 12 | /// 13 | /// The fully qualified name of the missing provider class. 14 | public MissingProviderException(string missingTypeName) : 15 | base($"The provider of type \"{missingTypeName}\" could not be found.") 16 | { 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /scripts/templates/Block.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.API.Logic; 3 | 4 | namespace TrueCraft.Core.Logic.Blocks 5 | { 6 | public class {{ csname }}Block : BlockProvider 7 | { 8 | public static readonly byte BlockID = {{ id }}; 9 | 10 | public override byte ID { get { return {{ id }}; } } 11 | 12 | public override double Hardness { get { return {{ hardness }}; } } 13 | 14 | public override string DisplayName { get { return "{{ display_name }}"; } }{% if tex_x %} 15 | 16 | public override Tuple GetTextureMap(byte metadata) 17 | { 18 | return new Tuple({{ tex_x }}, {{ tex_y }}); 19 | }{% endif %} 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /TrueCraft.Core/Inventory/IChestWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Inventory 4 | { 5 | public interface IChestWindow : IWindow where T : ISlot 6 | { 7 | /// 8 | /// Gets the collection of slots containing the Chest's contents. 9 | /// 10 | ISlots ChestInventory { get; } 11 | 12 | /// 13 | /// Gets whether or not the Chest is a double Chest. 14 | /// 15 | bool DoubleChest { get; } 16 | 17 | /// 18 | /// Gets the Slot Index (within the Window) of the first Slot of the Chest Area. 19 | /// 20 | int ChestSlotIndex { get; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /TrueCraft/Commands/Command.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.Networking; 4 | 5 | namespace TrueCraft.Commands 6 | { 7 | public abstract class Command : ICommand 8 | { 9 | public abstract string Name { get; } 10 | 11 | public abstract string Description { get; } 12 | 13 | public virtual string[] Aliases { get { return new string[0]; } } 14 | 15 | public virtual void Handle(IRemoteClient client, string alias, string[] arguments) { Help(client, alias, arguments); } 16 | 17 | public virtual void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("Command \"" + alias + "\" is not functional!"); } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /TrueCraft/World/IDimensionFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using TrueCraft; 4 | using TrueCraft.Core.Server; 5 | 6 | namespace TrueCraft.World 7 | { 8 | public interface IDimensionFactory 9 | { 10 | /// 11 | /// Builds a set of dimensions for a World. 12 | /// 13 | /// 14 | /// The folder containing the World Saves. 15 | /// The seed for generating the World. 16 | /// 17 | IList BuildDimensions(IServerServiceLocator serviceLocator, string baseDirectory, int seed); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /TrueCraft.Core/Server/ChatMessageEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Networking; 3 | 4 | namespace TrueCraft.Core.Server 5 | { 6 | public class ChatMessageEventArgs : EventArgs 7 | { 8 | public ChatMessageEventArgs(IRemoteClient client, string message) 9 | { 10 | Client = client; 11 | Message = message; 12 | PreventDefault = false; 13 | } 14 | 15 | public IRemoteClient Client { get; set; } 16 | public string Message { get; set; } 17 | /// 18 | /// If set to true, the server won't send the default message back to the client. 19 | /// 20 | public bool PreventDefault { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/ButtonBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class ButtonBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x4D; 8 | 9 | public override byte ID { get { return 0x4D; } } 10 | 11 | public override double BlastResistance { get { return 2.5; } } 12 | 13 | public override double Hardness { get { return 0.5; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override bool Opaque { get { return false; } } 18 | 19 | public override string GetDisplayName(short metadata) 20 | { 21 | return "Button"; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/PlayerGroundedPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent by clients to update whether or not the player is on the ground. 7 | /// Probably best to just ignore this. 8 | /// 9 | public struct PlayerGroundedPacket : IPacket 10 | { 11 | public byte ID { get { return 0x0A; }} 12 | 13 | public bool OnGround; 14 | 15 | public void ReadPacket(IMinecraftStream stream) 16 | { 17 | OnGround = stream.ReadBoolean(); 18 | } 19 | 20 | public void WritePacket(IMinecraftStream stream) 21 | { 22 | stream.WriteBoolean(OnGround); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/CreeperEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class CreeperEntity : MobEntity 8 | { 9 | public CreeperEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager, 20, new Size(0.6, 1.8, 0.6)) 11 | { 12 | } 13 | 14 | public override sbyte MobType 15 | { 16 | get 17 | { 18 | return 50; 19 | } 20 | } 21 | 22 | public override bool Friendly 23 | { 24 | get 25 | { 26 | return false; 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/ZombieEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class ZombieEntity : MobEntity 8 | { 9 | public ZombieEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager, 20, new Size(0.6, 1.8, 0.6)) 11 | { 12 | } 13 | 14 | public override sbyte MobType 15 | { 16 | get 17 | { 18 | return 54; 19 | } 20 | } 21 | 22 | public override bool Friendly 23 | { 24 | get 25 | { 26 | return false; 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/SkeletonEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class SkeletonEntity : MobEntity 8 | { 9 | public SkeletonEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager, 20, new Size(0.6, 1.8, 0.6)) 11 | { 12 | } 13 | 14 | public override sbyte MobType 15 | { 16 | get 17 | { 18 | return 51; 19 | } 20 | } 21 | 22 | public override bool Friendly 23 | { 24 | get 25 | { 26 | return false; 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/SpiderEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class SpiderEntity : MobEntity 8 | { 9 | public SpiderEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager, 16, new Size(1.4, 0.9, 1.4)) 11 | { 12 | } 13 | 14 | public override sbyte MobType 15 | { 16 | get 17 | { 18 | return 52; 19 | } 20 | } 21 | 22 | public override bool Friendly 23 | { 24 | get 25 | { 26 | return false; 27 | } 28 | } 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/ZombiePigmanEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class ZombiePigmanEntity : MobEntity 8 | { 9 | public ZombiePigmanEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager, 20, new Size(0.6, 1.8, 0.6)) 11 | { 12 | } 13 | 14 | public override sbyte MobType 15 | { 16 | get 17 | { 18 | return 57; 19 | } 20 | } 21 | 22 | public override bool Friendly 23 | { 24 | get 25 | { 26 | return false; 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /TrueCraft/Commands/PingCommand.cs: -------------------------------------------------------------------------------- 1 | using TrueCraft.Core.Networking; 2 | 3 | namespace TrueCraft.Commands 4 | { 5 | public class PingCommand : Command 6 | { 7 | public override string Name 8 | { 9 | get { return "ping"; } 10 | } 11 | 12 | public override string Description 13 | { 14 | get { return "Ping pong"; } 15 | } 16 | 17 | public override void Handle(IRemoteClient client, string alias, string[] arguments) 18 | { 19 | client.SendMessage("Pong!"); 20 | } 21 | 22 | public override void Help(IRemoteClient client, string alias, string[] arguments) 23 | { 24 | client.SendMessage("Correct usage is /" + alias); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/KeepAlivePacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent periodically to confirm that the connection is still active. Send the same packet back 7 | /// to confirm it. Connection is dropped if no keep alive is received within one minute. 8 | /// 9 | public struct KeepAlivePacket : IPacket 10 | { 11 | public byte ID { get { return 0x00; } } 12 | 13 | public void ReadPacket(IMinecraftStream stream) 14 | { 15 | // This space intentionally left blank 16 | } 17 | 18 | public void WritePacket(IMinecraftStream stream) 19 | { 20 | // This space intentionally left blank 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /TrueCraft/TerrainGen/Biomes/PlainsBiome.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.TerrainGen.Biomes 6 | { 7 | public class PlainsBiome : BiomeProvider 8 | { 9 | public override byte ID 10 | { 11 | get { return (byte)Biome.Plains; } 12 | } 13 | 14 | public override double Temperature 15 | { 16 | get { return 0.8f; } 17 | } 18 | 19 | public override double Rainfall 20 | { 21 | get { return 0.4f; } 22 | } 23 | 24 | public override TreeSpecies[] Trees 25 | { 26 | get 27 | { 28 | return new[] { TreeSpecies.Oak }; 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Test/TrueCraft.Core.Test/Utility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Xml; 4 | 5 | namespace TrueCraft.Core.Test 6 | { 7 | public static class Utility 8 | { 9 | /// 10 | /// Gets the top node from the given XML 11 | /// 12 | /// An XML document in a string. 13 | /// The root node of the XML Document. 14 | public static XmlNode GetTopNode(string xml) 15 | { 16 | XmlDocument doc = new XmlDocument(); 17 | using (StringReader sr = new StringReader(xml)) 18 | using (XmlReader xmlr = XmlReader.Create(sr)) 19 | doc.Load(xmlr); 20 | 21 | return doc.FirstChild!; 22 | } 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/HandshakePacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent from clients to begin a new connection. 7 | /// 8 | public struct HandshakePacket : IPacket 9 | { 10 | public byte ID { get { return 0x02; } } 11 | 12 | public HandshakePacket(string username) 13 | { 14 | Username = username; 15 | } 16 | 17 | public string Username; 18 | 19 | public void ReadPacket(IMinecraftStream stream) 20 | { 21 | Username = stream.ReadString(); 22 | } 23 | 24 | public void WritePacket(IMinecraftStream stream) 25 | { 26 | stream.WriteString(Username); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /TrueCraft/TerrainGen/Biomes/ForestBiome.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.TerrainGen.Biomes 6 | { 7 | public class ForestBiome : BiomeProvider 8 | { 9 | public override byte ID 10 | { 11 | get { return (byte)Biome.Forest; } 12 | } 13 | 14 | public override double Temperature 15 | { 16 | get { return 0.7f; } 17 | } 18 | 19 | public override double Rainfall 20 | { 21 | get { return 0.8f; } 22 | } 23 | 24 | public override PlantSpecies[] Plants 25 | { 26 | get 27 | { 28 | return new[] { PlantSpecies.TallGrass }; 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/UpdateHealthPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent by servers to inform clients of their current health. 7 | /// 8 | public struct UpdateHealthPacket : IPacket 9 | { 10 | public byte ID { get { return 0x08; } } 11 | 12 | public UpdateHealthPacket(short health) 13 | { 14 | Health = health; 15 | } 16 | 17 | public short Health; 18 | 19 | public void ReadPacket(IMinecraftStream stream) 20 | { 21 | Health = stream.ReadInt16(); 22 | } 23 | 24 | public void WritePacket(IMinecraftStream stream) 25 | { 26 | stream.WriteInt16(Health); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /TrueCraft/Rules/OverworldSpawnRules.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.AI; 3 | using TrueCraft.Core.Server; 4 | using TrueCraft.Core.World; 5 | 6 | namespace TrueCraft.Rules 7 | { 8 | /// 9 | /// Default rules for spawning mobs in the overworld. 10 | /// 11 | public class OverworldSpawnRules : ISpawnRule 12 | { 13 | public void GenerateMobs(IChunk chunk, IEntityManager entityManager) 14 | { 15 | // TODO 16 | } 17 | 18 | public void SpawnMobs(IChunk chunk, IEntityManager entityManager) 19 | { 20 | // TODO 21 | } 22 | 23 | public int ChunkSpawnChance 24 | { 25 | get 26 | { 27 | return 10; 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /TrueCraft.Core/World/IBiomeProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using TrueCraft.Core.Logic; 6 | 7 | namespace TrueCraft.Core.World 8 | { 9 | public interface IBiomeProvider 10 | { 11 | bool Spawn { get; } 12 | byte ID { get; } 13 | int Elevation { get; } 14 | double Temperature { get; } 15 | double Rainfall { get; } 16 | TreeSpecies[] Trees { get; } 17 | PlantSpecies[] Plants { get; } 18 | OreTypes[] Ores { get; } 19 | double TreeDensity { get; } 20 | byte WaterBlock { get; } 21 | byte SurfaceBlock { get; } 22 | byte FillerBlock { get; } 23 | int SurfaceDepth { get; } 24 | int FillerDepth { get; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /TrueCraft.Core/AI/ISpawnRule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.World; 3 | using TrueCraft.Core.Server; 4 | 5 | namespace TrueCraft.Core.AI 6 | { 7 | public interface ISpawnRule 8 | { 9 | /// 10 | /// One in every n chunks will spawn mobs (with randomness mixed in). 11 | /// 12 | int ChunkSpawnChance { get; } 13 | 14 | /// 15 | /// Spawns mobs on a given chunk immediately after the chunk has been generated. 16 | /// 17 | void GenerateMobs(IChunk chunk, IEntityManager entityManager); 18 | 19 | /// 20 | /// Spawns mobs as part of the ongoing spawn cycle. 21 | /// 22 | void SpawnMobs(IChunk chunk, IEntityManager entityManager); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/IDiscover.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace TrueCraft.Core.Logic 3 | { 4 | public interface IDiscover 5 | { 6 | /// 7 | /// 8 | /// 9 | /// 10 | void DiscoverItemProviders(IRegisterItemProvider repository); 11 | 12 | /// 13 | /// Finds all the available Block Providers and registers them in the Block Repository. 14 | /// 15 | /// 16 | void DiscoverBlockProviders(IRegisterBlockProvider repository); 17 | 18 | /// 19 | /// 20 | /// 21 | /// 22 | void DiscoverRecipes(IRegisterRecipe repository); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/UpdateStatisticPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent to update the client's list of player statistics. 7 | /// 8 | public struct UpdateStatisticPacket : IPacket 9 | { 10 | public byte ID { get { return 0xC8; } } 11 | 12 | public int StatisticID; 13 | public sbyte Delta; 14 | 15 | public void ReadPacket(IMinecraftStream stream) 16 | { 17 | StatisticID = stream.ReadInt32(); 18 | Delta = stream.ReadInt8(); 19 | } 20 | 21 | public void WritePacket(IMinecraftStream stream) 22 | { 23 | stream.WriteInt32(StatisticID); 24 | stream.WriteInt8(Delta); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/DisconnectPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Disconnects from a server or kicks a player. This is the last packet sent. 7 | /// 8 | public struct DisconnectPacket : IPacket 9 | { 10 | public byte ID { get { return 0xFF; } } 11 | 12 | public DisconnectPacket(string reason) 13 | { 14 | Reason = reason; 15 | } 16 | 17 | public string Reason; 18 | 19 | public void ReadPacket(IMinecraftStream stream) 20 | { 21 | Reason = stream.ReadString(); 22 | } 23 | 24 | public void WritePacket(IMinecraftStream stream) 25 | { 26 | stream.WriteString(Reason); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /TrueCraft/TerrainGen/Generator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using TrueCraft.Core.World; 4 | using TrueCraft.World; 5 | 6 | namespace TrueCraft.TerrainGen 7 | { 8 | public abstract class Generator : IChunkProvider 9 | { 10 | protected readonly int _seed; 11 | 12 | private readonly List _decorators; 13 | 14 | protected Generator(int seed) 15 | { 16 | _seed = seed; 17 | _decorators = new List(); 18 | } 19 | 20 | protected IList ChunkDecorators { get => _decorators; } 21 | 22 | public abstract IChunk GenerateChunk(GlobalChunkCoordinates coordinates); 23 | 24 | public abstract GlobalVoxelCoordinates GetSpawn(IDimension dimension); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /TrueCraft.Client/Modules/IInputModule.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using TrueCraft.Client.Input; 3 | 4 | namespace TrueCraft.Client.Modules 5 | { 6 | public interface IInputModule : IGameplayModule 7 | { 8 | bool KeyDown(GameTime gameTime, KeyboardKeyEventArgs e); 9 | bool KeyUp(GameTime gameTime, KeyboardKeyEventArgs e); 10 | bool MouseMove(GameTime gameTime, MouseMoveEventArgs e); 11 | bool MouseButtonDown(GameTime gameTime, MouseButtonEventArgs e); 12 | bool MouseButtonUp(GameTime gameTime, MouseButtonEventArgs e); 13 | bool MouseScroll(GameTime gameTime, MouseScrollEventArgs e); 14 | bool GamePadButtonDown(GameTime gameTime, GamePadButtonEventArgs e); 15 | bool GamePadButtonUp(GameTime gameTime, GamePadButtonEventArgs e); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/BedrockBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class BedrockBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x07; 8 | 9 | public override byte ID { get { return 0x07; } } 10 | 11 | public override double BlastResistance { get { return 18000000; } } 12 | 13 | public override double Hardness { get { return -1; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Bedrock"; 20 | } 21 | 22 | public override Tuple GetTextureMap(byte metadata) 23 | { 24 | return new Tuple(1, 1); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/AttachEntityPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Used to attach entities to other entities, i.e. players to minecarts 7 | /// 8 | public struct AttachEntityPacket : IPacket 9 | { 10 | public byte ID { get { return 0x27; } } 11 | 12 | public int EntityID; 13 | public int VehicleID; 14 | 15 | public void ReadPacket(IMinecraftStream stream) 16 | { 17 | EntityID = stream.ReadInt32(); 18 | VehicleID = stream.ReadInt32(); 19 | } 20 | 21 | public void WritePacket(IMinecraftStream stream) 22 | { 23 | stream.WriteInt32(EntityID); 24 | stream.WriteInt32(VehicleID); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /TrueCraft/AccessConfiguration.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using TrueCraft.Core; 3 | using YamlDotNet.Serialization; 4 | 5 | namespace TrueCraft 6 | { 7 | public class AccessConfiguration : Configuration, IAccessConfiguration 8 | { 9 | public AccessConfiguration() 10 | { 11 | Blacklist = new List(); 12 | Whitelist = new List(); 13 | Oplist = new List(); 14 | } 15 | 16 | [YamlMember(Alias = "blacklist")] 17 | public IList Blacklist { get; private set; } 18 | 19 | [YamlMember(Alias = "whitelist")] 20 | public IList Whitelist { get; private set; } 21 | 22 | [YamlMember(Alias = "ops")] 23 | public IList Oplist { get; private set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /TrueCraft.Core/Inventory/ISlotFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using TrueCraft.Core.Logic; 4 | 5 | namespace TrueCraft.Core.Inventory 6 | { 7 | public interface ISlotFactory where T : ISlot 8 | { 9 | /// 10 | /// Gets an instance of ISlot. 11 | /// 12 | /// 13 | T GetSlot(IItemRepository itemRepository); 14 | 15 | /// 16 | /// Gets a List containing the specified number of ISlot implementations. 17 | /// 18 | /// 19 | /// The number of ISlot instances to return. 20 | /// 21 | List GetSlots(IItemRepository itemRepository, int count); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/BricksBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class BricksBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x2D; 8 | 9 | public override byte ID { get { return 0x2D; } } 10 | 11 | public override double BlastResistance { get { return 30; } } 12 | 13 | public override double Hardness { get { return 2; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Bricks"; 20 | } 21 | 22 | public override Tuple GetTextureMap(byte metadata) 23 | { 24 | return new Tuple(7, 0); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /TrueCraft/Inventory/IServerSlots.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using TrueCraft.Core.Inventory; 4 | using TrueCraft.Core.Networking.Packets; 5 | using TrueCraft.Core.Server; 6 | 7 | namespace TrueCraft.Inventory 8 | { 9 | public interface IServerSlots : ISlots 10 | { 11 | /// 12 | /// Gets a SetSlotPacket for each Inventory Slot which has been changed 13 | /// since the last time SetSlotPackets were sent. 14 | /// 15 | /// the Window ID to use in the SetSlotPackets. 16 | /// An offset to add to the Index property of the ISlot. 17 | /// 18 | List GetSetSlotPackets(sbyte windowID, short baseIndex); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /TrueCraft/TerrainGen/Biomes/SeasonalForestBiome.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.TerrainGen.Biomes 6 | { 7 | public class SeasonalForestBiome : BiomeProvider 8 | { 9 | public override byte ID 10 | { 11 | get { return (byte)Biome.SeasonalForest; } 12 | } 13 | 14 | public override double Temperature 15 | { 16 | get { return 0.7f; } 17 | } 18 | 19 | public override double Rainfall 20 | { 21 | get { return 0.8f; } 22 | } 23 | 24 | public override PlantSpecies[] Plants 25 | { 26 | get 27 | { 28 | return new[] { PlantSpecies.Fern, PlantSpecies.TallGrass }; 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /TrueCraft.Client/Handlers/ActionList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace TrueCraft.Client.Handlers 5 | { 6 | public static class ActionList 7 | { 8 | private static List _lst = new List(); 9 | 10 | 11 | public static void Add(ActionConfirmation action) 12 | { 13 | _lst.Add(action); 14 | } 15 | 16 | public static ActionConfirmation? Get(int actionNumber) 17 | { 18 | int n = 0; 19 | while (n < _lst.Count && _lst[n].ActionNumber != actionNumber) 20 | n++; 21 | 22 | if (n == _lst.Count) return null; 23 | 24 | ActionConfirmation rv = _lst[n]; 25 | _lst.RemoveAt(n); 26 | 27 | return rv; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /TrueCraft.Client/Inventory/SlotFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using TrueCraft.Core.Inventory; 4 | using TrueCraft.Core.Logic; 5 | using TrueCraft.Core.Server; 6 | 7 | namespace TrueCraft.Client.Inventory 8 | { 9 | public class SlotFactory : ISlotFactory 10 | { 11 | public SlotFactory() 12 | { 13 | } 14 | 15 | public ISlot GetSlot(IItemRepository itemRepository) 16 | { 17 | return new Slot(itemRepository); 18 | } 19 | 20 | public List GetSlots(IItemRepository itemRepository, int count) 21 | { 22 | List rv = new List(count); 23 | for (int j = 0; j < count; j++) 24 | rv.Add(new Slot(itemRepository)); 25 | 26 | return rv; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/MossStoneBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class MossStoneBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x30; 8 | 9 | public override byte ID { get { return 0x30; } } 10 | 11 | public override double BlastResistance { get { return 30; } } 12 | 13 | public override double Hardness { get { return 2; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Moss Stone"; 20 | } 21 | 22 | public override Tuple GetTextureMap(byte metadata) 23 | { 24 | return new Tuple(4, 2); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/NetherrackBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class NetherrackBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x57; 8 | 9 | public override byte ID { get { return 0x57; } } 10 | 11 | public override double BlastResistance { get { return 2; } } 12 | 13 | public override double Hardness { get { return 0.4; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Netherrack"; 20 | } 21 | 22 | public override Tuple GetTextureMap(byte metadata) 23 | { 24 | return new Tuple(7, 6); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/SandstoneBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class SandstoneBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x18; 8 | 9 | public override byte ID { get { return 0x18; } } 10 | 11 | public override double BlastResistance { get { return 4; } } 12 | 13 | public override double Hardness { get { return 0.8; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Sandstone"; 20 | } 21 | 22 | public override Tuple GetTextureMap(byte metadata) 23 | { 24 | return new Tuple(0, 12); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/ObjectEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using TrueCraft.Core.Server; 6 | using TrueCraft.Core.World; 7 | 8 | namespace TrueCraft.Core.Entities 9 | { 10 | public abstract class ObjectEntity : Entity 11 | { 12 | protected ObjectEntity(IDimension dimension, IEntityManager entityManager, 13 | Size size, float accelerationDueToGravity, float drag, float terminalVelocity) : 14 | base(dimension, entityManager, size, accelerationDueToGravity, drag, terminalVelocity) 15 | { 16 | } 17 | 18 | // TODO: What is the meaning of this? 19 | public abstract byte EntityType { get; } 20 | 21 | // TODO: What is the meaning of this? 22 | public abstract int Data { get; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/CobblestoneBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class CobblestoneBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x04; 8 | 9 | public override byte ID { get { return 0x04; } } 10 | 11 | public override double BlastResistance { get { return 30; } } 12 | 13 | public override double Hardness { get { return 2; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Cobblestone"; 20 | } 21 | 22 | public override Tuple GetTextureMap(byte metadata) 23 | { 24 | return new Tuple(0, 1); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/MinecartItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | 4 | namespace TrueCraft.Core.Logic.Items 5 | { 6 | public class MinecartItem : ItemProvider 7 | { 8 | public static readonly short ItemID = 0x148; 9 | 10 | public MinecartItem(XmlNode node) : base(node) 11 | { 12 | } 13 | } 14 | 15 | public class MinecartWithChestItem : MinecartItem 16 | { 17 | public static readonly new short ItemID = 0x156; 18 | 19 | public MinecartWithChestItem(XmlNode node) : base(node) 20 | { 21 | } 22 | } 23 | 24 | public class MinecartWithFurnaceItem : MinecartItem 25 | { 26 | public static readonly new short ItemID = 0x157; 27 | 28 | public MinecartWithFurnaceItem(XmlNode node) : base(node) 29 | { 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/CloseWindowPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent by the server to forcibly close an inventory window, or from the client when naturally closed. 7 | /// 8 | public struct CloseWindowPacket : IPacket 9 | { 10 | public byte ID { get { return 0x65; } } 11 | 12 | public CloseWindowPacket(sbyte windowID) 13 | { 14 | WindowID = windowID; 15 | } 16 | 17 | public sbyte WindowID; 18 | 19 | public void ReadPacket(IMinecraftStream stream) 20 | { 21 | WindowID = stream.ReadInt8(); 22 | } 23 | 24 | public void WritePacket(IMinecraftStream stream) 25 | { 26 | stream.WriteInt8(WindowID); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /TrueCraft.Profiling/TrueCraft.Profiling.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Library 5 | netstandard2.1 6 | false 7 | false 8 | true 9 | 10 | 11 | 12 | true 13 | full 14 | false 15 | DEBUG; 16 | 17 | 18 | 19 | true 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logging/FileLogProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace TrueCraft.Core.Logging 5 | { 6 | public class FileLogProvider : ILogProvider 7 | { 8 | public StreamWriter Stream { get; set; } 9 | public LogCategory EnabledCategories { get; set; } 10 | 11 | public FileLogProvider(StreamWriter stream, LogCategory enabledCategories = LogCategory.Notice | LogCategory.Warning | LogCategory.Error) 12 | { 13 | Stream = stream; 14 | EnabledCategories = enabledCategories; 15 | } 16 | 17 | public void Log(LogCategory category, string text, params object[] parameters) 18 | { 19 | if ((EnabledCategories & category) != 0) 20 | { 21 | Stream.WriteLine(text, parameters); 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Inventory/IFurnaceWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Inventory 4 | { 5 | public interface IFurnaceWindow : IWindow where T : ISlot 6 | { 7 | ISlots Ingredient { get; } 8 | 9 | /// 10 | /// Gets the Slot Index (within the Window) of the Ingredient Slot. 11 | /// 12 | int IngredientSlotIndex { get; } 13 | 14 | ISlots Fuel { get; } 15 | 16 | /// 17 | /// Gets the Slot Index (within the Window) of the Fuel Slot. 18 | /// 19 | int FuelSlotIndex { get; } 20 | 21 | ISlots Output { get; } 22 | 23 | /// 24 | /// Gets the Slot Index (within the Window) of the Output Slot. 25 | /// 26 | int OutputSlotIndex { get; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logging/LogCategory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logging 4 | { 5 | [Flags] 6 | public enum LogCategory 7 | { 8 | /// 9 | /// Packets transmitted and received. 10 | /// 11 | Packets = 1, 12 | /// 13 | /// Debug information. 14 | /// 15 | Debug = 2, 16 | /// 17 | /// Potentially harmful, but not catastrophic, problems. 18 | /// 19 | Warning = 4, 20 | /// 21 | /// Catastrophic errors. 22 | /// 23 | Error = 8, 24 | /// 25 | /// Generally useful information. 26 | /// 27 | Notice = 16, 28 | All = Packets | Debug | Warning | Error | Notice 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/RespawnPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.World; 3 | 4 | namespace TrueCraft.Core.Networking.Packets 5 | { 6 | /// 7 | /// Sent by clients when the player clicks "Respawn" after death. Sent by servers to confirm 8 | /// the respawn, and to respawn players in different dimensions (i.e. when using a portal). 9 | /// 10 | public struct RespawnPacket : IPacket 11 | { 12 | public byte ID { get { return 0x09; } } 13 | 14 | public DimensionID Dimension; 15 | 16 | public void ReadPacket(IMinecraftStream stream) 17 | { 18 | Dimension = (DimensionID)stream.ReadInt8(); 19 | } 20 | 21 | public void WritePacket(IMinecraftStream stream) 22 | { 23 | stream.WriteInt8((sbyte)Dimension); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Server/IAccessConfiguration.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using TrueCraft.Core.Networking; 3 | 4 | namespace TrueCraft.Core 5 | { 6 | /// 7 | /// Interface for objects providing server access configuration. 8 | /// 9 | public interface IAccessConfiguration 10 | { 11 | /// 12 | /// Gets a list of blacklisted players for the configuration. 13 | /// 14 | IList Blacklist { get; } 15 | 16 | /// 17 | /// Gets a list of whitelisted players for the configuration. 18 | /// 19 | IList Whitelist { get; } 20 | 21 | /// 22 | /// Gets a list of opped players for the configuration. 23 | /// 24 | IList Oplist { get; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /TrueCraft/Inventory/SlotFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using TrueCraft.Core.Inventory; 4 | using TrueCraft.Core.Logic; 5 | using TrueCraft.Core.Server; 6 | 7 | namespace TrueCraft.Inventory 8 | { 9 | public class SlotFactory : ISlotFactory 10 | { 11 | public SlotFactory() 12 | { 13 | } 14 | 15 | public IServerSlot GetSlot(IItemRepository itemRepository) 16 | { 17 | return new ServerSlot(itemRepository); 18 | } 19 | 20 | public List GetSlots(IItemRepository itemRepository, int count) 21 | { 22 | List rv = new List(count); 23 | for (int j = 0; j < count; j++) 24 | rv.Add(new ServerSlot(itemRepository, j)); 25 | 26 | return rv; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/PlayerActionPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | public struct PlayerActionPacket : IPacket 6 | { 7 | public enum PlayerAction 8 | { 9 | Crouch = 1, 10 | Uncrouch = 2, 11 | LeaveBed = 3, 12 | } 13 | 14 | public byte ID { get { return 0x13; } } 15 | 16 | public int EntityID; 17 | public PlayerAction Action; 18 | 19 | public void ReadPacket(IMinecraftStream stream) 20 | { 21 | EntityID = stream.ReadInt32(); 22 | Action = (PlayerAction)stream.ReadInt8(); 23 | } 24 | 25 | public void WritePacket(IMinecraftStream stream) 26 | { 27 | stream.WriteInt32(EntityID); 28 | stream.WriteInt8((sbyte)Action); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Server/IEntityManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Entities; 3 | using System.Collections.Generic; 4 | using TrueCraft.Core.Networking; 5 | using TrueCraft.Core.World; 6 | 7 | namespace TrueCraft.Core.Server 8 | { 9 | public interface IEntityManager 10 | { 11 | TimeSpan TimeSinceLastUpdate { get; } 12 | /// 13 | /// Adds an entity to the world and assigns it an entity ID. 14 | /// 15 | void SpawnEntity(IEntity entity); 16 | void DespawnEntity(IEntity entity); 17 | void FlushDespawns(); 18 | IEntity? GetEntityByID(int id); 19 | void Update(); 20 | void SendEntitiesToClient(IRemoteClient client); 21 | IList EntitiesInRange(Vector3 center, float radius); 22 | IList ClientsForEntity(IEntity entity); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/EntityLookPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent by servers to update the direction an entity is looking in. 7 | /// 8 | public struct EntityLookPacket : IPacket 9 | { 10 | public byte ID { get { return 0x20; } } 11 | 12 | public int EntityID; 13 | public sbyte Yaw, Pitch; 14 | 15 | public void ReadPacket(IMinecraftStream stream) 16 | { 17 | EntityID = stream.ReadInt32(); 18 | Yaw = stream.ReadInt8(); 19 | Pitch = stream.ReadInt8(); 20 | } 21 | 22 | public void WritePacket(IMinecraftStream stream) 23 | { 24 | stream.WriteInt32(EntityID); 25 | stream.WriteInt8(Yaw); 26 | stream.WriteInt8(Pitch); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/EntityRelativeMovePacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | public struct EntityRelativeMovePacket : IPacket 6 | { 7 | public byte ID { get { return 0x1F; } } 8 | 9 | public int EntityID; 10 | public sbyte DeltaX, DeltaY, DeltaZ; 11 | 12 | public void ReadPacket(IMinecraftStream stream) 13 | { 14 | EntityID = stream.ReadInt32(); 15 | DeltaX = stream.ReadInt8(); 16 | DeltaY = stream.ReadInt8(); 17 | DeltaZ = stream.ReadInt8(); 18 | } 19 | 20 | public void WritePacket(IMinecraftStream stream) 21 | { 22 | stream.WriteInt32(EntityID); 23 | stream.WriteInt8(DeltaX); 24 | stream.WriteInt8(DeltaY); 25 | stream.WriteInt8(DeltaZ); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/PlayerLookPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent to update the rotation of the player's head and body. 7 | /// 8 | public struct PlayerLookPacket : IPacket 9 | { 10 | public byte ID { get { return 0x0C; } } 11 | 12 | public float Yaw, Pitch; 13 | public bool OnGround; 14 | 15 | public void ReadPacket(IMinecraftStream stream) 16 | { 17 | Yaw = stream.ReadSingle(); 18 | Pitch = stream.ReadSingle(); 19 | OnGround = stream.ReadBoolean(); 20 | } 21 | 22 | public void WritePacket(IMinecraftStream stream) 23 | { 24 | stream.WriteSingle(Yaw); 25 | stream.WriteSingle(Pitch); 26 | stream.WriteBoolean(OnGround); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/TimeUpdatePacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent from the server to inform the client of the in-game time of day. 7 | /// The number sent is in 1/20th of a second increments, where 24000 ticks are in each day. 8 | /// 9 | public struct TimeUpdatePacket : IPacket 10 | { 11 | public byte ID { get { return 0x04; } } 12 | 13 | public TimeUpdatePacket(long time) 14 | { 15 | Time = time; 16 | } 17 | 18 | public long Time; 19 | 20 | public void ReadPacket(IMinecraftStream stream) 21 | { 22 | Time = stream.ReadInt64(); 23 | } 24 | 25 | public void WritePacket(IMinecraftStream stream) 26 | { 27 | stream.WriteInt64(Time); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /TrueCraft/TerrainGen/Noise/ScaleNoise.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace TrueCraft.TerrainGen.Noise 7 | { 8 | public class ScaledNoise : NoiseGen 9 | { 10 | public NoiseGen Noise { get; set; } 11 | public double Bias { get; set; } 12 | public double Scale { get; set; } 13 | public ScaledNoise(NoiseGen Noise) 14 | { 15 | this.Noise = Noise; 16 | Bias = 0; 17 | Scale = 1; 18 | } 19 | 20 | public override double Value2D(double X, double Y) 21 | { 22 | return Noise.Value2D(X, Y) * Scale + Bias; 23 | } 24 | 25 | public override double Value3D(double X, double Y, double Z) 26 | { 27 | return Noise.Value3D(X, Y, Z) * Scale + Bias; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/EnvironmentStatePacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Updates the player on changes to or status of the environment. 7 | /// 8 | public struct EnvironmentStatePacket : IPacket 9 | { 10 | public enum EnvironmentState 11 | { 12 | InvalidBed = 0, 13 | BeginRaining = 1, 14 | EndRaining = 2 15 | } 16 | 17 | public byte ID { get { return 0x46; } } 18 | 19 | public EnvironmentState State; 20 | 21 | public void ReadPacket(IMinecraftStream stream) 22 | { 23 | State = (EnvironmentState)stream.ReadInt8(); 24 | } 25 | 26 | public void WritePacket(IMinecraftStream stream) 27 | { 28 | stream.WriteInt8((sbyte)State); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /TrueCraft.Core/AI/IdleState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.AI; 3 | using TrueCraft.Core.Entities; 4 | using TrueCraft.Core.Server; 5 | 6 | namespace TrueCraft.Core.AI 7 | { 8 | public class IdleState : IMobState 9 | { 10 | private DateTime Expiry { get; set; } 11 | private IMobState NextState { get; set; } 12 | 13 | public IdleState(IMobState nextState, DateTime? expiry = null) 14 | { 15 | NextState = nextState; 16 | if (expiry != null) 17 | Expiry = expiry.Value; 18 | else 19 | Expiry = DateTime.UtcNow.AddSeconds(MathHelper.Random.Next(5, 15)); 20 | } 21 | 22 | public void Update(IMobEntity entity, IEntityManager manager) 23 | { 24 | if (DateTime.UtcNow >= Expiry) 25 | entity.CurrentState = NextState; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /TrueCraft.Core/Inventory/IInventoryWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Inventory 4 | { 5 | public interface IInventoryWindow : IWindow where T : ISlot 6 | { 7 | /// 8 | /// Gets the 2x2 Crafting Grid which is part of the Inventory Window. 9 | /// 10 | public ICraftingArea CraftingGrid { get; } 11 | 12 | /// 13 | /// Gets the Slot Index (within the Window) of the Crafting Output Slot. 14 | /// 15 | /// This is the first slot of the Crafting Area. 16 | int CraftingOutputSlotIndex { get; } 17 | 18 | public ISlots Armor { get; } 19 | 20 | /// 21 | /// Gets the Slot Index (withing the Window) of the first Slot of the Armor Area. 22 | /// 23 | int ArmorSlotIndex { get; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/UseEntityPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent by clients upon clicking an entity. 7 | /// 8 | public struct UseEntityPacket : IPacket 9 | { 10 | public byte ID { get { return 0x07; } } 11 | 12 | public int UserID; 13 | public int TargetID; 14 | public bool LeftClick; 15 | 16 | public void ReadPacket(IMinecraftStream stream) 17 | { 18 | UserID = stream.ReadInt32(); 19 | TargetID = stream.ReadInt32(); 20 | LeftClick = stream.ReadBoolean(); 21 | } 22 | 23 | public void WritePacket(IMinecraftStream stream) 24 | { 25 | stream.WriteInt32(UserID); 26 | stream.WriteInt32(TargetID); 27 | stream.WriteBoolean(LeftClick); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/EntityMetadataPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | public struct EntityMetadataPacket : IPacket 6 | { 7 | public byte ID { get { return 0x28; } } 8 | 9 | public int EntityID; 10 | public MetadataDictionary Metadata; 11 | 12 | public EntityMetadataPacket(int entityID, MetadataDictionary metadata) 13 | { 14 | EntityID = entityID; 15 | Metadata = metadata; 16 | } 17 | 18 | public void ReadPacket(IMinecraftStream stream) 19 | { 20 | EntityID = stream.ReadInt32(); 21 | Metadata = MetadataDictionary.FromStream(stream); 22 | } 23 | 24 | public void WritePacket(IMinecraftStream stream) 25 | { 26 | stream.WriteInt32(EntityID); 27 | Metadata.WriteTo(stream); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/MapDataPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | public struct MapDataPacket : IPacket 6 | { 7 | public byte ID { get { return 0x83; } } 8 | 9 | public short ItemID; 10 | public short Metadata; 11 | public byte[] Data; 12 | 13 | public void ReadPacket(IMinecraftStream stream) 14 | { 15 | ItemID = stream.ReadInt16(); 16 | Metadata = stream.ReadInt16(); 17 | byte length = stream.ReadUInt8(); 18 | Data = stream.ReadUInt8Array(length); 19 | } 20 | 21 | public void WritePacket(IMinecraftStream stream) 22 | { 23 | stream.WriteInt16(ItemID); 24 | stream.WriteInt16(Metadata); 25 | stream.WriteUInt8((byte)Data.Length); 26 | stream.WriteUInt8Array(Data); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Server/IEventScheduler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace TrueCraft.Core.Server 5 | { 6 | public interface IEventScheduler 7 | { 8 | HashSet DisabledEvents { get; } 9 | /// 10 | /// Schedules an event to occur some time in the future. 11 | /// 12 | /// The subject of the event. If the subject is disposed, the event is cancelled. 13 | /// When to trigger the event. 14 | /// The event to trigger. 15 | void ScheduleEvent(string name, IEventSubject? subject, TimeSpan when, Action action); 16 | /// 17 | /// Triggers all pending scheduled events whose scheduled time has transpired. 18 | /// 19 | void Update(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logging/PacketLogging.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Networking; 3 | 4 | namespace TrueCraft.Core.Logging 5 | { 6 | public static class PacketLogging 7 | { 8 | public static void Log(this IPacket packet, ILogProvider log, bool clientToServer = false) 9 | { 10 | if (clientToServer) 11 | log.Log(LogCategory.Packets, "[CLIENT > SERVER] 0x{0:X2} {1}", packet.ID, packet.GetType().Name); 12 | else 13 | log.Log(LogCategory.Packets, "[SERVER > CLIENT] 0x{0:X2} {1}", packet.ID, packet.GetType().Name); 14 | foreach (var prop in packet.GetType().GetFields()) 15 | log.Log(LogCategory.Packets, "\t{0} ({1}): {2}", prop.Name, prop.FieldType.Name, prop.GetValue(packet) ?? string.Empty); 16 | log.Log(LogCategory.Packets, ""); // newline 17 | // TODO: Log packet payload 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /TrueCraft.Launcher/Singleplayer/WorldInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using fNbt; 3 | 4 | namespace TrueCraft.Launcher.Singleplayer 5 | { 6 | public class WorldInfo 7 | { 8 | public WorldInfo(string directory, NbtFile manifest) 9 | { 10 | this.Directory = directory; 11 | this.Seed = manifest.RootTag["Seed"].IntValue; 12 | this.Name = manifest.RootTag["Name"].StringValue; 13 | } 14 | 15 | /// 16 | /// Gets the name of the Directory in which this World is saved. 17 | /// 18 | public string Directory { get; } 19 | 20 | /// 21 | /// Gets the Seed used to generate the World. 22 | /// 23 | public int Seed { get; } 24 | 25 | /// 26 | /// Gets the name of the World 27 | /// 28 | public string Name { get; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/JukeboxBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class JukeboxBlock : BlockProvider, IBurnableItem 6 | { 7 | public static readonly byte BlockID = 0x54; 8 | 9 | public override byte ID { get { return 0x54; } } 10 | 11 | public override double BlastResistance { get { return 30; } } 12 | 13 | public override double Hardness { get { return 2; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Jukebox"; 20 | } 21 | 22 | public TimeSpan BurnTime { get { return TimeSpan.FromSeconds(15); } } 23 | 24 | public override Tuple GetTextureMap(byte metadata) 25 | { 26 | return new Tuple(10, 4); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/NoteBlockBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class NoteBlockBlock : BlockProvider, IBurnableItem 6 | { 7 | public static readonly byte BlockID = 0x19; 8 | 9 | public override byte ID { get { return 0x19; } } 10 | 11 | public override double BlastResistance { get { return 4; } } 12 | 13 | public override double Hardness { get { return 0.8; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Note Block"; 20 | } 21 | 22 | public TimeSpan BurnTime { get { return TimeSpan.FromSeconds(15); } } 23 | 24 | public override Tuple GetTextureMap(byte metadata) 25 | { 26 | return new Tuple(10, 4); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/OreTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace TrueCraft.Core 7 | { 8 | /// 9 | /// Enumerates the different types of ore in TrueCraft. 10 | /// 11 | public enum OreTypes 12 | { 13 | /// 14 | /// Coal ore. 15 | /// 16 | Coal, 17 | 18 | /// 19 | /// Lapis lazuli ore. 20 | /// 21 | Lapiz, 22 | 23 | /// 24 | /// Iron ore. 25 | /// 26 | Iron, 27 | 28 | /// 29 | /// Gold ore. 30 | /// 31 | Gold, 32 | 33 | /// 34 | /// Redstone ore. 35 | /// 36 | Redstone, 37 | 38 | /// 39 | /// Diamond ore. 40 | /// 41 | Diamond 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /TrueCraft.Client/Input/MouseEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Client.Input 4 | { 5 | /// 6 | /// Provides the event data for mouse events. 7 | /// 8 | public class MouseEventArgs : EventArgs 9 | { 10 | /// 11 | /// Gets the X coordinate for the event. 12 | /// 13 | public int X { get; private set; } 14 | 15 | /// 16 | /// Gets the Y coordinate for the event. 17 | /// 18 | public int Y { get; private set; } 19 | 20 | /// 21 | /// Creates new mouse event data. 22 | /// 23 | /// The X coordinate for the event. 24 | /// The Y coordinate for the event. 25 | public MouseEventArgs(int x, int y) 26 | { 27 | X = x; 28 | Y = y; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /TrueCraft.Client/Rendering/FontStyle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace TrueCraft.Client.Rendering 8 | { 9 | /// 10 | /// Enumerates the styles of fonts. 11 | /// 12 | public enum FontStyle 13 | { 14 | /// 15 | /// Regular font. 16 | /// 17 | Regular = 0, 18 | 19 | /// 20 | /// Bolded font. 21 | /// 22 | Bold = 1, 23 | 24 | /// 25 | /// Striked-through font. 26 | /// 27 | Strikethrough = 2, 28 | 29 | /// 30 | /// Underlined font. 31 | /// 32 | Underline = 3, 33 | 34 | /// 35 | /// Italicized font. 36 | /// 37 | Italic = 4, 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /TrueCraft/TerrainGen/Biomes/TaigaBiome.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.TerrainGen.Biomes 6 | { 7 | public class TaigaBiome : BiomeProvider 8 | { 9 | public override byte ID 10 | { 11 | get { return (byte)Biome.Taiga; } 12 | } 13 | 14 | public override double Temperature 15 | { 16 | get { return 0.0f; } 17 | } 18 | 19 | public override double Rainfall 20 | { 21 | get { return 0.0f; } 22 | } 23 | 24 | public override TreeSpecies[] Trees 25 | { 26 | get 27 | { 28 | return new[] { TreeSpecies.Spruce }; 29 | } 30 | } 31 | 32 | public override double TreeDensity 33 | { 34 | get 35 | { 36 | return 5; 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/ChangeHeldItemPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | public struct ChangeHeldItemPacket : IPacket 6 | { 7 | public byte ID { get { return 0x10; } } 8 | 9 | private short _slot; 10 | 11 | public ChangeHeldItemPacket(short slot) 12 | { 13 | #if DEBUG 14 | if (slot < 0 || slot >= 9) // NOTE: hard-coded constants for size of Hotbar! 15 | throw new ArgumentOutOfRangeException($"{slot} is not in the permissible hotbar range of [0,9)."); 16 | #endif 17 | 18 | _slot = slot; 19 | } 20 | 21 | public short Slot { get => _slot; } 22 | 23 | public void ReadPacket(IMinecraftStream stream) 24 | { 25 | _slot = stream.ReadInt16(); 26 | } 27 | 28 | public void WritePacket(IMinecraftStream stream) 29 | { 30 | stream.WriteInt16(_slot); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/ChatMessagePacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Used by clients to send messages and by servers to propegate messages to clients. 7 | /// Note that the server is expected to include the username, i.e. message, but the 8 | /// client is not given the same expectation. 9 | /// 10 | public struct ChatMessagePacket : IPacket 11 | { 12 | public byte ID { get { return 0x03; } } 13 | 14 | public ChatMessagePacket(string message) 15 | { 16 | Message = message; 17 | } 18 | 19 | public string Message; 20 | 21 | public void ReadPacket(IMinecraftStream stream) 22 | { 23 | Message = stream.ReadString(); 24 | } 25 | 26 | public void WritePacket(IMinecraftStream stream) 27 | { 28 | stream.WriteString(Message); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/GhastEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class GhastEntity : MobEntity 8 | { 9 | public GhastEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager, 10, new Size(4.0)) 11 | { 12 | } 13 | 14 | public override sbyte MobType 15 | { 16 | get 17 | { 18 | return 56; 19 | } 20 | } 21 | 22 | public override bool BeginUpdate() 23 | { 24 | // Ghasts can fly, no need to work out gravity 25 | // TODO: Think about how to deal with walls and such 26 | return false; 27 | } 28 | 29 | public override bool Friendly 30 | { 31 | get 32 | { 33 | return false; 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /TrueCraft/TerrainGen/Biomes/ShrublandBiome.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.TerrainGen.Biomes 6 | { 7 | public class ShrublandBiome : BiomeProvider 8 | { 9 | public override byte ID 10 | { 11 | get { return (byte)Biome.Shrubland; } 12 | } 13 | 14 | public override double Temperature 15 | { 16 | get { return 0.8f; } 17 | } 18 | 19 | public override double Rainfall 20 | { 21 | get { return 0.4f; } 22 | } 23 | 24 | public override TreeSpecies[] Trees 25 | { 26 | get 27 | { 28 | return new[] { TreeSpecies.Oak }; 29 | } 30 | } 31 | 32 | public override PlantSpecies[] Plants 33 | { 34 | get 35 | { 36 | return new PlantSpecies[0]; 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /TrueCraft.Core/World/DimensionID.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.World 4 | { 5 | /// 6 | /// Enumerates the different dimensions in the world in TrueCraft. 7 | /// 8 | public enum DimensionID 9 | { 10 | /// 11 | /// The Nether dimension. 12 | /// 13 | Nether = -1, 14 | 15 | /// 16 | /// The Overworld dimension. 17 | /// 18 | Overworld = 0 19 | } 20 | 21 | public static class DimensionInfo 22 | { 23 | public static string GetName(DimensionID id) 24 | { 25 | switch(id) 26 | { 27 | case DimensionID.Overworld: 28 | return "OverWorld"; 29 | 30 | case DimensionID.Nether: 31 | return "Nether"; 32 | 33 | default: 34 | return "Default"; 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /TrueCraft.Core/World/WorldConstants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.World 4 | { 5 | public static class WorldConstants 6 | { 7 | /// 8 | /// The width (X-direction) of a Chunk in Blocks. 9 | /// 10 | public const int ChunkWidth = 16; 11 | 12 | /// 13 | /// The depth (Z-direction) of a Chunk in Blocks. 14 | /// 15 | public const int ChunkDepth = 16; 16 | 17 | /// 18 | /// The Height (Y-direction) of the World in Blocks. 19 | /// 20 | public const int Height = 128; 21 | 22 | /// 23 | /// The width (X-direction) of a Region in Chunks. 24 | /// 25 | public const int RegionWidth = 32; 26 | 27 | /// 28 | /// The depth (Z-Direction) of a Region in Chunks. 29 | /// 30 | public const int RegionDepth = 32; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /TrueCraft/World/IBiomeMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using TrueCraft.Core.World; 5 | 6 | namespace TrueCraft.World 7 | { 8 | public class BiomeCell 9 | { 10 | public byte BiomeID { get; } 11 | public GlobalColumnCoordinates CellPoint { get; } 12 | 13 | public BiomeCell(byte biomeID, GlobalColumnCoordinates cellPoint) 14 | { 15 | this.BiomeID = biomeID; 16 | this.CellPoint = cellPoint; 17 | } 18 | } 19 | 20 | public interface IBiomeMap 21 | { 22 | IList BiomeCells { get; } 23 | void AddCell(BiomeCell cell); 24 | byte GetBiome(GlobalColumnCoordinates location); 25 | byte GenerateBiome(int seed, IBiomeRepository biomes, GlobalColumnCoordinates location, bool spawn); 26 | BiomeCell? ClosestCell(GlobalColumnCoordinates location); 27 | double ClosestCellPoint(GlobalColumnCoordinates location); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/HoeItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | using TrueCraft.Core.Logic.Blocks; 4 | using TrueCraft.Core.Networking; 5 | using TrueCraft.Core.World; 6 | 7 | namespace TrueCraft.Core.Logic.Items 8 | { 9 | public class HoeItem : ToolItem 10 | { 11 | public HoeItem(XmlNode node) : base(node) 12 | { 13 | } 14 | 15 | public override void ItemUsedOnBlock(GlobalVoxelCoordinates coordinates, ItemStack item, BlockFace face, IDimension dimension, IRemoteClient user) 16 | { 17 | var id = dimension.GetBlockID(coordinates); 18 | if (id == DirtBlock.BlockID || id == GrassBlock.BlockID) 19 | { 20 | dimension.SetBlockID(coordinates, FarmlandBlock.BlockID); 21 | dimension.BlockRepository.GetBlockProvider(FarmlandBlock.BlockID).BlockPlaced( 22 | new BlockDescriptor { Coordinates = coordinates }, face, dimension, user); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /TrueCraft/TerrainGen/Biomes/SwamplandBiome.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.TerrainGen.Biomes 6 | { 7 | public class SwamplandBiome : BiomeProvider 8 | { 9 | public override byte ID 10 | { 11 | get { return (byte)Biome.Swampland; } 12 | } 13 | 14 | public override double Temperature 15 | { 16 | get { return 0.8f; } 17 | } 18 | 19 | public override double Rainfall 20 | { 21 | get { return 0.9f; } 22 | } 23 | 24 | public override TreeSpecies[] Trees 25 | { 26 | get 27 | { 28 | return new TreeSpecies[0]; 29 | } 30 | } 31 | 32 | public override PlantSpecies[] Plants 33 | { 34 | get 35 | { 36 | return new[] { PlantSpecies.SugarCane, PlantSpecies.TallGrass }; 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/TNTBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class TNTBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x2E; 8 | 9 | public override byte ID { get { return 0x2E; } } 10 | 11 | public override double BlastResistance { get { return 0; } } 12 | 13 | public override double Hardness { get { return 0; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "TNT"; 20 | } 21 | 22 | public override SoundEffectClass SoundEffect 23 | { 24 | get 25 | { 26 | return SoundEffectClass.Grass; 27 | } 28 | } 29 | 30 | public override Tuple GetTextureMap(byte metadata) 31 | { 32 | return new Tuple(8, 0); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /lib/osx-x64/SDL2.dll.LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2020 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | -------------------------------------------------------------------------------- /TrueCraft.Core/Inventory/ISlot.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | 4 | namespace TrueCraft.Core.Inventory 5 | { 6 | public interface ISlot : INotifyPropertyChanged 7 | { 8 | /// 9 | /// Determines how many of the "other" items can be accepted by this Slot. 10 | /// 11 | /// The "other" items which we may want to add to this Slot. 12 | /// The number of the "other" items which may be added. Zero will 13 | /// be returned if the items are not compatible with the Slot. Items may not be 14 | /// compatible if the slot already has some items in it, or if it is, for example, 15 | /// an armor slot. Zero will be returned if the Slot is already full. 16 | int CanAccept(ItemStack other); 17 | 18 | /// 19 | /// Gets or sets the ItemStack stored in this inventory Slot. 20 | /// 21 | ItemStack Item { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/DirtBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class DirtBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x03; 8 | 9 | public override byte ID { get { return 0x03; } } 10 | 11 | public override double BlastResistance { get { return 2.5; } } 12 | 13 | public override double Hardness { get { return 0.5; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Dirt"; 20 | } 21 | 22 | public override SoundEffectClass SoundEffect 23 | { 24 | get 25 | { 26 | return SoundEffectClass.Gravel; 27 | } 28 | } 29 | 30 | public override Tuple GetTextureMap(byte metadata) 31 | { 32 | return new Tuple(2, 0); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/SpongeBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class SpongeBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x13; 8 | 9 | public override byte ID { get { return 0x13; } } 10 | 11 | public override double BlastResistance { get { return 3; } } 12 | 13 | public override double Hardness { get { return 0.6; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Sponge"; 20 | } 21 | 22 | public override SoundEffectClass SoundEffect 23 | { 24 | get 25 | { 26 | return SoundEffectClass.Grass; 27 | } 28 | } 29 | 30 | public override Tuple GetTextureMap(byte metadata) 31 | { 32 | return new Tuple(0, 3); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/LightningPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Spawns lightning at the given coordinates. 7 | /// 8 | public struct LightningPacket : IPacket 9 | { 10 | public byte ID { get { return 0x47; } } 11 | 12 | public int EntityID; 13 | public int X, Y, Z; 14 | 15 | public void ReadPacket(IMinecraftStream stream) 16 | { 17 | EntityID = stream.ReadInt32(); 18 | stream.ReadBoolean(); // Unknown 19 | X = stream.ReadInt32(); 20 | Y = stream.ReadInt32(); 21 | Z = stream.ReadInt32(); 22 | } 23 | 24 | public void WritePacket(IMinecraftStream stream) 25 | { 26 | stream.WriteInt32(EntityID); 27 | stream.WriteBoolean(true); // Unknown 28 | stream.WriteInt32(X); 29 | stream.WriteInt32(Y); 30 | stream.WriteInt32(Z); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/SoulSandBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class SoulSandBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x58; 8 | 9 | public override byte ID { get { return 0x58; } } 10 | 11 | public override double BlastResistance { get { return 2.5; } } 12 | 13 | public override double Hardness { get { return 0.5; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Soul Sand"; 20 | } 21 | 22 | public override SoundEffectClass SoundEffect 23 | { 24 | get 25 | { 26 | return SoundEffectClass.Sand; 27 | } 28 | } 29 | 30 | public override Tuple GetTextureMap(byte metadata) 31 | { 32 | return new Tuple(8, 6); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Metadata/MetadataByte.cs: -------------------------------------------------------------------------------- 1 | using TrueCraft.Core.Networking; 2 | 3 | namespace TrueCraft.Core 4 | { 5 | public class MetadataByte : MetadataEntry 6 | { 7 | public override byte Identifier { get { return 0; } } 8 | public override string FriendlyName { get { return "byte"; } } 9 | 10 | public byte Value; 11 | 12 | public static implicit operator MetadataByte(byte value) 13 | { 14 | return new MetadataByte(value); 15 | } 16 | 17 | public MetadataByte() 18 | { 19 | } 20 | 21 | public MetadataByte(byte value) 22 | { 23 | Value = value; 24 | } 25 | 26 | public override void FromStream(IMinecraftStream stream) 27 | { 28 | Value = stream.ReadUInt8(); 29 | } 30 | 31 | public override void WriteTo(IMinecraftStream stream, byte index) 32 | { 33 | stream.WriteUInt8(GetKey(index)); 34 | stream.WriteUInt8(Value); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/BlockFace.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core 4 | { 5 | /// 6 | /// Enumerates the directions of block faces. 7 | /// 8 | public enum BlockFace 9 | { 10 | /// 11 | /// The block face points towards -Y. 12 | /// 13 | NegativeY = 0, 14 | 15 | /// 16 | /// The block face points towards +Y. 17 | /// 18 | PositiveY = 1, 19 | 20 | /// 21 | /// The block face points towards -Z. 22 | /// 23 | NegativeZ = 2, 24 | 25 | /// 26 | /// The block face points towards +Z. 27 | /// 28 | PositiveZ = 3, 29 | 30 | /// 31 | /// The block face points towards -X. 32 | /// 33 | NegativeX = 4, 34 | 35 | /// 36 | /// The block face points towards +X. 37 | /// 38 | PositiveX = 5 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/HandshakeResponsePacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent from servers to continue with a connection. A kick is sent instead if the connection is refused. 7 | /// 8 | public struct HandshakeResponsePacket : IPacket 9 | { 10 | public byte ID { get { return 0x02; } } 11 | 12 | public HandshakeResponsePacket(string connectionHash) 13 | { 14 | ConnectionHash = connectionHash; 15 | } 16 | 17 | /// 18 | /// Set to "-" for offline mode servers. Online mode beta servers are obsolete. 19 | /// 20 | public string ConnectionHash; 21 | 22 | public void ReadPacket(IMinecraftStream stream) 23 | { 24 | ConnectionHash = stream.ReadString(); 25 | } 26 | 27 | public void WritePacket(IMinecraftStream stream) 28 | { 29 | stream.WriteString(ConnectionHash); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Metadata/MetadataInt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Networking; 3 | 4 | namespace TrueCraft.Core 5 | { 6 | public class MetadataInt : MetadataEntry 7 | { 8 | public override byte Identifier { get { return 2; } } 9 | public override string FriendlyName { get { return "int"; } } 10 | 11 | public int Value; 12 | 13 | public static implicit operator MetadataInt(int value) 14 | { 15 | return new MetadataInt(value); 16 | } 17 | 18 | public MetadataInt() 19 | { 20 | } 21 | 22 | public MetadataInt(int value) 23 | { 24 | Value = value; 25 | } 26 | 27 | public override void FromStream(IMinecraftStream stream) 28 | { 29 | Value = stream.ReadInt32(); 30 | } 31 | 32 | public override void WriteTo(IMinecraftStream stream, byte index) 33 | { 34 | stream.WriteUInt8(GetKey(index)); 35 | stream.WriteInt32(Value); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/SeedsItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | using TrueCraft.Core.Logic.Blocks; 4 | using TrueCraft.Core.Networking; 5 | using TrueCraft.Core.World; 6 | 7 | namespace TrueCraft.Core.Logic.Items 8 | { 9 | public class SeedsItem : ItemProvider 10 | { 11 | public static readonly short ItemID = 0x127; 12 | 13 | public SeedsItem(XmlNode node) : base(node) 14 | { 15 | } 16 | 17 | public override void ItemUsedOnBlock(GlobalVoxelCoordinates coordinates, ItemStack item, BlockFace face, IDimension dimension, IRemoteClient user) 18 | { 19 | if (dimension.GetBlockID(coordinates) == FarmlandBlock.BlockID) 20 | { 21 | dimension.SetBlockID(coordinates + MathHelper.BlockFaceToCoordinates(face), CropsBlock.BlockID); 22 | dimension.BlockRepository.GetBlockProvider(CropsBlock.BlockID).BlockPlaced( 23 | new BlockDescriptor { Coordinates = coordinates }, face, dimension, user); 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/CollectItemPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent by servers to show the animation of an item entity being collected by a player. 7 | /// 8 | public struct CollectItemPacket : IPacket 9 | { 10 | public byte ID { get { return 0x16; } } 11 | 12 | public int CollectedItemID; 13 | public int CollectorID; 14 | 15 | public CollectItemPacket(int collectedItemID, int collectorID) 16 | { 17 | CollectedItemID = collectedItemID; 18 | CollectorID = collectorID; 19 | } 20 | 21 | public void ReadPacket(IMinecraftStream stream) 22 | { 23 | CollectedItemID = stream.ReadInt32(); 24 | CollectorID = stream.ReadInt32(); 25 | } 26 | 27 | public void WritePacket(IMinecraftStream stream) 28 | { 29 | stream.WriteInt32(CollectedItemID); 30 | stream.WriteInt32(CollectorID); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/SpawnPositionPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent by the server to specify the coordinates of the spawn point. This only affects what the 7 | /// compass item points to. 8 | /// 9 | public struct SpawnPositionPacket : IPacket 10 | { 11 | public byte ID { get { return 0x06; } } 12 | 13 | public SpawnPositionPacket(int x, int y, int z) 14 | { 15 | X = x; 16 | Y = y; 17 | Z = z; 18 | } 19 | 20 | public int X, Y, Z; 21 | 22 | public void ReadPacket(IMinecraftStream stream) 23 | { 24 | X = stream.ReadInt32(); 25 | Y = stream.ReadInt32(); 26 | Z = stream.ReadInt32(); 27 | } 28 | 29 | public void WritePacket(IMinecraftStream stream) 30 | { 31 | stream.WriteInt32(X); 32 | stream.WriteInt32(Y); 33 | stream.WriteInt32(Z); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Metadata/MetadataFloat.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Networking; 3 | 4 | namespace TrueCraft.Core 5 | { 6 | public class MetadataFloat : MetadataEntry 7 | { 8 | public override byte Identifier { get { return 3; } } 9 | public override string FriendlyName { get { return "float"; } } 10 | 11 | public float Value; 12 | 13 | public static implicit operator MetadataFloat(float value) 14 | { 15 | return new MetadataFloat(value); 16 | } 17 | 18 | public MetadataFloat() 19 | { 20 | } 21 | 22 | public MetadataFloat(float value) 23 | { 24 | Value = value; 25 | } 26 | 27 | public override void FromStream(IMinecraftStream stream) 28 | { 29 | Value = stream.ReadSingle(); 30 | } 31 | 32 | public override void WriteTo(IMinecraftStream stream, byte index) 33 | { 34 | stream.WriteUInt8(GetKey(index)); 35 | stream.WriteSingle(Value); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Metadata/MetadataShort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Networking; 3 | 4 | namespace TrueCraft.Core 5 | { 6 | public class MetadataShort : MetadataEntry 7 | { 8 | public override byte Identifier { get { return 1; } } 9 | public override string FriendlyName { get { return "short"; } } 10 | 11 | public short Value; 12 | 13 | public static implicit operator MetadataShort(short value) 14 | { 15 | return new MetadataShort(value); 16 | } 17 | 18 | public MetadataShort() 19 | { 20 | } 21 | 22 | public MetadataShort(short value) 23 | { 24 | Value = value; 25 | } 26 | 27 | public override void FromStream(IMinecraftStream stream) 28 | { 29 | Value = stream.ReadInt16(); 30 | } 31 | 32 | public override void WriteTo(IMinecraftStream stream, byte index) 33 | { 34 | stream.WriteUInt8(GetKey(index)); 35 | stream.WriteInt16(Value); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /TrueCraft.Client/Input/KeyboardKeyEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework.Input; 3 | 4 | namespace TrueCraft.Client.Input 5 | { 6 | /// 7 | /// Provides the event data for keyboard key events. 8 | /// 9 | public class KeyboardKeyEventArgs : KeyboardEventArgs 10 | { 11 | /// 12 | /// Gets the key for the event. 13 | /// 14 | public Keys Key { get; private set; } 15 | 16 | /// 17 | /// Gets whether the key was pressed or released. 18 | /// 19 | public bool IsPressed { get; private set; } 20 | 21 | /// 22 | /// Creates new keyboard key event data. 23 | /// 24 | /// The key for the event. 25 | /// Whether the key was pressed or released. 26 | public KeyboardKeyEventArgs(Keys key, bool isPressed) 27 | { 28 | Key = key; 29 | IsPressed = isPressed; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/EntityStatusPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Gives updates to what entities are doing. 7 | /// 8 | public struct EntityStatusPacket : IPacket 9 | { 10 | public enum EntityStatus 11 | { 12 | EntityHurt = 2, 13 | EntityKilled = 3, 14 | WolfTaming = 6, 15 | WolfTamed = 7, 16 | WolfShaking = 8, 17 | EatingAccepted = 9 // what 18 | } 19 | 20 | public byte ID { get { return 0x26; } } 21 | 22 | public int EntityID; 23 | public EntityStatus Status; 24 | 25 | public void ReadPacket(IMinecraftStream stream) 26 | { 27 | EntityID = stream.ReadInt32(); 28 | Status = (EntityStatus)stream.ReadInt8(); 29 | } 30 | 31 | public void WritePacket(IMinecraftStream stream) 32 | { 33 | stream.WriteInt32(EntityID); 34 | stream.WriteInt8((sbyte)Status); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/MonsterSpawnerBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class MonsterSpawnerBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x34; 8 | 9 | public override byte ID { get { return 0x34; } } 10 | 11 | public override double BlastResistance { get { return 25; } } 12 | 13 | public override double Hardness { get { return 5; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override bool Opaque { get { return false; } } 18 | 19 | public override string GetDisplayName(short metadata) 20 | { 21 | return "Monster Spawner"; 22 | } 23 | 24 | public override Tuple GetTextureMap(byte metadata) 25 | { 26 | return new Tuple(1, 4); 27 | } 28 | 29 | protected override ItemStack[] GetDrop(BlockDescriptor descriptor, ItemStack item) 30 | { 31 | return new ItemStack[0]; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/LeverBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class LeverBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x45; 8 | 9 | public override byte ID { get { return 0x45; } } 10 | 11 | public override double BlastResistance { get { return 2.5; } } 12 | 13 | public override double Hardness { get { return 0.5; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override bool Opaque { get { return false; } } 18 | 19 | public override string GetDisplayName(short metadata) 20 | { 21 | return "Lever"; 22 | } 23 | 24 | public override SoundEffectClass SoundEffect 25 | { 26 | get 27 | { 28 | return SoundEffectClass.Wood; 29 | } 30 | } 31 | 32 | public override Tuple GetTextureMap(byte metadata) 33 | { 34 | return new Tuple(0, 6); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/PortalBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class PortalBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x5A; 8 | 9 | public override byte ID { get { return 0x5A; } } 10 | 11 | public override double BlastResistance { get { return 0; } } 12 | 13 | public override double Hardness { get { return -1; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override bool Opaque { get { return false; } } 18 | 19 | public override string GetDisplayName(short metadata) 20 | { 21 | return "Portal"; 22 | } 23 | 24 | public override SoundEffectClass SoundEffect 25 | { 26 | get 27 | { 28 | return SoundEffectClass.Glass; 29 | } 30 | } 31 | 32 | public override Tuple GetTextureMap(byte metadata) 33 | { 34 | return new Tuple(14, 0); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/WoolBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class WoolBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x23; 8 | 9 | public override byte ID { get { return 0x23; } } 10 | 11 | public override double BlastResistance { get { return 4; } } 12 | 13 | public override double Hardness { get { return 0.8; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Wool"; 20 | } 21 | 22 | public override bool Flammable { get { return true; } } 23 | 24 | public override SoundEffectClass SoundEffect 25 | { 26 | get 27 | { 28 | return SoundEffectClass.Cloth; 29 | } 30 | } 31 | 32 | public override Tuple GetTextureMap(byte metadata) 33 | { 34 | return new Tuple(0, 4); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/PlantSpecies.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace TrueCraft.Core 7 | { 8 | /// 9 | /// Enumerates the different species of plants in TrueCraft. 10 | /// 11 | public enum PlantSpecies 12 | { 13 | /// 14 | /// Rose flower. 15 | /// 16 | Rose, 17 | 18 | /// 19 | /// Dandelion flower. 20 | /// 21 | Dandelion, 22 | 23 | /// 24 | /// Tall grass. 25 | /// 26 | TallGrass, 27 | 28 | /// 29 | /// Fern. 30 | /// 31 | Fern, 32 | 33 | /// 34 | /// Dead bush. 35 | /// 36 | Deadbush, 37 | 38 | /// 39 | /// Cactus. 40 | /// 41 | Cactus, 42 | 43 | /// 44 | /// Sugarcane. 45 | /// 46 | SugarCane, 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/EntityLookAndRelativeMovePacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | public struct EntityLookAndRelativeMovePacket : IPacket 6 | { 7 | public byte ID { get { return 0x21; } } 8 | 9 | public int EntityID; 10 | public sbyte DeltaX, DeltaY, DeltaZ; 11 | public sbyte Yaw, Pitch; 12 | 13 | public void ReadPacket(IMinecraftStream stream) 14 | { 15 | EntityID = stream.ReadInt32(); 16 | DeltaX = stream.ReadInt8(); 17 | DeltaY = stream.ReadInt8(); 18 | DeltaZ = stream.ReadInt8(); 19 | Yaw = stream.ReadInt8(); 20 | Pitch = stream.ReadInt8(); 21 | } 22 | 23 | public void WritePacket(IMinecraftStream stream) 24 | { 25 | stream.WriteInt32(EntityID); 26 | stream.WriteInt8(DeltaX); 27 | stream.WriteInt8(DeltaY); 28 | stream.WriteInt8(DeltaZ); 29 | stream.WriteInt8(Yaw); 30 | stream.WriteInt8(Pitch); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/GiantZombieEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Server; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Entities 6 | { 7 | public class GiantZombieEntity : ZombieEntity 8 | { 9 | public GiantZombieEntity(IDimension dimension, IEntityManager entityManager) : 10 | base(dimension, entityManager) 11 | { 12 | } 13 | 14 | public override Size Size 15 | { 16 | get 17 | { 18 | return new Size(0.6, 1.8, 0.6) * 6; 19 | } 20 | } 21 | 22 | public override short MaxHealth 23 | { 24 | get 25 | { 26 | return 100; 27 | } 28 | } 29 | 30 | public override sbyte MobType 31 | { 32 | get 33 | { 34 | return 53; 35 | } 36 | } 37 | 38 | public override bool Friendly 39 | { 40 | get 41 | { 42 | return false; 43 | } 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Drew DeVault 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /TrueCraft.Client/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("TrueCraft.Client")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("sircmpwn")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /TrueCraft.Core/Entities/FallingBlockEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Networking; 3 | using TrueCraft.Core.Networking.Packets; 4 | using TrueCraft.Core.World; 5 | using TrueCraft.Core.Physics; 6 | using TrueCraft.Core.Server; 7 | 8 | namespace TrueCraft.Core.Entities 9 | { 10 | public abstract class FallingBlockEntity : ObjectEntity 11 | { 12 | public FallingBlockEntity(IDimension dimension, IEntityManager entityManager, 13 | Vector3 position) : 14 | base(dimension, entityManager, new Size(0.98), 0.8f, 0.40f, 39.2f) 15 | { 16 | _position = position + new Vector3(0.5); 17 | } 18 | 19 | public override IPacket SpawnPacket 20 | { 21 | get 22 | { 23 | return new SpawnGenericEntityPacket(EntityID, (sbyte)EntityType, 24 | MathHelper.CreateAbsoluteInt(Position.X), MathHelper.CreateAbsoluteInt(Position.Y), 25 | MathHelper.CreateAbsoluteInt(Position.Z)); 26 | } 27 | } 28 | 29 | public override int Data { get { return 1; } } 30 | } 31 | } -------------------------------------------------------------------------------- /TrueCraft.Launcher/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("TrueCraft.Launcher")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("sircmpwn")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /TrueCraft.Profiling/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("TrueCraft.Profiling")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("sircmpwn")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /TrueCraft.Core/AI/PriorityQueue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace TrueCraft.Core.AI 5 | { 6 | // TODO: Replace this with something better eventually 7 | // Thanks to www.redblobgames.com/pathfinding/a-star/implementation.html 8 | public class PriorityQueue 9 | { 10 | private List> elements = new List>(); 11 | 12 | public int Count 13 | { 14 | get { return elements.Count; } 15 | } 16 | 17 | public void Enqueue(T item, double priority) 18 | { 19 | elements.Add(Tuple.Create(item, priority)); 20 | } 21 | 22 | public T Dequeue() 23 | { 24 | int bestIndex = 0; 25 | 26 | for (int i = 0; i < elements.Count; i++) { 27 | if (elements[i].Item2 < elements[bestIndex].Item2) { 28 | bestIndex = i; 29 | } 30 | } 31 | 32 | T bestItem = elements[bestIndex].Item1; 33 | elements.RemoveAt(bestIndex); 34 | return bestItem; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/ChunkPreamblePacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Used to allocate or unload chunks. 7 | /// 8 | public struct ChunkPreamblePacket : IPacket 9 | { 10 | public byte ID { get { return 0x32; } } 11 | 12 | public ChunkPreamblePacket(int x, int z, bool load = true) 13 | { 14 | X = x; 15 | Z = z; 16 | Load = load; 17 | } 18 | 19 | public int X, Z; 20 | /// 21 | /// If false, free the chunk. If true, allocate it. 22 | /// 23 | public bool Load; 24 | 25 | public void ReadPacket(IMinecraftStream stream) 26 | { 27 | X = stream.ReadInt32(); 28 | Z = stream.ReadInt32(); 29 | Load = stream.ReadBoolean(); 30 | } 31 | 32 | public void WritePacket(IMinecraftStream stream) 33 | { 34 | stream.WriteInt32(X); 35 | stream.WriteInt32(Z); 36 | stream.WriteBoolean(Load); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/UseBedPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent by servers to indicate that a player is using a bed. More research required on this packet. 7 | /// 8 | public struct UseBedPacket : IPacket 9 | { 10 | public byte ID { get { return 0x11; } } 11 | 12 | public int EntityID; 13 | public bool InBed; 14 | public int X; 15 | public sbyte Y; 16 | public int Z; 17 | 18 | public void ReadPacket(IMinecraftStream stream) 19 | { 20 | EntityID = stream.ReadInt32(); 21 | InBed = stream.ReadBoolean(); 22 | X = stream.ReadInt32(); 23 | Y = stream.ReadInt8(); 24 | Z = stream.ReadInt32(); 25 | } 26 | 27 | public void WritePacket(IMinecraftStream stream) 28 | { 29 | stream.WriteInt32(EntityID); 30 | stream.WriteBoolean(InBed); 31 | stream.WriteInt32(X); 32 | stream.WriteInt8(Y); 33 | stream.WriteInt32(Z); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /TrueCraft.Client/Modelling/ModellerEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Client.Rendering; 3 | 4 | namespace TrueCraft.Client.Modelling 5 | { 6 | /// 7 | /// 8 | /// 9 | /// 10 | public sealed class ModellerEventArgs : EventArgs 11 | { 12 | /// 13 | /// 14 | /// 15 | public T Item { get; private set; } 16 | 17 | /// 18 | /// 19 | /// 20 | public MeshBase Result { get; private set; } 21 | 22 | /// 23 | /// 24 | /// 25 | public bool IsPriority { get; private set; } 26 | 27 | /// 28 | /// 29 | /// 30 | /// 31 | /// 32 | /// 33 | public ModellerEventArgs(T item, MeshBase result, bool isPriority) 34 | { 35 | Item = item; 36 | Result = result; 37 | IsPriority = isPriority; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /TrueCraft/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("TrueCraft")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("sircmpwn")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | [assembly:InternalsVisibleTo("TrueCraft.Test")] -------------------------------------------------------------------------------- /Test/TrueCraft.Test/World/RegionTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Reflection; 5 | using NUnit.Framework; 6 | using TrueCraft.Core.World; 7 | using TrueCraft.World; 8 | 9 | namespace TrueCraft.Test.World 10 | { 11 | [TestFixture] 12 | public class RegionTest 13 | { 14 | private Region? _region; 15 | 16 | [OneTimeSetUp] 17 | public void SetUp() 18 | { 19 | string assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!; 20 | _region = new Region(RegionCoordinates.Zero, 21 | Path.Combine(assemblyDir, "Files")); 22 | } 23 | 24 | [Test] 25 | public void TestGetChunk() 26 | { 27 | IChunk? chunk = _region!.GetChunk(LocalChunkCoordinates.Zero); 28 | 29 | // No chunk was added, and Region must not generate chunks. 30 | Assert.IsNull(chunk); 31 | } 32 | 33 | [Test] 34 | public void TestGetRegionFileName() 35 | { 36 | Assert.AreEqual("r.0.0.mcr", Region.GetRegionFileName(_region!.Position)); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Inventory/SlotFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using TrueCraft.Core.Logic; 4 | 5 | namespace TrueCraft.Core.Inventory 6 | { 7 | public class SlotFactory : ISlotFactory where T : ISlot 8 | { 9 | // NOTE this must be initialized by a call to RegisterSlotFactory 10 | // prior to using any methods in this class. Otherwise, 11 | // a NullReferenceException will occur. 12 | private static ISlotFactory _impl = null!; 13 | 14 | public static void RegisterSlotFactory(ISlotFactory slotFactory) 15 | { 16 | _impl = slotFactory; 17 | } 18 | 19 | public static ISlotFactory Get() 20 | { 21 | return _impl; 22 | } 23 | 24 | public SlotFactory() 25 | { 26 | } 27 | 28 | public T GetSlot(IItemRepository itemRepository) 29 | { 30 | return _impl.GetSlot(itemRepository); 31 | } 32 | 33 | public List GetSlots(IItemRepository itemRepository, int count) 34 | { 35 | return _impl.GetSlots(itemRepository, count); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /TrueCraft/TerrainGen/Biomes/SavannaBiome.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.TerrainGen.Biomes 6 | { 7 | public class SavannaBiome : BiomeProvider 8 | { 9 | public override byte ID 10 | { 11 | get { return (byte)Biome.Savanna; } 12 | } 13 | 14 | public override double Temperature 15 | { 16 | get { return 1.2f; } 17 | } 18 | 19 | public override double Rainfall 20 | { 21 | get { return 0.0f; } 22 | } 23 | 24 | public override TreeSpecies[] Trees 25 | { 26 | get 27 | { 28 | return new[] { TreeSpecies.Oak }; 29 | } 30 | } 31 | 32 | public override PlantSpecies[] Plants 33 | { 34 | get 35 | { 36 | return new[] { PlantSpecies.Deadbush, PlantSpecies.Fern }; 37 | } 38 | } 39 | 40 | public override double TreeDensity 41 | { 42 | get 43 | { 44 | return 50; 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/ArmorMaterial.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace TrueCraft.Core 7 | { 8 | /// 9 | /// Enumerates the materials armor can be crafted from. 10 | /// 11 | /// 12 | /// 13 | /// Note that the values in this enum must correspond to values in the 14 | /// armorMaterialType in the TrueCraft.xsd. 15 | /// 16 | /// 17 | public enum ArmorMaterial 18 | { 19 | /// 20 | /// The armor is made of leather. 21 | /// 22 | Leather, 23 | 24 | /// 25 | /// The armor is made of chain (fire). 26 | /// 27 | Chain, 28 | 29 | /// 30 | /// The armor is made of iron ingots. 31 | /// 32 | Iron, 33 | 34 | /// 35 | /// The armor is made of gold ingots. 36 | /// 37 | Gold, 38 | 39 | /// 40 | /// The armor is made of diamonds. 41 | /// 42 | Diamond 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/EntityVelocityPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent by servers to inform players of changes to the velocity of entities. 7 | /// Not sure exactly how all of that works, but I know it's going to be a pain in the ass. 8 | /// 9 | public struct EntityVelocityPacket : IPacket 10 | { 11 | public byte ID { get { return 0x1C; } } 12 | 13 | public int EntityID; 14 | public short XVelocity; 15 | public short YVelocity; 16 | public short ZVelocity; 17 | 18 | public void ReadPacket(IMinecraftStream stream) 19 | { 20 | EntityID = stream.ReadInt32(); 21 | XVelocity = stream.ReadInt16(); 22 | YVelocity = stream.ReadInt16(); 23 | ZVelocity = stream.ReadInt16(); 24 | } 25 | 26 | public void WritePacket(IMinecraftStream stream) 27 | { 28 | stream.WriteInt32(EntityID); 29 | stream.WriteInt16(XVelocity); 30 | stream.WriteInt16(YVelocity); 31 | stream.WriteInt16(ZVelocity); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /TrueCraft.Client/Handlers/ActionConfirmation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace TrueCraft.Client.Handlers 3 | { 4 | /// 5 | /// Encapsulates the action to be taken when a TransactionStatusPacket is received. 6 | /// 7 | public class ActionConfirmation 8 | { 9 | private static int _nextActionNumber = 1; 10 | 11 | private readonly int _actionNumber; 12 | 13 | private Action _action; 14 | 15 | public static ActionConfirmation GetActionConfirmation(Action action) 16 | { 17 | ActionConfirmation rv = new ActionConfirmation(_nextActionNumber, action); 18 | _nextActionNumber++; 19 | if ((_nextActionNumber & 0xffff8000) != 0) 20 | _nextActionNumber = 1; 21 | 22 | return rv; 23 | } 24 | 25 | private ActionConfirmation(int actionNumber, Action action) 26 | { 27 | _actionNumber = actionNumber; 28 | _action = action; 29 | } 30 | 31 | public short ActionNumber { get => (short)_actionNumber; } 32 | 33 | public void TakeAction() 34 | { 35 | _action(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/SignItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | using TrueCraft.Core.Logic.Blocks; 4 | using TrueCraft.Core.Networking; 5 | using TrueCraft.Core.World; 6 | 7 | namespace TrueCraft.Core.Logic.Items 8 | { 9 | public class SignItem : ItemProvider 10 | { 11 | public static readonly short ItemID = 0x143; 12 | 13 | public SignItem(XmlNode node) : base(node) 14 | { 15 | } 16 | 17 | public override void ItemUsedOnBlock(GlobalVoxelCoordinates coordinates, ItemStack item, BlockFace face, IDimension dimension, IRemoteClient user) 18 | { 19 | if (face == BlockFace.PositiveY) 20 | { 21 | var provider = dimension.BlockRepository.GetBlockProvider(UprightSignBlock.BlockID); 22 | (provider as IItemProvider).ItemUsedOnBlock(coordinates, item, face, dimension, user); 23 | } 24 | else 25 | { 26 | var provider = dimension.BlockRepository.GetBlockProvider(WallSignBlock.BlockID); 27 | (provider as IItemProvider).ItemUsedOnBlock(coordinates, item, face, dimension, user); 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/CakeItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | using TrueCraft.Core.Logic.Blocks; 4 | using TrueCraft.Core.Networking; 5 | using TrueCraft.Core.Server; 6 | using TrueCraft.Core.World; 7 | 8 | namespace TrueCraft.Core.Logic.Items 9 | { 10 | public class CakeItem : FoodItem // TODO: This is a special sort of FoodItem that isn't fully consumed. 11 | { 12 | public static readonly short ItemID = 0x162; 13 | 14 | public CakeItem(XmlNode node) : base(node) 15 | { 16 | } 17 | 18 | public override void ItemUsedOnBlock(GlobalVoxelCoordinates coordinates, ItemStack item, BlockFace face, IDimension dimension, IRemoteClient user) 19 | { 20 | ServerOnly.Assert(); 21 | 22 | coordinates += MathHelper.BlockFaceToCoordinates(face); 23 | var old = dimension.BlockRepository.GetBlockProvider(dimension.GetBlockID(coordinates)); 24 | if (old.Hardness == 0) 25 | { 26 | dimension.SetBlockID(coordinates, CakeBlock.BlockID); 27 | item.Count--; 28 | user.Hotbar[user.SelectedSlot].Item = item; 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Items/RedstoneItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | using TrueCraft.Core.Logic.Blocks; 4 | using TrueCraft.Core.Networking; 5 | using TrueCraft.Core.Server; 6 | using TrueCraft.Core.World; 7 | 8 | namespace TrueCraft.Core.Logic.Items 9 | { 10 | public class RedstoneItem : ItemProvider 11 | { 12 | public static readonly short ItemID = 0x14B; 13 | 14 | public RedstoneItem(XmlNode node) : base(node) 15 | { 16 | } 17 | 18 | public override void ItemUsedOnBlock(GlobalVoxelCoordinates coordinates, ItemStack item, BlockFace face, IDimension dimension, IRemoteClient user) 19 | { 20 | ServerOnly.Assert(); 21 | 22 | coordinates += MathHelper.BlockFaceToCoordinates(face); 23 | IBlockProvider supportingBlock = dimension.BlockRepository.GetBlockProvider(dimension.GetBlockID(coordinates + Vector3i.Down)); 24 | 25 | if (supportingBlock.Opaque) 26 | { 27 | dimension.SetBlockID(coordinates, RedstoneDustBlock.BlockID); 28 | item.Count--; 29 | user.Hotbar[user.SelectedSlot].Item = item; 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/AnimationPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | public struct AnimationPacket : IPacket 6 | { 7 | public enum PlayerAnimation 8 | { 9 | None = 0, 10 | SwingArm = 1, 11 | TakeDamage = 2, 12 | LeaveBed = 3, 13 | Unknown = 102, 14 | Crouch = 104, 15 | Uncrouch = 105, 16 | } 17 | 18 | public byte ID { get { return 0x12; } } 19 | 20 | public int EntityID; 21 | public PlayerAnimation Animation; 22 | 23 | public AnimationPacket(int entityID, PlayerAnimation animation) 24 | { 25 | EntityID = entityID; 26 | Animation = animation; 27 | } 28 | 29 | public void ReadPacket(IMinecraftStream stream) 30 | { 31 | EntityID = stream.ReadInt32(); 32 | Animation = (PlayerAnimation)stream.ReadInt8(); 33 | } 34 | 35 | public void WritePacket(IMinecraftStream stream) 36 | { 37 | stream.WriteInt32(EntityID); 38 | stream.WriteInt8((sbyte)Animation); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/DispenserBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core.Networking; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.Core.Logic.Blocks 6 | { 7 | public class DispenserBlock : BlockProvider 8 | { 9 | public static readonly byte BlockID = 0x17; 10 | 11 | public override byte ID { get { return 0x17; } } 12 | 13 | public override double BlastResistance { get { return 17.5; } } 14 | 15 | public override double Hardness { get { return 3.5; } } 16 | 17 | public override byte Luminance { get { return 0; } } 18 | 19 | public override string GetDisplayName(short metadata) 20 | { 21 | return "Dispenser"; 22 | } 23 | 24 | public override Tuple GetTextureMap(byte metadata) 25 | { 26 | return new Tuple(13, 2); 27 | } 28 | 29 | public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IDimension dimension, IRemoteClient user) 30 | { 31 | dimension.SetMetadata(descriptor.Coordinates, (byte)MathHelper.DirectionByRotationFlat(user.Entity!.Yaw, true)); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /TrueCraft/TerrainGen/Biomes/RainforestBiome.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TrueCraft.Core; 3 | using TrueCraft.Core.World; 4 | 5 | namespace TrueCraft.TerrainGen.Biomes 6 | { 7 | public class RainforestBiome : BiomeProvider 8 | { 9 | public override byte ID 10 | { 11 | get { return (byte)Biome.Rainforest; } 12 | } 13 | 14 | public override double Temperature 15 | { 16 | get { return 1.2f; } 17 | } 18 | 19 | public override double Rainfall 20 | { 21 | get { return 0.9f; } 22 | } 23 | 24 | public override TreeSpecies[] Trees 25 | { 26 | get 27 | { 28 | return new[] { TreeSpecies.Birch, TreeSpecies.Oak }; 29 | } 30 | } 31 | 32 | public override double TreeDensity 33 | { 34 | get 35 | { 36 | return 2; 37 | } 38 | } 39 | 40 | public override PlantSpecies[] Plants 41 | { 42 | get 43 | { 44 | return new[] { PlantSpecies.Fern, PlantSpecies.TallGrass }; 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/BookshelfBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class BookshelfBlock : BlockProvider, IBurnableItem 6 | { 7 | public static readonly byte BlockID = 0x2F; 8 | 9 | public override byte ID { get { return 0x2F; } } 10 | 11 | public override double BlastResistance { get { return 7.5; } } 12 | 13 | public override double Hardness { get { return 1.5; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Bookshelf"; 20 | } 21 | 22 | public TimeSpan BurnTime { get { return TimeSpan.FromSeconds(15); } } 23 | 24 | public override SoundEffectClass SoundEffect 25 | { 26 | get 27 | { 28 | return SoundEffectClass.Wood; 29 | } 30 | } 31 | 32 | public override bool Flammable { get { return true; } } 33 | 34 | public override Tuple GetTextureMap(byte metadata) 35 | { 36 | return new Tuple(3, 2); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/LockedChestBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class LockedChestBlock : BlockProvider, IBurnableItem 6 | { 7 | public static readonly byte BlockID = 0x5F; 8 | 9 | public override byte ID { get { return 0x5F; } } 10 | 11 | public override double BlastResistance { get { return 0; } } 12 | 13 | public override double Hardness { get { return 0; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override bool Opaque { get { return false; } } 18 | 19 | public override string GetDisplayName(short metadata) 20 | { 21 | return "Locked Chest"; 22 | } 23 | 24 | public TimeSpan BurnTime { get { return TimeSpan.FromSeconds(15); } } 25 | 26 | public override SoundEffectClass SoundEffect 27 | { 28 | get 29 | { 30 | return SoundEffectClass.Wood; 31 | } 32 | } 33 | 34 | public override Tuple GetTextureMap(byte metadata) 35 | { 36 | return new Tuple(10, 1); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/WoodenPlanksBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class WoodenPlanksBlock : BlockProvider, IBurnableItem 6 | { 7 | public static readonly byte BlockID = 0x05; 8 | 9 | public override byte ID { get { return 0x05; } } 10 | 11 | public override double BlastResistance { get { return 15; } } 12 | 13 | public override double Hardness { get { return 2; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Wooden Planks"; 20 | } 21 | 22 | public override bool Flammable { get { return true; } } 23 | 24 | public TimeSpan BurnTime { get { return TimeSpan.FromSeconds(15); } } 25 | 26 | public override SoundEffectClass SoundEffect 27 | { 28 | get 29 | { 30 | return SoundEffectClass.Wood; 31 | } 32 | } 33 | 34 | public override Tuple GetTextureMap(byte metadata) 35 | { 36 | return new Tuple(4, 0); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /TrueCraft.Core/Logic/Blocks/ObsidianBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Logic.Blocks 4 | { 5 | public class ObsidianBlock : BlockProvider 6 | { 7 | public static readonly byte BlockID = 0x31; 8 | 9 | public override byte ID { get { return 0x31; } } 10 | 11 | public override double BlastResistance { get { return 6000; } } 12 | 13 | public override double Hardness { get { return 10; } } 14 | 15 | public override byte Luminance { get { return 0; } } 16 | 17 | public override string GetDisplayName(short metadata) 18 | { 19 | return "Obsidian"; 20 | } 21 | 22 | public override Tuple GetTextureMap(byte metadata) 23 | { 24 | return new Tuple(5, 2); 25 | } 26 | 27 | public override ToolMaterial EffectiveToolMaterials 28 | { 29 | get 30 | { 31 | return ToolMaterial.Diamond; 32 | } 33 | } 34 | 35 | public override ToolType EffectiveTools 36 | { 37 | get 38 | { 39 | return ToolType.Pickaxe; 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /TrueCraft.Core/Networking/Packets/LoginRequestPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TrueCraft.Core.Networking.Packets 4 | { 5 | /// 6 | /// Sent by clients after the handshake to request logging into the world. 7 | /// 8 | public struct LoginRequestPacket : IPacket 9 | { 10 | public byte ID { get { return 0x01; } } 11 | 12 | public LoginRequestPacket(int protocolVersion, string username) 13 | { 14 | ProtocolVersion = protocolVersion; 15 | Username = username; 16 | } 17 | 18 | public int ProtocolVersion; 19 | public string Username; 20 | 21 | public void ReadPacket(IMinecraftStream stream) 22 | { 23 | ProtocolVersion = stream.ReadInt32(); 24 | Username = stream.ReadString(); 25 | stream.ReadInt64(); // Unused 26 | stream.ReadInt8(); // Unused 27 | } 28 | 29 | public void WritePacket(IMinecraftStream stream) 30 | { 31 | stream.WriteInt32(ProtocolVersion); 32 | stream.WriteString(Username); 33 | stream.WriteInt64(0); // Unused 34 | stream.WriteInt8(0); // Unused 35 | } 36 | } 37 | } --------------------------------------------------------------------------------