items: all armor items, turtle helmet, elytra

This commit is contained in:
Bixilon 2022-12-17 23:34:28 +01:00
parent 2e6a600f08
commit 7777ea9ff0
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
29 changed files with 627 additions and 116 deletions

View File

@ -16,15 +16,15 @@ package de.bixilon.minosoft.data.container.slots.equipment
import de.bixilon.minosoft.data.container.ArmorSlots
import de.bixilon.minosoft.data.container.Container
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
object ChestSlotType : EquipmentSlotType {
override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean {
val item = stack.item.item
if (item !is ArmorItem) {
if (item !is WearableItem) {
return false
}
return item.equipmentSlot == ArmorSlots.CHEST && super.canPut(container, slot, stack)
return ArmorSlots.CHEST in item.armorSlot && super.canPut(container, slot, stack)
}
}

View File

@ -16,15 +16,15 @@ package de.bixilon.minosoft.data.container.slots.equipment
import de.bixilon.minosoft.data.container.ArmorSlots
import de.bixilon.minosoft.data.container.Container
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
object FeetSlotType : EquipmentSlotType {
override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean {
val item = stack.item.item
if (item !is ArmorItem) {
if (item !is WearableItem) {
return false
}
return item.equipmentSlot == ArmorSlots.FEET && super.canPut(container, slot, stack)
return ArmorSlots.FEET in item.armorSlot && super.canPut(container, slot, stack)
}
}

View File

@ -17,18 +17,18 @@ import de.bixilon.minosoft.data.container.ArmorSlots
import de.bixilon.minosoft.data.container.Container
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.registries.blocks.MinecraftBlocks
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
object HeadSlotType : EquipmentSlotType {
override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean {
val item = stack.item.item
if (item.resourceLocation == MinecraftBlocks.CARVED_PUMPKIN) {
if (item.resourceLocation == MinecraftBlocks.CARVED_PUMPKIN) { // TODO: remove edge case and implement carved pumpkin as wearable item
return super.canPut(container, slot, stack)
}
if (item !is ArmorItem) {
if (item !is WearableItem) {
return false
}
return item.equipmentSlot == ArmorSlots.HEAD && super.canPut(container, slot, stack)
return ArmorSlots.HEAD in item.armorSlot && super.canPut(container, slot, stack)
}
}

View File

@ -16,15 +16,15 @@ package de.bixilon.minosoft.data.container.slots.equipment
import de.bixilon.minosoft.data.container.ArmorSlots
import de.bixilon.minosoft.data.container.Container
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
object LegsSlotType : EquipmentSlotType {
override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean {
val item = stack.item.item
if (item !is ArmorItem) {
if (item !is WearableItem) {
return false
}
return item.equipmentSlot == ArmorSlots.LEGS && super.canPut(container, slot, stack)
return ArmorSlots.LEGS in item.armorSlot && super.canPut(container, slot, stack)
}
}

View File

@ -36,6 +36,8 @@ class DisplayProperty(
val lore by observedList(lore) // ToDo: Lock
var _customDisplayName = customDisplayName
var customDisplayName by InventoryDelegate(stack, this::_customDisplayName)
@Deprecated("Should belong in DyeableItem")
var _dyeColor = dyedColor
var dyeColor by InventoryDelegate(stack, this::_dyeColor)

View File

@ -43,7 +43,7 @@ import de.bixilon.minosoft.data.registries.enchantment.Enchantment
import de.bixilon.minosoft.data.registries.entities.EntityType
import de.bixilon.minosoft.data.registries.fluid.fluids.Fluid
import de.bixilon.minosoft.data.registries.fluid.fluids.flowable.FlowableFluid
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.data.registries.item.items.armor.DefendingItem
import de.bixilon.minosoft.data.registries.particle.data.BlockParticleData
import de.bixilon.minosoft.data.registries.shapes.AABB
import de.bixilon.minosoft.data.text.ChatComponent
@ -573,9 +573,8 @@ abstract class Entity(
for (equipment in equipment.unsafe.values) {
val item = equipment.item.item
if (item is ArmorItem) {
// could also be a pumpkin or just trash
protectionLevel += item.protection
if (item is DefendingItem) {
protectionLevel += item.defense
}
}
this.equipment.lock.release()

View File

@ -32,7 +32,7 @@ import de.bixilon.minosoft.data.entities.entities.SynchronizedEntityData
import de.bixilon.minosoft.data.entities.entities.player.additional.PlayerAdditional
import de.bixilon.minosoft.data.entities.entities.player.properties.PlayerProperties
import de.bixilon.minosoft.data.registries.entities.EntityType
import de.bixilon.minosoft.data.registries.item.items.armor.DyeableArmorItem
import de.bixilon.minosoft.data.registries.item.items.dye.DyeableItem
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
import de.bixilon.minosoft.data.world.World
@ -133,7 +133,7 @@ abstract class PlayerEntity(
return ChatColors.GREEN
}
val chestPlate = equipment[EquipmentSlots.CHEST]
if (chestPlate != null && chestPlate.item.item is DyeableArmorItem) {
if (chestPlate != null && chestPlate.item.item is DyeableItem) {
chestPlate._display?.dyeColor?.let { return it }
}
val formattingCode = additional.team?.formattingCode

View File

@ -57,8 +57,8 @@ import de.bixilon.minosoft.data.registries.effects.attributes.DefaultStatusEffec
import de.bixilon.minosoft.data.registries.effects.attributes.EntityAttribute
import de.bixilon.minosoft.data.registries.effects.movement.MovementEffect
import de.bixilon.minosoft.data.registries.enchantment.armor.ArmorEnchantment
import de.bixilon.minosoft.data.registries.item.MinecraftItems
import de.bixilon.minosoft.data.registries.item.items.Item
import de.bixilon.minosoft.data.registries.item.items.armor.materials.LeatherArmor
import de.bixilon.minosoft.data.registries.shapes.AABB
import de.bixilon.minosoft.data.tags.DefaultBlockTags
import de.bixilon.minosoft.data.tags.Tag
@ -363,7 +363,7 @@ class LocalPlayerEntity(
}
private fun adjustVelocityForClimbing(velocity: Vec3d): Vec3d {
if ((this.horizontalCollision || isJumping) && (isClimbing || connection.world[positionInfo.blockPosition]?.block == MinecraftBlocks.POWDER_SNOW && equipment[EquipmentSlots.FEET]?.item?.item?.resourceLocation == MinecraftItems.LEATHER_BOOTS)) {
if ((this.horizontalCollision || isJumping) && (isClimbing || connection.world[positionInfo.blockPosition]?.block == MinecraftBlocks.POWDER_SNOW && equipment[EquipmentSlots.FEET]?.item?.item is LeatherArmor.LeatherBoots)) {
return Vec3d(velocity.x, 0.2, velocity.z)
}
return velocity

View File

@ -39,7 +39,7 @@ interface ArmorEnchantment : SlotSpecificEnchantment {
EquipmentSlots.HEAD -> ArmorSlots.HEAD
else -> return false
}
if (item.equipmentSlot != armorSlot) {
if (armorSlot !in item.armorSlot) {
return false
}
return armorSlot in this.slots

View File

@ -17,7 +17,6 @@ import de.bixilon.minosoft.util.KUtil.toResourceLocation
@Deprecated("item factories")
object MinecraftItems {
val LEATHER_BOOTS = "minecraft:leather_boots".toResourceLocation()
val LAPISLAZULI = "minecraft:lapis_lazuli".toResourceLocation()
val EGG = "minecraft:egg".toResourceLocation()
val COAL = "minecraft:coal".toResourceLocation()

View File

@ -17,6 +17,9 @@ import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.factory.DefaultFactory
import de.bixilon.minosoft.data.registries.integrated.IntegratedRegistry
import de.bixilon.minosoft.data.registries.item.items.Item
import de.bixilon.minosoft.data.registries.item.items.armor.extra.ElytraItem
import de.bixilon.minosoft.data.registries.item.items.armor.extra.TurtleHelmet
import de.bixilon.minosoft.data.registries.item.items.armor.materials.*
import de.bixilon.minosoft.data.registries.item.items.bucket.BucketItem
import de.bixilon.minosoft.data.registries.item.items.bucket.FilledBucketItem
import de.bixilon.minosoft.data.registries.item.items.food.AppleItem
@ -30,6 +33,39 @@ object ItemFactories : DefaultFactory<ItemFactory<*>>(
BucketItem.EmptyBucketItem,
FilledBucketItem.LavaBucketItem,
FilledBucketItem.WaterBucketItem,
LeatherArmor.LeatherBoots,
LeatherArmor.LeatherChestplate,
LeatherArmor.LeatherLeggings,
LeatherArmor.LeatherHelmet,
ChainmailArmor.ChainmailBoots,
ChainmailArmor.ChainmailChestplate,
ChainmailArmor.ChainmailLeggings,
ChainmailArmor.ChainmailHelmet,
IronArmor.IronBoots,
IronArmor.IronChestplate,
IronArmor.IronLeggings,
IronArmor.IronHelmet,
GoldArmor.GoldBoots,
GoldArmor.GoldChestplate,
GoldArmor.GoldLeggings,
GoldArmor.GoldHelmet,
DiamondArmor.DiamondBoots,
DiamondArmor.DiamondChestplate,
DiamondArmor.DiamondLeggings,
DiamondArmor.DiamondHelmet,
NetheriteArmor.NetheriteBoots,
NetheriteArmor.NetheriteChestplate,
NetheriteArmor.NetheriteLeggings,
NetheriteArmor.NetheriteHelmet,
TurtleHelmet,
ElytraItem,
), IntegratedRegistry<Item> {
override fun build(name: ResourceLocation, registries: Registries): Item? {

View File

@ -33,7 +33,6 @@ object PixLyzerItemFactories : DefaultClassFactory<PixLyzerItemFactory<*>>(
SpawnEggItem,
DyeItem,
HorseArmorItem,
ShieldItem,
MusicDiscItem,
@ -46,12 +45,6 @@ object PixLyzerItemFactories : DefaultClassFactory<PixLyzerItemFactory<*>>(
HoeItem,
AxeItem,
ArmorItem,
DyeableArmorItem,
DyeableHorseArmorItem,
ElytraItem,
LingeringPotionItem,
FireChargeItem,
ExperienceBottleItem,

View File

@ -13,28 +13,9 @@
package de.bixilon.minosoft.data.registries.item.items.armor
import de.bixilon.kutil.cast.CastUtil.unsafeCast
import de.bixilon.kutil.primitive.FloatUtil.toFloat
import de.bixilon.minosoft.data.container.ArmorSlots
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.item.factory.PixLyzerItemFactory
import de.bixilon.minosoft.data.registries.item.items.PixLyzerItem
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.data.registries.item.items.Item
open class ArmorItem(
abstract class ArmorItem(
resourceLocation: ResourceLocation,
registries: Registries,
data: Map<String, Any>,
) : PixLyzerItem(resourceLocation, registries, data) {
val protection = data["defense"].toFloat()
val toughness = data["toughness"].toFloat()
val equipmentSlot = data["equipment_slot"].unsafeCast<String>().let { ArmorSlots[it] }
val knockbackResistance = data["knockback_resistance"]?.toFloat() ?: 0.0f
companion object : PixLyzerItemFactory<ArmorItem> {
override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>): ArmorItem {
return ArmorItem(resourceLocation, registries, data)
}
}
}
) : Item(resourceLocation), WearableItem, DefendingItem

View File

@ -13,21 +13,6 @@
package de.bixilon.minosoft.data.registries.item.items.armor
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.item.factory.PixLyzerItemFactory
import de.bixilon.minosoft.data.registries.item.items.PixLyzerItem
import de.bixilon.minosoft.data.registries.registries.Registries
open class DyeableHorseArmorItem(
resourceLocation: ResourceLocation,
registries: Registries,
data: Map<String, Any>,
) : PixLyzerItem(resourceLocation, registries, data) {
companion object : PixLyzerItemFactory<DyeableHorseArmorItem> {
override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>): DyeableHorseArmorItem {
return DyeableHorseArmorItem(resourceLocation, registries, data)
}
}
interface DefendingItem {
val defense: Int
}

View File

@ -13,21 +13,8 @@
package de.bixilon.minosoft.data.registries.item.items.armor
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.item.factory.PixLyzerItemFactory
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.data.container.ArmorSlots
open class DyeableArmorItem(
resourceLocation: ResourceLocation,
registries: Registries,
data: Map<String, Any>,
) : ArmorItem(resourceLocation, registries, data) {
companion object : PixLyzerItemFactory<DyeableArmorItem> {
override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>): DyeableArmorItem {
return DyeableArmorItem(resourceLocation, registries, data)
}
}
interface WearableItem {
val armorSlot: Set<ArmorSlots> get() = ArmorSlots.ALL
}

View File

@ -11,24 +11,21 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.armor
package de.bixilon.minosoft.data.registries.item.items.armor.extra
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.item.factory.PixLyzerItemFactory
import de.bixilon.minosoft.data.registries.item.items.PixLyzerItem
import de.bixilon.minosoft.data.registries.item.factory.ItemFactory
import de.bixilon.minosoft.data.registries.item.items.Item
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.ChestplateItem
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.util.KUtil.minecraft
open class ElytraItem(
resourceLocation: ResourceLocation,
registries: Registries,
data: Map<String, Any>,
) : PixLyzerItem(resourceLocation, registries, data) {
open class ElytraItem(resourceLocation: ResourceLocation = this.resourceLocation) : Item(resourceLocation), WearableItem, ChestplateItem {
companion object : ItemFactory<ElytraItem> {
override val resourceLocation = minecraft("elytra")
companion object : PixLyzerItemFactory<ElytraItem> {
override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>): ElytraItem {
return ElytraItem(resourceLocation, registries, data)
}
override fun build(registries: Registries) = ElytraItem()
}
}

View File

@ -11,27 +11,23 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.armor
package de.bixilon.minosoft.data.registries.item.items.armor.extra
import de.bixilon.kutil.cast.CastUtil.nullCast
import de.bixilon.kutil.primitive.IntUtil.toInt
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.item.factory.PixLyzerItemFactory
import de.bixilon.minosoft.data.registries.item.items.PixLyzerItem
import de.bixilon.minosoft.data.registries.item.factory.ItemFactory
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.data.registries.item.items.armor.DefendingItem
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.HelmetItem
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.util.KUtil.minecraft
open class HorseArmorItem(
resourceLocation: ResourceLocation,
registries: Registries,
data: Map<String, Any>,
) : PixLyzerItem(resourceLocation, registries, data) {
val horseProtection = data["horse_protection"]?.toInt() ?: 0
val horseTexture = data["horse_texture"]?.nullCast<String>()
open class TurtleHelmet(resourceLocation: ResourceLocation = this.resourceLocation) : ArmorItem(resourceLocation), WearableItem, DefendingItem, HelmetItem {
override val defense: Int get() = 2
companion object : PixLyzerItemFactory<HorseArmorItem> {
companion object : ItemFactory<TurtleHelmet> {
override val resourceLocation = minecraft("turtle_helmet")
override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>): HorseArmorItem {
return HorseArmorItem(resourceLocation, registries, data)
}
override fun build(registries: Registries) = TurtleHelmet()
}
}

View File

@ -0,0 +1,70 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.armor.materials
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.item.factory.ItemFactory
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.data.registries.item.items.armor.DefendingItem
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.BootsItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.ChestplateItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.HelmetItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.LeggingsItem
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.util.KUtil.minecraft
abstract class ChainmailArmor(resourceLocation: ResourceLocation) : ArmorItem(resourceLocation), WearableItem, DefendingItem {
open class ChainmailBoots(resourceLocation: ResourceLocation = this.resourceLocation) : ChainmailArmor(resourceLocation), BootsItem {
override val defense: Int get() = 1
companion object : ItemFactory<ChainmailBoots> {
override val resourceLocation = minecraft("chainmail_boots")
override fun build(registries: Registries) = ChainmailBoots()
}
}
open class ChainmailLeggings(resourceLocation: ResourceLocation = this.resourceLocation) : ChainmailArmor(resourceLocation), LeggingsItem {
override val defense: Int get() = 4
companion object : ItemFactory<ChainmailLeggings> {
override val resourceLocation = minecraft("chainmail_leggings")
override fun build(registries: Registries) = ChainmailLeggings()
}
}
open class ChainmailChestplate(resourceLocation: ResourceLocation = this.resourceLocation) : ChainmailArmor(resourceLocation), ChestplateItem {
override val defense: Int get() = 5
companion object : ItemFactory<ChainmailChestplate> {
override val resourceLocation = minecraft("chainmail_chestplate")
override fun build(registries: Registries) = ChainmailChestplate()
}
}
open class ChainmailHelmet(resourceLocation: ResourceLocation = this.resourceLocation) : ChainmailArmor(resourceLocation), HelmetItem {
override val defense: Int get() = 2
companion object : ItemFactory<ChainmailHelmet> {
override val resourceLocation = minecraft("chainmail_helmet")
override fun build(registries: Registries) = ChainmailHelmet()
}
}
}

View File

@ -0,0 +1,70 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.armor.materials
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.item.factory.ItemFactory
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.data.registries.item.items.armor.DefendingItem
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.BootsItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.ChestplateItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.HelmetItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.LeggingsItem
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.util.KUtil.minecraft
abstract class DiamondArmor(resourceLocation: ResourceLocation) : ArmorItem(resourceLocation), WearableItem, DefendingItem {
open class DiamondBoots(resourceLocation: ResourceLocation = this.resourceLocation) : DiamondArmor(resourceLocation), BootsItem {
override val defense: Int get() = 3
companion object : ItemFactory<DiamondBoots> {
override val resourceLocation = minecraft("diamond_boots")
override fun build(registries: Registries) = DiamondBoots()
}
}
open class DiamondLeggings(resourceLocation: ResourceLocation = this.resourceLocation) : DiamondArmor(resourceLocation), LeggingsItem {
override val defense: Int get() = 6
companion object : ItemFactory<DiamondLeggings> {
override val resourceLocation = minecraft("diamond_leggings")
override fun build(registries: Registries) = DiamondLeggings()
}
}
open class DiamondChestplate(resourceLocation: ResourceLocation = this.resourceLocation) : DiamondArmor(resourceLocation), ChestplateItem {
override val defense: Int get() = 8
companion object : ItemFactory<DiamondChestplate> {
override val resourceLocation = minecraft("diamond_chestplate")
override fun build(registries: Registries) = DiamondChestplate()
}
}
open class DiamondHelmet(resourceLocation: ResourceLocation = this.resourceLocation) : DiamondArmor(resourceLocation), HelmetItem {
override val defense: Int get() = 3
companion object : ItemFactory<DiamondHelmet> {
override val resourceLocation = minecraft("diamond_helmet")
override fun build(registries: Registries) = DiamondHelmet()
}
}
}

View File

@ -0,0 +1,70 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.armor.materials
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.item.factory.ItemFactory
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.data.registries.item.items.armor.DefendingItem
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.BootsItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.ChestplateItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.HelmetItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.LeggingsItem
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.util.KUtil.minecraft
abstract class GoldArmor(resourceLocation: ResourceLocation) : ArmorItem(resourceLocation), WearableItem, DefendingItem {
open class GoldBoots(resourceLocation: ResourceLocation = this.resourceLocation) : GoldArmor(resourceLocation), BootsItem {
override val defense: Int get() = 1
companion object : ItemFactory<GoldBoots> {
override val resourceLocation = minecraft("gold_boots")
override fun build(registries: Registries) = GoldBoots()
}
}
open class GoldLeggings(resourceLocation: ResourceLocation = this.resourceLocation) : GoldArmor(resourceLocation), LeggingsItem {
override val defense: Int get() = 3
companion object : ItemFactory<GoldLeggings> {
override val resourceLocation = minecraft("gold_leggings")
override fun build(registries: Registries) = GoldLeggings()
}
}
open class GoldChestplate(resourceLocation: ResourceLocation = this.resourceLocation) : GoldArmor(resourceLocation), ChestplateItem {
override val defense: Int get() = 5
companion object : ItemFactory<GoldChestplate> {
override val resourceLocation = minecraft("gold_chestplate")
override fun build(registries: Registries) = GoldChestplate()
}
}
open class GoldHelmet(resourceLocation: ResourceLocation = this.resourceLocation) : GoldArmor(resourceLocation), HelmetItem {
override val defense: Int get() = 2
companion object : ItemFactory<GoldHelmet> {
override val resourceLocation = minecraft("gold_helmet")
override fun build(registries: Registries) = GoldHelmet()
}
}
}

View File

@ -0,0 +1,70 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.armor.materials
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.item.factory.ItemFactory
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.data.registries.item.items.armor.DefendingItem
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.BootsItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.ChestplateItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.HelmetItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.LeggingsItem
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.util.KUtil.minecraft
abstract class IronArmor(resourceLocation: ResourceLocation) : ArmorItem(resourceLocation), WearableItem, DefendingItem {
open class IronBoots(resourceLocation: ResourceLocation = this.resourceLocation) : IronArmor(resourceLocation), BootsItem {
override val defense: Int get() = 2
companion object : ItemFactory<IronBoots> {
override val resourceLocation = minecraft("iron_boots")
override fun build(registries: Registries) = IronBoots()
}
}
open class IronLeggings(resourceLocation: ResourceLocation = this.resourceLocation) : IronArmor(resourceLocation), LeggingsItem {
override val defense: Int get() = 5
companion object : ItemFactory<IronLeggings> {
override val resourceLocation = minecraft("iron_leggings")
override fun build(registries: Registries) = IronLeggings()
}
}
open class IronChestplate(resourceLocation: ResourceLocation = this.resourceLocation) : IronArmor(resourceLocation), ChestplateItem {
override val defense: Int get() = 6
companion object : ItemFactory<IronChestplate> {
override val resourceLocation = minecraft("iron_chestplate")
override fun build(registries: Registries) = IronChestplate()
}
}
open class IronHelmet(resourceLocation: ResourceLocation = this.resourceLocation) : IronArmor(resourceLocation), HelmetItem {
override val defense: Int get() = 2
companion object : ItemFactory<IronHelmet> {
override val resourceLocation = minecraft("iron_helmet")
override fun build(registries: Registries) = IronHelmet()
}
}
}

View File

@ -0,0 +1,71 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.armor.materials
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.item.factory.ItemFactory
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.data.registries.item.items.armor.DefendingItem
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.BootsItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.ChestplateItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.HelmetItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.LeggingsItem
import de.bixilon.minosoft.data.registries.item.items.dye.DyeableItem
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.util.KUtil.minecraft
abstract class LeatherArmor(resourceLocation: ResourceLocation) : ArmorItem(resourceLocation), WearableItem, DefendingItem, DyeableItem {
open class LeatherBoots(resourceLocation: ResourceLocation = this.resourceLocation) : LeatherArmor(resourceLocation), BootsItem {
override val defense: Int get() = 1
companion object : ItemFactory<LeatherBoots> {
override val resourceLocation = minecraft("leather_boots")
override fun build(registries: Registries) = LeatherBoots()
}
}
open class LeatherLeggings(resourceLocation: ResourceLocation = this.resourceLocation) : LeatherArmor(resourceLocation), LeggingsItem {
override val defense: Int get() = 2
companion object : ItemFactory<LeatherLeggings> {
override val resourceLocation = minecraft("leather_leggings")
override fun build(registries: Registries) = LeatherLeggings()
}
}
open class LeatherChestplate(resourceLocation: ResourceLocation = this.resourceLocation) : LeatherArmor(resourceLocation), ChestplateItem {
override val defense: Int get() = 3
companion object : ItemFactory<LeatherChestplate> {
override val resourceLocation = minecraft("leather_chestplate")
override fun build(registries: Registries) = LeatherChestplate()
}
}
open class LeatherHelmet(resourceLocation: ResourceLocation = this.resourceLocation) : LeatherArmor(resourceLocation), HelmetItem {
override val defense: Int get() = 1
companion object : ItemFactory<LeatherHelmet> {
override val resourceLocation = minecraft("leather_helmet")
override fun build(registries: Registries) = LeatherHelmet()
}
}
}

View File

@ -0,0 +1,70 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.armor.materials
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.item.factory.ItemFactory
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.data.registries.item.items.armor.DefendingItem
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.BootsItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.ChestplateItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.HelmetItem
import de.bixilon.minosoft.data.registries.item.items.armor.slots.LeggingsItem
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.util.KUtil.minecraft
abstract class NetheriteArmor(resourceLocation: ResourceLocation) : ArmorItem(resourceLocation), WearableItem, DefendingItem {
open class NetheriteBoots(resourceLocation: ResourceLocation = this.resourceLocation) : NetheriteArmor(resourceLocation), BootsItem {
override val defense: Int get() = 3
companion object : ItemFactory<NetheriteBoots> {
override val resourceLocation = minecraft("netherite_boots")
override fun build(registries: Registries) = NetheriteBoots()
}
}
open class NetheriteLeggings(resourceLocation: ResourceLocation = this.resourceLocation) : NetheriteArmor(resourceLocation), LeggingsItem {
override val defense: Int get() = 6
companion object : ItemFactory<NetheriteLeggings> {
override val resourceLocation = minecraft("netherite_leggings")
override fun build(registries: Registries) = NetheriteLeggings()
}
}
open class NetheriteChestplate(resourceLocation: ResourceLocation = this.resourceLocation) : NetheriteArmor(resourceLocation), ChestplateItem {
override val defense: Int get() = 8
companion object : ItemFactory<NetheriteChestplate> {
override val resourceLocation = minecraft("netherite_chestplate")
override fun build(registries: Registries) = NetheriteChestplate()
}
}
open class NetheriteHelmet(resourceLocation: ResourceLocation = this.resourceLocation) : NetheriteArmor(resourceLocation), HelmetItem {
override val defense: Int get() = 3
companion object : ItemFactory<NetheriteHelmet> {
override val resourceLocation = minecraft("netherite_helmet")
override fun build(registries: Registries) = NetheriteHelmet()
}
}
}

View File

@ -0,0 +1,25 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.armor.slots
import de.bixilon.minosoft.data.container.ArmorSlots
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
interface BootsItem : WearableItem {
override val armorSlot: Set<ArmorSlots> get() = FEET
companion object {
private val FEET = setOf(ArmorSlots.FEET)
}
}

View File

@ -0,0 +1,25 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.armor.slots
import de.bixilon.minosoft.data.container.ArmorSlots
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
interface ChestplateItem : WearableItem {
override val armorSlot: Set<ArmorSlots> get() = CHEST
companion object {
private val CHEST = setOf(ArmorSlots.CHEST)
}
}

View File

@ -0,0 +1,25 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.armor.slots
import de.bixilon.minosoft.data.container.ArmorSlots
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
interface HelmetItem : WearableItem {
override val armorSlot: Set<ArmorSlots> get() = HEAD
companion object {
private val HEAD = setOf(ArmorSlots.HEAD)
}
}

View File

@ -0,0 +1,25 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.armor.slots
import de.bixilon.minosoft.data.container.ArmorSlots
import de.bixilon.minosoft.data.registries.item.items.armor.WearableItem
interface LeggingsItem : WearableItem {
override val armorSlot: Set<ArmorSlots> get() = LEGS
companion object {
private val LEGS = setOf(ArmorSlots.LEGS)
}
}

View File

@ -0,0 +1,16 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.item.items.dye
interface DyeableItem

View File

@ -16,7 +16,6 @@ package de.bixilon.minosoft.gui.rendering.skeletal.instance
import de.bixilon.kotlinglm.func.rad
import de.bixilon.kotlinglm.mat4x4.Mat4
import de.bixilon.kotlinglm.vec3.Vec3
import de.bixilon.kutil.time.TimeUtil
import de.bixilon.kutil.time.TimeUtil.millis
import de.bixilon.minosoft.data.entities.EntityRotation
import de.bixilon.minosoft.gui.rendering.RenderWindow
@ -76,7 +75,7 @@ class SkeletalInstance(
val matrix = Mat4()
.translateAssign(position)
.rotateAssign((180.0f - rotation.yaw).toFloat().rad, Vec3(0, 1, 0))
.translateAssign(Vec3(-0.5, 0, -0.5)) // move to center
.translateAssign(Vec3(-0.5, -0.5, -0.5)) // move to bottom center
if (baseTransform != matrix) {
baseTransform = matrix