bump pixlyer, improve fluid classes

This commit is contained in:
Bixilon 2021-06-16 20:44:18 +02:00
parent cac7d44bb0
commit 7c83342333
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
9 changed files with 194 additions and 11 deletions

View File

@ -0,0 +1,24 @@
/*
* Minosoft
* Copyright (C) 2021 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.fluid
import com.google.gson.JsonObject
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.versions.Registries
class EmptyFluid(
resourceLocation: ResourceLocation,
registries: Registries,
data: JsonObject,
) : Fluid(resourceLocation, registries, data)

View File

@ -14,18 +14,24 @@ package de.bixilon.minosoft.data.registries.fluid
import com.google.gson.JsonObject
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.fluid.lava.FlowingLavaFluid
import de.bixilon.minosoft.data.registries.fluid.lava.StillLavaFluid
import de.bixilon.minosoft.data.registries.fluid.water.FlowingWaterFluid
import de.bixilon.minosoft.data.registries.fluid.water.StillWaterFluid
import de.bixilon.minosoft.data.registries.items.Item
import de.bixilon.minosoft.data.registries.particle.ParticleType
import de.bixilon.minosoft.data.registries.registry.RegistryItem
import de.bixilon.minosoft.data.registries.registry.ResourceLocationDeserializer
import de.bixilon.minosoft.data.registries.versions.Registries
data class Fluid(
open class Fluid(
override val resourceLocation: ResourceLocation,
private val bucketItemId: Int?,
val dripParticle: ParticleType?,
val renderTexture: ResourceLocation?,
registries: Registries,
data: JsonObject,
) : RegistryItem {
private val bucketItemId = data["bucket"]?.asInt
val dripParticle: ParticleType? = data["drip_particle_type"]?.asInt?.let { registries.particleTypeRegistry[it] }
val renderTexture: ResourceLocation? = data["render"]?.asJsonObject?.get("texture")?.asString?.let { ResourceLocation(it) }
var bucketItem: Item? = null
private set
@ -38,14 +44,21 @@ data class Fluid(
}
companion object : ResourceLocationDeserializer<Fluid> {
private val CONSTRUCTORS: Map<String, (resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) -> Fluid> = mapOf(
"EmptyFluid" to { resourceLocation, registries, data -> EmptyFluid(resourceLocation, registries, data) },
"WaterFluid\$Flowing" to { resourceLocation, registries, data -> FlowingWaterFluid(resourceLocation, registries, data) },
"WaterFluid\$Still" to { resourceLocation, registries, data -> StillWaterFluid(resourceLocation, registries, data) },
"LavaFluid\$Flowing" to { resourceLocation, registries, data -> FlowingLavaFluid(resourceLocation, registries, data) },
"LavaFluid\$Still" to { resourceLocation, registries, data -> StillLavaFluid(resourceLocation, registries, data) },
)
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Fluid {
check(registries != null) { "Registries is null!" }
return Fluid(
resourceLocation = resourceLocation,
bucketItemId = data["bucket"]?.asInt,
dripParticle = data["drip_particle_type"]?.asInt?.let { registries.particleTypeRegistry[it] },
renderTexture = data["render"]?.asJsonObject?.get("texture")?.asString?.let { ResourceLocation(it) },
)
CONSTRUCTORS[data["class"]?.asString]?.let {
return it.invoke(resourceLocation, registries, data)
}
return Fluid(resourceLocation, registries, data)
}
}
}

View File

@ -0,0 +1,24 @@
/*
* Minosoft
* Copyright (C) 2021 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.fluid.lava
import com.google.gson.JsonObject
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.versions.Registries
class FlowingLavaFluid(
resourceLocation: ResourceLocation,
registries: Registries,
data: JsonObject,
) : LavaFluid(resourceLocation, registries, data)

View File

@ -0,0 +1,25 @@
/*
* Minosoft
* Copyright (C) 2021 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.fluid.lava
import com.google.gson.JsonObject
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.fluid.Fluid
import de.bixilon.minosoft.data.registries.versions.Registries
abstract class LavaFluid(
resourceLocation: ResourceLocation,
registries: Registries,
data: JsonObject,
) : Fluid(resourceLocation, registries, data)

View File

@ -0,0 +1,24 @@
/*
* Minosoft
* Copyright (C) 2021 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.fluid.lava
import com.google.gson.JsonObject
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.versions.Registries
class StillLavaFluid(
resourceLocation: ResourceLocation,
registries: Registries,
data: JsonObject,
) : LavaFluid(resourceLocation, registries, data)

View File

@ -0,0 +1,24 @@
/*
* Minosoft
* Copyright (C) 2021 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.fluid.water
import com.google.gson.JsonObject
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.versions.Registries
class FlowingWaterFluid(
resourceLocation: ResourceLocation,
registries: Registries,
data: JsonObject,
) : WaterFluid(resourceLocation, registries, data)

View File

@ -0,0 +1,24 @@
/*
* Minosoft
* Copyright (C) 2021 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.fluid.water
import com.google.gson.JsonObject
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.versions.Registries
class StillWaterFluid(
resourceLocation: ResourceLocation,
registries: Registries,
data: JsonObject,
) : WaterFluid(resourceLocation, registries, data)

View File

@ -0,0 +1,25 @@
/*
* Minosoft
* Copyright (C) 2021 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.fluid.water
import com.google.gson.JsonObject
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.fluid.Fluid
import de.bixilon.minosoft.data.registries.versions.Registries
abstract class WaterFluid(
resourceLocation: ResourceLocation,
registries: Registries,
data: JsonObject,
) : Fluid(resourceLocation, registries, data)

File diff suppressed because one or more lines are too long