mirror of
https://github.com/chylex/Hardcore-Ender-Expansion-2.git
synced 2025-05-08 06:34:04 +02:00
Reformat code
This commit is contained in:
parent
421cadb545
commit
1a11754bad
README.md
data/src/main/java/chylex/hee/datagen
src/main/java/chylex/hee
Mod.kt
client
VanillaResourceOverrides.kt
gui
GuiAmuletOfRecovery.ktGuiBrewingStandCustom.ktGuiLootChest.ktGuiPortalTokenStorage.ktGuiShulkerBox.ktGuiTrinketPouch.kt
base
model
block
entity
item
render
OverlayRenderer.ktTerritoryRenderer.kt
block
RenderTileAbstractPortal.ktRenderTileDarkChest.ktRenderTileEndPortal.ktRenderTileExperienceGate.ktRenderTileIgneousPlate.ktRenderTileJarODust.ktRenderTileLootChest.ktRenderTileMinersBurialAltar.ktRenderTileShulkerBox.ktRenderTileSpawner.ktRenderTileTable.ktRenderTileTablePedestal.ktRenderTileVoidPortal.kt
entity
RenderEntityBossEnderEye.ktRenderEntityItem.ktRenderEntityItemNoBob.ktRenderEntityMobAbstractEnderman.ktRenderEntityMobAngryEnderman.ktRenderEntityMobBlobby.ktRenderEntityMobSpiderling.ktRenderEntityMobUndread.ktRenderEntityMobVampireBat.ktRenderEntityMobVillagerDying.ktRenderEntityNothing.ktRenderEntityProjectileEyeOfEnder.ktRenderEntitySprite.ktRenderEntityTerritoryLightningBolt.ktRenderEntityTokenHolder.kt
layer
item
territory
sound
commands
game/block
BlockAbstractCauldron.ktBlockAbstractChest.ktBlockAbstractGoo.ktBlockAbstractPortal.ktBlockAbstractTable.ktBlockAbstractTableTile.ktBlockAncientCobweb.ktBlockBrewingStandCustom.ktBlockCauldronWithDragonsBreath.ktBlockCauldronWithGoo.ktBlockCorruptedEnergy.ktBlockDarkChest.ktBlockDeathFlowerDecaying.kt
@ -1,2 +1,3 @@
|
||||
# Hardcore Ender Expansion 2
|
||||
|
||||
Work in progress. PRs will not be accepted before release.
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.datagen
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.datagen.client.BlockItemModels
|
||||
import chylex.hee.datagen.client.BlockModels
|
||||
@ -13,21 +14,21 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD
|
||||
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent
|
||||
|
||||
@SubscribeAllEvents(modid = HEE.ID, bus = MOD)
|
||||
object DataGen{
|
||||
object DataGen {
|
||||
@SubscribeEvent
|
||||
fun register(e: GatherDataEvent){
|
||||
fun register(e: GatherDataEvent) {
|
||||
val modid = HEE.ID
|
||||
val helper = e.existingFileHelper
|
||||
|
||||
with(e.generator){
|
||||
if (e.includeClient()){
|
||||
with(e.generator) {
|
||||
if (e.includeClient()) {
|
||||
addProvider(BlockStates(this, modid, helper))
|
||||
addProvider(BlockModels(this, modid, helper))
|
||||
addProvider(BlockItemModels(this, modid, helper))
|
||||
addProvider(ItemModels(this, modid, helper))
|
||||
}
|
||||
|
||||
if (e.includeServer()){
|
||||
if (e.includeServer()) {
|
||||
addProvider(BlockLootTables(this))
|
||||
addProvider(BlockTags(this))
|
||||
addProvider(ItemTags(this))
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.datagen
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.system.facades.Resource
|
||||
import net.minecraft.block.Block
|
||||
@ -17,58 +18,58 @@ val IForgeRegistryEntry<*>.isVanilla
|
||||
get() = Resource.isVanilla(registryName!!)
|
||||
|
||||
val IItemProvider.r
|
||||
get() = when(this){
|
||||
get() = when(this) {
|
||||
is Block -> resource("block/" + this.path, this.isVanilla)
|
||||
is Item -> resource("item/" + this.path, this.isVanilla)
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
fun IItemProvider.r(suffix: String): ResourceLocation{
|
||||
return when(this){
|
||||
fun IItemProvider.r(suffix: String): ResourceLocation {
|
||||
return when(this) {
|
||||
is Block -> resource("block/" + this.path + suffix, this.isVanilla)
|
||||
is Item -> resource("item/" + this.path + suffix, this.isVanilla)
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
}
|
||||
|
||||
fun resource(path: String, vanilla: Boolean): ResourceLocation{
|
||||
fun resource(path: String, vanilla: Boolean): ResourceLocation {
|
||||
return if (vanilla) Resource.Vanilla(path) else Resource.Custom(path)
|
||||
}
|
||||
|
||||
inline fun <T : IDataProvider> T?.safeUnit(callback: T.() -> Unit){
|
||||
try{
|
||||
inline fun <T : IDataProvider> T?.safeUnit(callback: T.() -> Unit) {
|
||||
try {
|
||||
this?.callback()
|
||||
}catch(e: Exception){
|
||||
} catch(e: Exception) {
|
||||
HEE.log.error("[DataGen] " + e.message)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T : ModelBuilder<T>, U : ModelProvider<T>> U?.safeUnit(callback: U.() -> Unit){
|
||||
try{
|
||||
inline fun <T : ModelBuilder<T>, U : ModelProvider<T>> U?.safeUnit(callback: U.() -> Unit) {
|
||||
try {
|
||||
this?.callback()
|
||||
}catch(e: Exception){
|
||||
} catch(e: Exception) {
|
||||
HEE.log.error("[DataGen] " + e.message)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T : ModelBuilder<T>, U : ModelProvider<T>> U?.safe(callback: U.() -> T): T?{
|
||||
return try{
|
||||
inline fun <T : ModelBuilder<T>, U : ModelProvider<T>> U?.safe(callback: U.() -> T): T? {
|
||||
return try {
|
||||
this?.callback()
|
||||
}catch(e: Exception){
|
||||
} catch(e: Exception) {
|
||||
HEE.log.error("[DataGen] " + e.message)
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T : ModelBuilder<T>> T?.then(callback: T.() -> T): T?{
|
||||
return try{
|
||||
inline fun <T : ModelBuilder<T>> T?.then(callback: T.() -> T): T? {
|
||||
return try {
|
||||
this?.callback()
|
||||
}catch(e: Exception){
|
||||
} catch(e: Exception) {
|
||||
HEE.log.error("[DataGen] " + e.message)
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
class Callback<T>(val item: T, val suffix: String, val path: String){
|
||||
class Callback<T>(val item: T, val suffix: String, val path: String) {
|
||||
override fun toString() = path
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.datagen.client
|
||||
|
||||
import chylex.hee.datagen.client.util.block
|
||||
import chylex.hee.datagen.client.util.multi
|
||||
import chylex.hee.datagen.client.util.override
|
||||
@ -13,8 +14,8 @@ import net.minecraft.data.DataGenerator
|
||||
import net.minecraftforge.client.model.generators.ExistingFileHelper
|
||||
import net.minecraftforge.client.model.generators.ItemModelProvider
|
||||
|
||||
class BlockItemModels(generator: DataGenerator, modid: String, existingFileHelper: ExistingFileHelper) : ItemModelProvider(generator, modid, existingFileHelper){
|
||||
override fun registerModels(){
|
||||
class BlockItemModels(generator: DataGenerator, modid: String, existingFileHelper: ExistingFileHelper) : ItemModelProvider(generator, modid, existingFileHelper) {
|
||||
override fun registerModels() {
|
||||
|
||||
// Blocks: Building (Uncategorized)
|
||||
|
||||
@ -85,12 +86,12 @@ class BlockItemModels(generator: DataGenerator, modid: String, existingFileHelpe
|
||||
// Blocks: Decorative (Plants)
|
||||
|
||||
simple(ModBlocks.DEATH_FLOWER_DECAYING, ModBlocks.DEATH_FLOWER_DECAYING.r("_1")).then {
|
||||
override(ModBlocks.DEATH_FLOWER_DECAYING.asItem().r("_2")){ predicate(Resource.Custom("death_level"), 4F) }
|
||||
override(ModBlocks.DEATH_FLOWER_DECAYING.asItem().r("_3")){ predicate(Resource.Custom("death_level"), 8F) }
|
||||
override(ModBlocks.DEATH_FLOWER_DECAYING.asItem().r("_4")){ predicate(Resource.Custom("death_level"), 12F) }
|
||||
override(ModBlocks.DEATH_FLOWER_DECAYING.asItem().r("_2")) { predicate(Resource.Custom("death_level"), 4F) }
|
||||
override(ModBlocks.DEATH_FLOWER_DECAYING.asItem().r("_3")) { predicate(Resource.Custom("death_level"), 8F) }
|
||||
override(ModBlocks.DEATH_FLOWER_DECAYING.asItem().r("_4")) { predicate(Resource.Custom("death_level"), 12F) }
|
||||
}
|
||||
|
||||
multi(ModBlocks.DEATH_FLOWER_DECAYING, Resource.Vanilla("item/generated"), 1..4){
|
||||
multi(ModBlocks.DEATH_FLOWER_DECAYING, Resource.Vanilla("item/generated"), 1..4) {
|
||||
texture("layer0", Resource.Custom("block/" + it.path))
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.datagen.client
|
||||
|
||||
import chylex.hee.datagen.client.util.cauldron
|
||||
import chylex.hee.datagen.client.util.cross
|
||||
import chylex.hee.datagen.client.util.cube
|
||||
@ -23,8 +24,8 @@ import net.minecraft.data.DataGenerator
|
||||
import net.minecraftforge.client.model.generators.BlockModelProvider
|
||||
import net.minecraftforge.client.model.generators.ExistingFileHelper
|
||||
|
||||
class BlockModels(generator: DataGenerator, modid: String, existingFileHelper: ExistingFileHelper) : BlockModelProvider(generator, modid, existingFileHelper){
|
||||
override fun registerModels(){
|
||||
class BlockModels(generator: DataGenerator, modid: String, existingFileHelper: ExistingFileHelper) : BlockModelProvider(generator, modid, existingFileHelper) {
|
||||
override fun registerModels() {
|
||||
|
||||
// Blocks: Building (Uncategorized)
|
||||
|
||||
@ -60,7 +61,7 @@ class BlockModels(generator: DataGenerator, modid: String, existingFileHelper: E
|
||||
texture("particle", ModBlocks.GRAVE_DIRT_PLAIN.r)
|
||||
}
|
||||
|
||||
multi(ModBlocks.GRAVE_DIRT_LOOT, Resource.Custom("block/grave_dirt_low"), 1..6){
|
||||
multi(ModBlocks.GRAVE_DIRT_LOOT, Resource.Custom("block/grave_dirt_low"), 1..6) {
|
||||
texture("top", Resource.Custom("block/$it"))
|
||||
}
|
||||
|
||||
@ -102,7 +103,7 @@ class BlockModels(generator: DataGenerator, modid: String, existingFileHelper: E
|
||||
|
||||
cubeBottomTop(ModBlocks.EXPERIENCE_GATE, top = ModBlocks.EXPERIENCE_GATE.r("_bottom"))
|
||||
|
||||
multi(ModBlocks.EXPERIENCE_GATE, ModBlocks.EXPERIENCE_GATE.r, arrayOf("_rd1", "_rd2", "_ud")){
|
||||
multi(ModBlocks.EXPERIENCE_GATE, ModBlocks.EXPERIENCE_GATE.r, arrayOf("_rd1", "_rd2", "_ud")) {
|
||||
texture("top", Resource.Custom("block/experience_gate_top" + it.suffix))
|
||||
}
|
||||
|
||||
@ -143,14 +144,14 @@ class BlockModels(generator: DataGenerator, modid: String, existingFileHelper: E
|
||||
|
||||
// Blocks: Decorative (Plants)
|
||||
|
||||
multi(ModBlocks.DEATH_FLOWER_DECAYING, Resource.Vanilla("block/cross"), 1..4){
|
||||
multi(ModBlocks.DEATH_FLOWER_DECAYING, Resource.Vanilla("block/cross"), 1..4) {
|
||||
texture("cross", Resource.Custom("block/$it"))
|
||||
}
|
||||
|
||||
cross(ModBlocks.DEATH_FLOWER_HEALED)
|
||||
cross(ModBlocks.DEATH_FLOWER_WITHERED)
|
||||
|
||||
multi(ModBlocks.POTTED_DEATH_FLOWER_DECAYING, Resource.Vanilla("block/flower_pot_cross"), 1..4){
|
||||
multi(ModBlocks.POTTED_DEATH_FLOWER_DECAYING, Resource.Vanilla("block/flower_pot_cross"), 1..4) {
|
||||
texture("plant", Resource.Custom("block/death_flower" + it.suffix))
|
||||
}
|
||||
|
||||
@ -176,7 +177,7 @@ class BlockModels(generator: DataGenerator, modid: String, existingFileHelper: E
|
||||
|
||||
// Blocks: Tables
|
||||
|
||||
for(tier in 1..3){
|
||||
for(tier in 1..3) {
|
||||
parent("table_tier_$tier", Resource.Custom("block/table")).then {
|
||||
texture("particle", "hee:block/table_base")
|
||||
texture("bottom", "hee:block/table_base")
|
||||
@ -185,20 +186,26 @@ class BlockModels(generator: DataGenerator, modid: String, existingFileHelper: E
|
||||
}
|
||||
}
|
||||
|
||||
parent(ModBlocks.TABLE_BASE_TIER_1, Resource.Custom("block/table_tier_1")).then { Resource.Custom("block/transparent").let {
|
||||
texture("overlay_top", it)
|
||||
texture("overlay_side", it)
|
||||
}}
|
||||
parent(ModBlocks.TABLE_BASE_TIER_1, Resource.Custom("block/table_tier_1")).then {
|
||||
Resource.Custom("block/transparent").let {
|
||||
texture("overlay_top", it)
|
||||
texture("overlay_side", it)
|
||||
}
|
||||
}
|
||||
|
||||
parent(ModBlocks.TABLE_BASE_TIER_2, Resource.Custom("block/table_tier_2")).then { Resource.Custom("block/transparent").let {
|
||||
texture("overlay_top", it)
|
||||
texture("overlay_side", it)
|
||||
}}
|
||||
parent(ModBlocks.TABLE_BASE_TIER_2, Resource.Custom("block/table_tier_2")).then {
|
||||
Resource.Custom("block/transparent").let {
|
||||
texture("overlay_top", it)
|
||||
texture("overlay_side", it)
|
||||
}
|
||||
}
|
||||
|
||||
parent(ModBlocks.TABLE_BASE_TIER_3, Resource.Custom("block/table_tier_3")).then { Resource.Custom("block/transparent").let {
|
||||
texture("overlay_top", it)
|
||||
texture("overlay_side", it)
|
||||
}}
|
||||
parent(ModBlocks.TABLE_BASE_TIER_3, Resource.Custom("block/table_tier_3")).then {
|
||||
Resource.Custom("block/transparent").let {
|
||||
texture("overlay_top", it)
|
||||
texture("overlay_side", it)
|
||||
}
|
||||
}
|
||||
|
||||
table(ModBlocks.ACCUMULATION_TABLE_TIER_1)
|
||||
table(ModBlocks.ACCUMULATION_TABLE_TIER_2)
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.datagen.client
|
||||
|
||||
import chylex.hee.datagen.client.util.cube
|
||||
import chylex.hee.datagen.client.util.log
|
||||
import chylex.hee.datagen.client.util.pillar
|
||||
@ -13,8 +14,8 @@ import net.minecraft.data.DataGenerator
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider
|
||||
import net.minecraftforge.client.model.generators.ExistingFileHelper
|
||||
|
||||
class BlockStates(generator: DataGenerator, modid: String, existingFileHelper: ExistingFileHelper) : BlockStateProvider(generator, modid, existingFileHelper){
|
||||
override fun registerStatesAndModels(){
|
||||
class BlockStates(generator: DataGenerator, modid: String, existingFileHelper: ExistingFileHelper) : BlockStateProvider(generator, modid, existingFileHelper) {
|
||||
override fun registerStatesAndModels() {
|
||||
|
||||
// Blocks: Building (Uncategorized)
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.datagen.client
|
||||
|
||||
import chylex.hee.datagen.client.util.layers
|
||||
import chylex.hee.datagen.client.util.multi
|
||||
import chylex.hee.datagen.client.util.override
|
||||
@ -14,8 +15,8 @@ import net.minecraft.item.Items
|
||||
import net.minecraftforge.client.model.generators.ExistingFileHelper
|
||||
import net.minecraftforge.client.model.generators.ItemModelProvider
|
||||
|
||||
class ItemModels(generator: DataGenerator, modid: String, existingFileHelper: ExistingFileHelper) : ItemModelProvider(generator, modid, existingFileHelper){
|
||||
override fun registerModels(){
|
||||
class ItemModels(generator: DataGenerator, modid: String, existingFileHelper: ExistingFileHelper) : ItemModelProvider(generator, modid, existingFileHelper) {
|
||||
override fun registerModels() {
|
||||
|
||||
// Items: Raw Resources
|
||||
|
||||
@ -54,8 +55,8 @@ class ItemModels(generator: DataGenerator, modid: String, existingFileHelper: Ex
|
||||
simple(ModItems.COMPOST)
|
||||
|
||||
simple(ModItems.VOID_SALAD).then {
|
||||
override(Resource.Custom("item/void_void_salad")){ predicate(Resource.Custom("void_salad_type"), 1F) }
|
||||
override(Resource.Custom("item/mega_void_salad")){ predicate(Resource.Custom("void_salad_type"), 2F) }
|
||||
override(Resource.Custom("item/void_void_salad")) { predicate(Resource.Custom("void_salad_type"), 1F) }
|
||||
override(Resource.Custom("item/mega_void_salad")) { predicate(Resource.Custom("void_salad_type"), 2F) }
|
||||
}
|
||||
|
||||
simple("void_void_salad")
|
||||
@ -79,13 +80,13 @@ class ItemModels(generator: DataGenerator, modid: String, existingFileHelper: Ex
|
||||
simple(ModItems.VOID_MINER)
|
||||
|
||||
simple(ModItems.VOID_BUCKET).then {
|
||||
override(ModItems.VOID_BUCKET.r("_fluid_level_1")){ predicate(Resource.Custom("void_bucket_cooldown"), 0.01F) }
|
||||
override(ModItems.VOID_BUCKET.r("_fluid_level_2")){ predicate(Resource.Custom("void_bucket_cooldown"), 0.3F) }
|
||||
override(ModItems.VOID_BUCKET.r("_fluid_level_3")){ predicate(Resource.Custom("void_bucket_cooldown"), 0.5F) }
|
||||
override(ModItems.VOID_BUCKET.r("_fluid_level_4")){ predicate(Resource.Custom("void_bucket_cooldown"), 0.7F) }
|
||||
override(ModItems.VOID_BUCKET.r("_fluid_level_1")) { predicate(Resource.Custom("void_bucket_cooldown"), 0.01F) }
|
||||
override(ModItems.VOID_BUCKET.r("_fluid_level_2")) { predicate(Resource.Custom("void_bucket_cooldown"), 0.3F) }
|
||||
override(ModItems.VOID_BUCKET.r("_fluid_level_3")) { predicate(Resource.Custom("void_bucket_cooldown"), 0.5F) }
|
||||
override(ModItems.VOID_BUCKET.r("_fluid_level_4")) { predicate(Resource.Custom("void_bucket_cooldown"), 0.7F) }
|
||||
}
|
||||
|
||||
multi(ModItems.VOID_BUCKET, Resource.Vanilla("item/generated"), Array(4){ "_fluid_level_${it + 1}" }){
|
||||
multi(ModItems.VOID_BUCKET, Resource.Vanilla("item/generated"), Array(4) { "_fluid_level_${it + 1}" }) {
|
||||
texture("layer0", Resource.Custom("item/void_bucket"))
|
||||
texture("layer1", Resource.Custom("item/$it"))
|
||||
}
|
||||
@ -104,17 +105,17 @@ class ItemModels(generator: DataGenerator, modid: String, existingFileHelper: Ex
|
||||
// Items: Energy
|
||||
|
||||
layers(ModItems.ENERGY_ORACLE, arrayOf("energy_oracle", "energy_oracle_indicator_inactive")).then {
|
||||
override(ModItems.ENERGY_ORACLE.r("_active_mild")){ predicate(Resource.Custom("activity_intensity"), 0.5F) }
|
||||
override(ModItems.ENERGY_ORACLE.r("_active_full")){ predicate(Resource.Custom("activity_intensity"), 1F) }
|
||||
override(ModItems.ENERGY_ORACLE.r("_active_mild")) { predicate(Resource.Custom("activity_intensity"), 0.5F) }
|
||||
override(ModItems.ENERGY_ORACLE.r("_active_full")) { predicate(Resource.Custom("activity_intensity"), 1F) }
|
||||
}
|
||||
|
||||
multi(ModItems.ENERGY_ORACLE, Resource.Vanilla("item/generated"), arrayOf("_active_mild", "_active_full")){
|
||||
multi(ModItems.ENERGY_ORACLE, Resource.Vanilla("item/generated"), arrayOf("_active_mild", "_active_full")) {
|
||||
texture("layer0", Resource.Custom("item/energy_oracle"))
|
||||
texture("layer1", Resource.Custom("item/energy_oracle_indicator" + it.suffix))
|
||||
}
|
||||
|
||||
simple(ModItems.ENERGY_RECEPTACLE).then {
|
||||
override(ModItems.ENERGY_RECEPTACLE.r("_with_cluster")){ predicate(Resource.Custom("has_cluster"), 1F) }
|
||||
override(ModItems.ENERGY_RECEPTACLE.r("_with_cluster")) { predicate(Resource.Custom("has_cluster"), 1F) }
|
||||
}
|
||||
|
||||
layers(ModItems.ENERGY_RECEPTACLE.suffixed("_with_cluster"), arrayOf("energy_receptacle", "energy_receptacle_cluster"))
|
||||
@ -126,9 +127,9 @@ class ItemModels(generator: DataGenerator, modid: String, existingFileHelper: Ex
|
||||
simple(ModItems.LINKING_GEM)
|
||||
|
||||
layers(ModItems.PORTAL_TOKEN, arrayOf("portal_token_outline", "portal_token_color_top", "portal_token_color_bottom")).then {
|
||||
override(ModItems.PORTAL_TOKEN.r("_rare")){ predicate(Resource.Custom("token_type"), 1F) }
|
||||
override(ModItems.PORTAL_TOKEN.r("_rare_corrupted")){ predicate(Resource.Custom("token_type"), 1.5F) }
|
||||
override(ModItems.PORTAL_TOKEN.r("_solitary")){ predicate(Resource.Custom("token_type"), 2F) }
|
||||
override(ModItems.PORTAL_TOKEN.r("_rare")) { predicate(Resource.Custom("token_type"), 1F) }
|
||||
override(ModItems.PORTAL_TOKEN.r("_rare_corrupted")) { predicate(Resource.Custom("token_type"), 1.5F) }
|
||||
override(ModItems.PORTAL_TOKEN.r("_solitary")) { predicate(Resource.Custom("token_type"), 2F) }
|
||||
}
|
||||
|
||||
layers(ModItems.PORTAL_TOKEN.suffixed("_rare"), arrayOf("portal_token_outline", "portal_token_color_top", "portal_token_color_bottom", "portal_token_border_rare"))
|
||||
@ -141,7 +142,7 @@ class ItemModels(generator: DataGenerator, modid: String, existingFileHelper: Ex
|
||||
simple(ModItems.TRINKET_POUCH)
|
||||
|
||||
simple(ModItems.TOTEM_OF_UNDYING).then {
|
||||
override(ModItems.TOTEM_OF_UNDYING.r("_shaking")){ predicate(Resource.Custom("is_shaking"), 1F) }
|
||||
override(ModItems.TOTEM_OF_UNDYING.r("_shaking")) { predicate(Resource.Custom("is_shaking"), 1F) }
|
||||
}
|
||||
|
||||
simple(ModItems.TOTEM_OF_UNDYING.suffixed("_shaking"))
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.datagen.client.util
|
||||
|
||||
import chylex.hee.datagen.Callback
|
||||
import chylex.hee.datagen.path
|
||||
import chylex.hee.datagen.r
|
||||
@ -15,7 +16,7 @@ import net.minecraft.util.ResourceLocation
|
||||
import net.minecraftforge.client.model.generators.BlockModelBuilder
|
||||
import net.minecraftforge.client.model.generators.BlockModelProvider
|
||||
|
||||
fun Block.suffixed(suffix: String): Block{
|
||||
fun Block.suffixed(suffix: String): Block {
|
||||
return Block(Block.Properties.from(Blocks.AIR)) named this.path + suffix
|
||||
}
|
||||
|
||||
@ -27,15 +28,15 @@ fun BlockModelProvider.parent(block: Block, parent: ResourceLocation) = safe {
|
||||
this.getBuilder(block.path).parent(getExistingFile(parent))
|
||||
}
|
||||
|
||||
fun BlockModelProvider.simple(block: Block, parent: ResourceLocation, textureName: String, textureLocation: ResourceLocation = block.r): BlockModelBuilder?{
|
||||
fun BlockModelProvider.simple(block: Block, parent: ResourceLocation, textureName: String, textureLocation: ResourceLocation = block.r): BlockModelBuilder? {
|
||||
return this.parent(block, parent).then { texture(textureName, textureLocation) }
|
||||
}
|
||||
|
||||
fun BlockModelProvider.cube(block: Block, texture: ResourceLocation = block.r): BlockModelBuilder?{
|
||||
fun BlockModelProvider.cube(block: Block, texture: ResourceLocation = block.r): BlockModelBuilder? {
|
||||
return this.simple(block, Resource.Vanilla("block/cube_all"), "all", texture)
|
||||
}
|
||||
|
||||
fun BlockModelProvider.cross(block: Block, texture: ResourceLocation = block.r): BlockModelBuilder?{
|
||||
fun BlockModelProvider.cross(block: Block, texture: ResourceLocation = block.r): BlockModelBuilder? {
|
||||
return this.simple(block, Resource.Vanilla("block/cross"), "cross", texture)
|
||||
}
|
||||
|
||||
@ -47,7 +48,7 @@ fun BlockModelProvider.cubeBottomTop(block: Block, side: ResourceLocation = bloc
|
||||
return this.cubeBottomTop(block.path, side, bottom, top)
|
||||
}
|
||||
|
||||
fun BlockModelProvider.leaves(block: Block): BlockModelBuilder?{
|
||||
fun BlockModelProvider.leaves(block: Block): BlockModelBuilder? {
|
||||
return this.simple(block, Resource.Vanilla("block/leaves"), "all")
|
||||
}
|
||||
|
||||
@ -55,8 +56,8 @@ fun BlockModelProvider.particle(block: Block, particle: ResourceLocation) = safe
|
||||
this.getBuilder(block.path).texture("particle", particle)
|
||||
}
|
||||
|
||||
fun BlockModelProvider.multi(block: Block, parent: ResourceLocation, suffixes: Array<String>, callback: BlockModelBuilder.(Callback<Block>) -> Unit){
|
||||
for(suffix in suffixes){
|
||||
fun BlockModelProvider.multi(block: Block, parent: ResourceLocation, suffixes: Array<String>, callback: BlockModelBuilder.(Callback<Block>) -> Unit) {
|
||||
for(suffix in suffixes) {
|
||||
val path = block.path + suffix
|
||||
|
||||
this.safeUnit {
|
||||
@ -65,8 +66,8 @@ fun BlockModelProvider.multi(block: Block, parent: ResourceLocation, suffixes: A
|
||||
}
|
||||
}
|
||||
|
||||
fun BlockModelProvider.multi(block: Block, parent: ResourceLocation, suffixes: IntRange, callback: BlockModelBuilder.(Callback<Block>) -> Unit){
|
||||
multi(block, parent, Array(1 + suffixes.last - suffixes.first){ "_${suffixes.first + it}" }, callback)
|
||||
fun BlockModelProvider.multi(block: Block, parent: ResourceLocation, suffixes: IntRange, callback: BlockModelBuilder.(Callback<Block>) -> Unit) {
|
||||
multi(block, parent, Array(1 + suffixes.last - suffixes.first) { "_${suffixes.first + it}" }, callback)
|
||||
}
|
||||
|
||||
fun BlockModelProvider.wall(block: BlockWall, texture: ResourceLocation) = safeUnit {
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.datagen.client.util
|
||||
|
||||
import chylex.hee.datagen.r
|
||||
import chylex.hee.datagen.safeUnit
|
||||
import chylex.hee.system.migration.BlockLog
|
||||
@ -10,7 +11,7 @@ import net.minecraft.util.ResourceLocation
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider
|
||||
import net.minecraftforge.client.model.generators.ModelFile.UncheckedModelFile
|
||||
|
||||
private fun BlockStateProvider.simpleBlockItem(block: Block){
|
||||
private fun BlockStateProvider.simpleBlockItem(block: Block) {
|
||||
this.simpleBlockItem(block, UncheckedModelFile(block.r))
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.datagen.client.util
|
||||
|
||||
import chylex.hee.datagen.Callback
|
||||
import chylex.hee.datagen.path
|
||||
import chylex.hee.datagen.r
|
||||
@ -15,20 +16,20 @@ import net.minecraftforge.client.model.generators.ItemModelBuilder.OverrideBuild
|
||||
import net.minecraftforge.client.model.generators.ItemModelProvider
|
||||
import net.minecraftforge.client.model.generators.ModelFile.UncheckedModelFile
|
||||
|
||||
fun Item.suffixed(suffix: String): Item{
|
||||
fun Item.suffixed(suffix: String): Item {
|
||||
return Item(Item.Properties()) named this.path + suffix
|
||||
}
|
||||
|
||||
private val ItemModelProvider.generated
|
||||
get() = getExistingFile(Resource.Vanilla("item/generated"))
|
||||
|
||||
private fun IItemProvider.path() = when(this){
|
||||
private fun IItemProvider.path() = when(this) {
|
||||
is Block -> this.path
|
||||
is Item -> this.path
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
private fun ItemModelProvider.build(item: IItemProvider): ItemModelBuilder{
|
||||
private fun ItemModelProvider.build(item: IItemProvider): ItemModelBuilder {
|
||||
return this.getBuilder(item.path())
|
||||
}
|
||||
|
||||
@ -47,15 +48,15 @@ fun ItemModelProvider.simple(item: IItemProvider, texture: ResourceLocation = it
|
||||
fun ItemModelProvider.layers(item: Item, layers: Array<String>) = safe {
|
||||
var builder = this.getBuilder(item.path).parent(generated)
|
||||
|
||||
for((index, layer) in layers.withIndex()){
|
||||
for((index, layer) in layers.withIndex()) {
|
||||
builder = builder.texture("layer$index", Resource.Custom("item/$layer"))
|
||||
}
|
||||
|
||||
builder
|
||||
}
|
||||
|
||||
fun ItemModelProvider.multi(item: IItemProvider, parent: ResourceLocation, suffixes: Array<String>, callback: ItemModelBuilder.(Callback<IItemProvider>) -> Unit){
|
||||
for(suffix in suffixes){
|
||||
fun ItemModelProvider.multi(item: IItemProvider, parent: ResourceLocation, suffixes: Array<String>, callback: ItemModelBuilder.(Callback<IItemProvider>) -> Unit) {
|
||||
for(suffix in suffixes) {
|
||||
val path = item.path() + suffix
|
||||
|
||||
this.safeUnit {
|
||||
@ -64,14 +65,14 @@ fun ItemModelProvider.multi(item: IItemProvider, parent: ResourceLocation, suffi
|
||||
}
|
||||
}
|
||||
|
||||
fun ItemModelProvider.multi(item: IItemProvider, parent: ResourceLocation, suffixes: IntRange, callback: ItemModelBuilder.(Callback<IItemProvider>) -> Unit){
|
||||
multi(item, parent, Array(1 + suffixes.last - suffixes.first){ "_${suffixes.first + it}" }, callback)
|
||||
fun ItemModelProvider.multi(item: IItemProvider, parent: ResourceLocation, suffixes: IntRange, callback: ItemModelBuilder.(Callback<IItemProvider>) -> Unit) {
|
||||
multi(item, parent, Array(1 + suffixes.last - suffixes.first) { "_${suffixes.first + it}" }, callback)
|
||||
}
|
||||
|
||||
fun ItemModelProvider.block(block: Block, parent: Block = block) = safe {
|
||||
this.getBuilder(block.path).parent(UncheckedModelFile(parent.r))
|
||||
}
|
||||
|
||||
fun ItemModelBuilder.override(model: ResourceLocation, callback: OverrideBuilder.() -> OverrideBuilder): ItemModelBuilder?{
|
||||
fun ItemModelBuilder.override(model: ResourceLocation, callback: OverrideBuilder.() -> OverrideBuilder): ItemModelBuilder? {
|
||||
return this.override().model(UncheckedModelFile(model)).let(callback).end()
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
package chylex.hee.datagen.server
|
||||
|
||||
import chylex.hee.datagen.server.util.BlockLootTableProvider
|
||||
import chylex.hee.init.ModBlocks
|
||||
import chylex.hee.init.ModItems
|
||||
import net.minecraft.block.Blocks
|
||||
import net.minecraft.data.DataGenerator
|
||||
|
||||
class BlockLootTables(generator: DataGenerator) : BlockLootTableProvider(generator){
|
||||
override val consumer = object : RegistrationConsumer(){
|
||||
override fun addTables(){
|
||||
class BlockLootTables(generator: DataGenerator) : BlockLootTableProvider(generator) {
|
||||
override val consumer = object : RegistrationConsumer() {
|
||||
override fun addTables() {
|
||||
dropSelf(ModBlocks.ACCUMULATION_TABLE_TIER_1)
|
||||
dropSelf(ModBlocks.ACCUMULATION_TABLE_TIER_2)
|
||||
dropSelf(ModBlocks.ACCUMULATION_TABLE_TIER_3)
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.datagen.server
|
||||
|
||||
import chylex.hee.datagen.server.util.add
|
||||
import chylex.hee.game.block.BlockWhitebarkSapling
|
||||
import chylex.hee.init.ModBlocks
|
||||
@ -14,10 +15,10 @@ import net.minecraft.data.DataGenerator
|
||||
import net.minecraft.tags.BlockTags
|
||||
import net.minecraftforge.common.Tags
|
||||
|
||||
class BlockTags(generator: DataGenerator) : BlockTagsProvider(generator){
|
||||
class BlockTags(generator: DataGenerator) : BlockTagsProvider(generator) {
|
||||
private val blocks = getRegistryEntries<Block>(ModBlocks)
|
||||
|
||||
override fun registerTags(){
|
||||
override fun registerTags() {
|
||||
getBuilder(BlockTags.BAMBOO_PLANTABLE_ON).add(ModBlocks.HUMUS)
|
||||
getBuilder(BlockTags.FLOWER_POTS).add(blocks.filterIsInstance<BlockFlowerPot>())
|
||||
getBuilder(BlockTags.IMPERMEABLE).add(ModBlocks.INFUSED_GLASS)
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.datagen.server
|
||||
|
||||
import chylex.hee.init.ModItems
|
||||
import net.minecraft.data.DataGenerator
|
||||
import net.minecraft.data.ItemTagsProvider
|
||||
@ -6,8 +7,8 @@ import net.minecraft.tags.BlockTags
|
||||
import net.minecraft.tags.ItemTags
|
||||
import net.minecraftforge.common.Tags
|
||||
|
||||
class ItemTags(generator: DataGenerator) : ItemTagsProvider(generator){
|
||||
override fun registerTags(){
|
||||
class ItemTags(generator: DataGenerator) : ItemTagsProvider(generator) {
|
||||
override fun registerTags() {
|
||||
copy(BlockTags.LEAVES, ItemTags.LEAVES)
|
||||
copy(BlockTags.LOGS, ItemTags.LOGS)
|
||||
copy(BlockTags.PLANKS, ItemTags.PLANKS)
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.datagen.server.util
|
||||
|
||||
import chylex.hee.system.migration.BlockFlowerPot
|
||||
import com.mojang.datafixers.util.Pair
|
||||
import net.minecraft.block.Block
|
||||
@ -16,55 +17,55 @@ import java.util.function.BiConsumer
|
||||
import java.util.function.Consumer
|
||||
import java.util.function.Supplier
|
||||
|
||||
abstract class BlockLootTableProvider(generator: DataGenerator) : LootTableProvider(generator){
|
||||
abstract class BlockLootTableProvider(generator: DataGenerator) : LootTableProvider(generator) {
|
||||
protected abstract val consumer: RegistrationConsumer
|
||||
|
||||
final override fun getName(): String{
|
||||
final override fun getName(): String {
|
||||
return "Block Loot Tables"
|
||||
}
|
||||
|
||||
final override fun getTables(): MutableList<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, Builder>>>, LootParameterSet>>{
|
||||
final override fun getTables(): MutableList<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, Builder>>>, LootParameterSet>> {
|
||||
return mutableListOf(Pair.of(Supplier(::consumer), LootParameterSets.BLOCK))
|
||||
}
|
||||
|
||||
final override fun validate(map: MutableMap<ResourceLocation, LootTable>, tracker: ValidationTracker){}
|
||||
final override fun validate(map: MutableMap<ResourceLocation, LootTable>, tracker: ValidationTracker) {}
|
||||
|
||||
protected abstract class RegistrationConsumer : BlockLootTables(){
|
||||
protected abstract class RegistrationConsumer : BlockLootTables() {
|
||||
private val lootTables = mutableMapOf<ResourceLocation, Builder>()
|
||||
|
||||
override fun addTables(){}
|
||||
override fun addTables() {}
|
||||
|
||||
final override fun accept(consumer: BiConsumer<ResourceLocation?, Builder?>){
|
||||
final override fun accept(consumer: BiConsumer<ResourceLocation?, Builder?>) {
|
||||
addTables()
|
||||
|
||||
for((location, table) in lootTables){
|
||||
for((location, table) in lootTables) {
|
||||
consumer.accept(location, table)
|
||||
}
|
||||
|
||||
lootTables.clear()
|
||||
}
|
||||
|
||||
final override fun registerLootTable(block: Block, table: Builder){
|
||||
final override fun registerLootTable(block: Block, table: Builder) {
|
||||
check(lootTables.put(block.lootTable, table) == null)
|
||||
}
|
||||
|
||||
protected fun dropSelf(block: Block){
|
||||
protected fun dropSelf(block: Block) {
|
||||
registerDropSelfLootTable(block)
|
||||
}
|
||||
|
||||
protected fun dropOther(block: Block, drop: IItemProvider){
|
||||
protected fun dropOther(block: Block, drop: IItemProvider) {
|
||||
registerDropping(block, drop)
|
||||
}
|
||||
|
||||
protected fun dropFunc(block: Block, func: (Block) -> Builder){
|
||||
protected fun dropFunc(block: Block, func: (Block) -> Builder) {
|
||||
registerLootTable(block, func)
|
||||
}
|
||||
|
||||
protected fun dropFlowerPot(block: BlockFlowerPot){
|
||||
protected fun dropFlowerPot(block: BlockFlowerPot) {
|
||||
registerFlowerPot(block)
|
||||
}
|
||||
|
||||
protected companion object{
|
||||
protected companion object {
|
||||
val withName = BlockLootTables::droppingWithName
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package chylex.hee.datagen.server.util
|
||||
|
||||
import net.minecraft.tags.Tag
|
||||
|
||||
fun <T> Tag.Builder<T>.add(items: List<T>){
|
||||
fun <T> Tag.Builder<T>.add(items: List<T>) {
|
||||
items.forEach(this::add)
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee
|
||||
|
||||
import chylex.hee.game.block.BlockBrewingStandCustom
|
||||
import chylex.hee.game.block.BlockEndPortalOverride
|
||||
import chylex.hee.game.block.BlockShulkerBoxOverride
|
||||
@ -37,16 +38,16 @@ import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent
|
||||
|
||||
@Mod(HEE.ID)
|
||||
@SubscribeAllEvents(modid = HEE.ID, bus = MOD)
|
||||
object Mod{
|
||||
init{
|
||||
with(ModLoadingContext.get()){
|
||||
object Mod {
|
||||
init {
|
||||
with(ModLoadingContext.get()) {
|
||||
HEE.version = activeContainer.modInfo.version.toString()
|
||||
}
|
||||
|
||||
@Suppress("ConvertLambdaToReference")
|
||||
HEE.proxy = DistExecutor.safeRunForDist(
|
||||
{ SafeSupplier { ModClientProxy() }},
|
||||
{ SafeSupplier { ModCommonProxy() }}
|
||||
{ SafeSupplier { ModClientProxy() } },
|
||||
{ SafeSupplier { ModCommonProxy() } }
|
||||
)
|
||||
|
||||
CustomRarity
|
||||
@ -57,12 +58,12 @@ object Mod{
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onClientSetup(@Suppress("UNUSED_PARAMETER") e: FMLClientSetupEvent){
|
||||
fun onClientSetup(@Suppress("UNUSED_PARAMETER") e: FMLClientSetupEvent) {
|
||||
Debug.initializeClient()
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onCommonSetup(@Suppress("UNUSED_PARAMETER") e: FMLCommonSetupEvent){
|
||||
fun onCommonSetup(@Suppress("UNUSED_PARAMETER") e: FMLCommonSetupEvent) {
|
||||
NetworkManager.initialize(ModPackets.ALL)
|
||||
ModLoot.initialize()
|
||||
|
||||
@ -73,7 +74,7 @@ object Mod{
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onLoadComplete(@Suppress("UNUSED_PARAMETER") e: FMLLoadCompleteEvent){
|
||||
fun onLoadComplete(@Suppress("UNUSED_PARAMETER") e: FMLLoadCompleteEvent) {
|
||||
EntityMobEnderman.setupBiomeSpawns()
|
||||
EndermanBlockHandler.setupCarriableBlocks()
|
||||
ModPotions.setupVanillaOverrides()
|
||||
@ -82,12 +83,12 @@ object Mod{
|
||||
IntegrityCheck.verify()
|
||||
}
|
||||
|
||||
private object IntegrityCheck{
|
||||
fun verify(){
|
||||
private object IntegrityCheck {
|
||||
fun verify() {
|
||||
crashIfFalse(Blocks.END_PORTAL::class.java === BlockEndPortalOverride::class.java, "invalid End Portal block: ${Blocks.END_PORTAL::class.java}")
|
||||
crashIfFalse(Blocks.BREWING_STAND::class.java === BlockBrewingStandCustom::class.java, "invalid Brewing Stand block: ${Blocks.BREWING_STAND::class.java}")
|
||||
|
||||
for(block in BlockShulkerBoxOverride.ALL_BLOCKS){
|
||||
for(block in BlockShulkerBoxOverride.ALL_BLOCKS) {
|
||||
crashIfFalse(block.javaClass === BlockShulkerBoxOverride::class.java, "invalid Shulker Box block: ${block.javaClass}")
|
||||
crashIfFalse(block.asItem().javaClass === ItemShulkerBoxOverride::class.java, "invalid Shulker Box item: ${block.asItem().javaClass}")
|
||||
}
|
||||
@ -99,15 +100,15 @@ object Mod{
|
||||
|
||||
// Utilities
|
||||
|
||||
private fun crashIfFalse(value: Boolean, message: String){
|
||||
if (!value){
|
||||
private fun crashIfFalse(value: Boolean, message: String) {
|
||||
if (!value) {
|
||||
failIntegrityCheck(message, true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun failIntegrityCheck(message: String, crash: Boolean){
|
||||
private fun failIntegrityCheck(message: String, crash: Boolean) {
|
||||
HEE.log.error("[IntegrityCheck] $message")
|
||||
check(!crash){ "Integrity check failed: $message" }
|
||||
check(!crash) { "Integrity check failed: $message" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.system.facades.Resource
|
||||
import chylex.hee.system.migration.supply
|
||||
@ -11,15 +12,15 @@ import net.minecraft.resources.ResourcePackInfo.Priority
|
||||
import net.minecraft.resources.ResourcePackType
|
||||
import net.minecraftforge.fml.packs.ResourcePackLoader
|
||||
|
||||
object VanillaResourceOverrides : IPackFinder{
|
||||
fun register(){
|
||||
object VanillaResourceOverrides : IPackFinder {
|
||||
fun register() {
|
||||
// Minecraft is null when running datagen, but I cannot move this to FMLClientSetupEvent because it only runs after all resource packs are initialized
|
||||
with(Minecraft.getInstance() ?: return){
|
||||
with(Minecraft.getInstance() ?: return) {
|
||||
resourcePackList.addPackFinder(this@VanillaResourceOverrides)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : ResourcePackInfo> addPackInfosToMap(map: MutableMap<String, T>, factory: IFactory<T>){
|
||||
override fun <T : ResourcePackInfo> addPackInfosToMap(map: MutableMap<String, T>, factory: IFactory<T>) {
|
||||
val delegate = ResourcePackLoader.getResourcePackFor(HEE.ID).get()
|
||||
val supplier = supply<IResourcePack>(Pack(delegate))
|
||||
|
||||
@ -30,7 +31,7 @@ object VanillaResourceOverrides : IPackFinder{
|
||||
override fun getName() = "Hardcore Ender Expansion 2"
|
||||
override fun isHidden() = true // minecraft doesn't remember the order across restarts anyway
|
||||
|
||||
override fun getResourceNamespaces(type: ResourcePackType): MutableSet<String>{
|
||||
override fun getResourceNamespaces(type: ResourcePackType): MutableSet<String> {
|
||||
return mutableSetOf(Resource.NAMESPACE_VANILLA)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.gui
|
||||
|
||||
import chylex.hee.client.gui.base.GuiBaseChestContainer
|
||||
import chylex.hee.game.container.ContainerAmuletOfRecovery
|
||||
import chylex.hee.network.server.PacketServerContainerEvent
|
||||
@ -10,14 +11,14 @@ import net.minecraft.util.text.ITextComponent
|
||||
import net.minecraftforge.fml.client.gui.widget.ExtendedButton
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class GuiAmuletOfRecovery(container: ContainerAmuletOfRecovery, inventory: PlayerInventory, title: ITextComponent) : GuiBaseChestContainer<ContainerAmuletOfRecovery>(container, inventory, title){
|
||||
override fun init(){
|
||||
class GuiAmuletOfRecovery(container: ContainerAmuletOfRecovery, inventory: PlayerInventory, title: ITextComponent) : GuiBaseChestContainer<ContainerAmuletOfRecovery>(container, inventory, title) {
|
||||
override fun init() {
|
||||
super.init()
|
||||
|
||||
val moveAllTitle = I18n.format("gui.hee.amulet_of_recovery.move_all")
|
||||
val moveAllWidth = (font.getStringWidth(moveAllTitle) + 14).coerceAtMost(xSize / 2)
|
||||
|
||||
addButton(ExtendedButton(guiLeft + xSize - moveAllWidth - 7, (height / 2) + 6, moveAllWidth, 11, moveAllTitle){
|
||||
addButton(ExtendedButton(guiLeft + xSize - moveAllWidth - 7, (height / 2) + 6, moveAllWidth, 11, moveAllTitle) {
|
||||
PacketServerContainerEvent(0).sendToServer()
|
||||
})
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.gui
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.render.gl.GL
|
||||
import chylex.hee.game.block.entity.TileEntityBrewingStandCustom
|
||||
@ -12,15 +13,15 @@ import net.minecraft.inventory.container.BrewingStandContainer
|
||||
import net.minecraft.util.text.ITextComponent
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class GuiBrewingStandCustom(container: BrewingStandContainer, inventory: PlayerInventory, title: ITextComponent) : BrewingStandScreen(container, inventory, title){
|
||||
private companion object{
|
||||
class GuiBrewingStandCustom(container: BrewingStandContainer, inventory: PlayerInventory, title: ITextComponent) : BrewingStandScreen(container, inventory, title) {
|
||||
private companion object {
|
||||
private val TEX_BACKGROUND = Resource.Custom("textures/gui/brewing_stand.png")
|
||||
private val BUBBLE_LENGTHS = intArrayOf(0, 6, 11, 16, 20, 24, 29)
|
||||
}
|
||||
|
||||
private var brewStartTime = MC.world!!.totalTime
|
||||
|
||||
override fun drawGuiContainerBackgroundLayer(partialTicks: Float, mouseX: Int, mouseY: Int){
|
||||
override fun drawGuiContainerBackgroundLayer(partialTicks: Float, mouseX: Int, mouseY: Int) {
|
||||
val x = (width - xSize) / 2
|
||||
val y = (height - ySize) / 2
|
||||
|
||||
@ -31,31 +32,31 @@ class GuiBrewingStandCustom(container: BrewingStandContainer, inventory: PlayerI
|
||||
val worldTime = MC.world!!.totalTime
|
||||
val brewTime = container.func_216981_f() // RENAME getBrewTime
|
||||
|
||||
if (brewTime > 0){
|
||||
if (brewTime > 0) {
|
||||
val brewProgress = (28F * (1F - (brewTime / 400F))).toInt()
|
||||
|
||||
if (brewProgress > 0){
|
||||
if (brewProgress > 0) {
|
||||
blit(x + 97, y + 16, 176, 0, 9, brewProgress)
|
||||
}
|
||||
|
||||
val bubbleLength = BUBBLE_LENGTHS[((worldTime - brewStartTime).toInt() / 2) % 7]
|
||||
|
||||
if (bubbleLength > 0){
|
||||
if (bubbleLength > 0) {
|
||||
blit(x + 63, y + 43 - bubbleLength, 185, 29 - bubbleLength, 12, bubbleLength)
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
brewStartTime = worldTime
|
||||
}
|
||||
|
||||
if (container.getSlot(TileEntityBrewingStandCustom.SLOT_MODIFIER).hasStack){
|
||||
if (container.getSlot(TileEntityBrewingStandCustom.SLOT_MODIFIER).hasStack) {
|
||||
blit(x + 62, y + 45, 197, 0, 14, 2)
|
||||
}
|
||||
|
||||
for(slotIndex in TileEntityBrewingStandCustom.SLOTS_POTIONS){
|
||||
for(slotIndex in TileEntityBrewingStandCustom.SLOTS_POTIONS) {
|
||||
val slot = container.getSlot(slotIndex)
|
||||
|
||||
if (!slot.hasStack){
|
||||
if (!slot.hasStack) {
|
||||
blit(x + slot.xPos, y + slot.yPos, 211, 0, 16, 16)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.gui
|
||||
|
||||
import chylex.hee.client.gui.base.GuiBaseChestContainer
|
||||
import chylex.hee.game.block.entity.TileEntityLootChest
|
||||
import chylex.hee.game.container.ContainerLootChest
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.gui
|
||||
|
||||
import chylex.hee.client.gui.base.GuiBaseChestContainer
|
||||
import chylex.hee.game.container.ContainerPortalTokenStorage
|
||||
import chylex.hee.system.forge.Side
|
||||
@ -8,8 +9,8 @@ import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.text.ITextComponent
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class GuiPortalTokenStorage(container: ContainerPortalTokenStorage, inventory: PlayerInventory, title: ITextComponent) : GuiBaseChestContainer<ContainerPortalTokenStorage>(container, inventory, title){
|
||||
fun canActivateToken(stack: ItemStack): Boolean{
|
||||
class GuiPortalTokenStorage(container: ContainerPortalTokenStorage, inventory: PlayerInventory, title: ITextComponent) : GuiBaseChestContainer<ContainerPortalTokenStorage>(container, inventory, title) {
|
||||
fun canActivateToken(stack: ItemStack): Boolean {
|
||||
return container.canActivateToken(stack)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.gui
|
||||
|
||||
import chylex.hee.client.gui.base.GuiBaseChestContainer
|
||||
import chylex.hee.game.container.ContainerShulkerBox
|
||||
import chylex.hee.system.forge.Side
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.gui
|
||||
|
||||
import chylex.hee.client.gui.base.GuiBaseCustomInventory
|
||||
import chylex.hee.game.container.ContainerTrinketPouch
|
||||
import chylex.hee.game.container.base.ContainerBaseCustomInventory
|
||||
@ -11,29 +12,29 @@ import net.minecraft.entity.player.PlayerInventory
|
||||
import net.minecraft.util.text.ITextComponent
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class GuiTrinketPouch(container: ContainerTrinketPouch, inventory: PlayerInventory, title: ITextComponent) : GuiBaseCustomInventory<ContainerTrinketPouch>(container, inventory, title){
|
||||
class GuiTrinketPouch(container: ContainerTrinketPouch, inventory: PlayerInventory, title: ITextComponent) : GuiBaseCustomInventory<ContainerTrinketPouch>(container, inventory, title) {
|
||||
override val texBackground = Resource.Custom("textures/gui/trinket_pouch.png")
|
||||
override val titleContainer = "gui.hee.trinket_pouch.title"
|
||||
|
||||
private val hiddenSlots: Int
|
||||
private val hiddenSlotColor = RGBA(0u, 0.25F).i
|
||||
|
||||
init{
|
||||
init {
|
||||
ySize = ContainerTrinketPouch.HEIGHT
|
||||
hiddenSlots = ContainerTrinketPouch.MAX_SLOTS - (container as ContainerBaseCustomInventory<*>).containerInventory.size
|
||||
}
|
||||
|
||||
override fun drawGuiContainerBackgroundLayer(partialTicks: Float, mouseX: Int, mouseY: Int){
|
||||
override fun drawGuiContainerBackgroundLayer(partialTicks: Float, mouseX: Int, mouseY: Int) {
|
||||
super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY)
|
||||
|
||||
val middleSlot = ContainerTrinketPouch.MAX_SLOTS / 2
|
||||
|
||||
repeat(hiddenSlots){
|
||||
repeat(hiddenSlots) {
|
||||
renderSlotCover(middleSlot + ((ContainerTrinketPouch.MAX_SLOTS - it) / 2) * (if (it % 2 == 0) -1 else 1))
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderSlotCover(index: Int){
|
||||
private fun renderSlotCover(index: Int) {
|
||||
val x = guiLeft + 44 + (index * 18)
|
||||
val y = guiTop + 18
|
||||
fill(x, y, x + 16, y + 16, hiddenSlotColor)
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.gui.base
|
||||
|
||||
import chylex.hee.client.render.gl.GL
|
||||
import chylex.hee.game.inventory.size
|
||||
import chylex.hee.system.color.IntColor.Companion.RGB
|
||||
@ -11,25 +12,25 @@ import net.minecraft.inventory.container.ChestContainer
|
||||
import net.minecraft.util.text.ITextComponent
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
abstract class GuiBaseChestContainer<T : ChestContainer>(container: T, inventory: PlayerInventory, title: ITextComponent) : ContainerScreen<T>(container, inventory, title){
|
||||
private companion object{
|
||||
abstract class GuiBaseChestContainer<T : ChestContainer>(container: T, inventory: PlayerInventory, title: ITextComponent) : ContainerScreen<T>(container, inventory, title) {
|
||||
private companion object {
|
||||
private val TEX_BACKGROUND = Resource.Vanilla("textures/gui/container/generic_54.png")
|
||||
private val COLOR_TEXT = RGB(64u).i
|
||||
}
|
||||
|
||||
private val containerRows = container.lowerChestInventory.size / 9
|
||||
|
||||
init{
|
||||
init {
|
||||
ySize = 114 + (containerRows * 18)
|
||||
}
|
||||
|
||||
override fun render(mouseX: Int, mouseY: Int, partialTicks: Float){
|
||||
override fun render(mouseX: Int, mouseY: Int, partialTicks: Float) {
|
||||
renderBackground()
|
||||
super.render(mouseX, mouseY, partialTicks)
|
||||
renderHoveredToolTip(mouseX, mouseY)
|
||||
}
|
||||
|
||||
override fun drawGuiContainerBackgroundLayer(partialTicks: Float, mouseX: Int, mouseY: Int){
|
||||
override fun drawGuiContainerBackgroundLayer(partialTicks: Float, mouseX: Int, mouseY: Int) {
|
||||
val x = (width - xSize) / 2
|
||||
val y = (height - ySize) / 2
|
||||
val heightContainer = 17 + (containerRows * 18)
|
||||
@ -40,7 +41,7 @@ abstract class GuiBaseChestContainer<T : ChestContainer>(container: T, inventory
|
||||
blit(x, y + heightContainer, 0, 126, xSize, 96)
|
||||
}
|
||||
|
||||
override fun drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int){
|
||||
override fun drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) {
|
||||
font.drawString(title.formattedText, 8F, 6F, COLOR_TEXT)
|
||||
font.drawString(playerInventory.displayName.formattedText, 8F, ySize - 94F, COLOR_TEXT)
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.gui.base
|
||||
|
||||
import chylex.hee.client.render.gl.GL
|
||||
import chylex.hee.game.container.base.ContainerBaseCustomInventory
|
||||
import chylex.hee.system.color.IntColor.Companion.RGB
|
||||
@ -10,21 +11,21 @@ import net.minecraft.util.ResourceLocation
|
||||
import net.minecraft.util.text.ITextComponent
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
abstract class GuiBaseCustomInventory<T : ContainerBaseCustomInventory<*>>(container: T, inventory: PlayerInventory, title: ITextComponent) : ContainerScreen<T>(container, inventory, title){
|
||||
private companion object{
|
||||
abstract class GuiBaseCustomInventory<T : ContainerBaseCustomInventory<*>>(container: T, inventory: PlayerInventory, title: ITextComponent) : ContainerScreen<T>(container, inventory, title) {
|
||||
private companion object {
|
||||
private val COLOR_TEXT = RGB(64u).i
|
||||
}
|
||||
|
||||
protected abstract val texBackground: ResourceLocation
|
||||
protected abstract val titleContainer: String
|
||||
|
||||
override fun render(mouseX: Int, mouseY: Int, partialTicks: Float){
|
||||
override fun render(mouseX: Int, mouseY: Int, partialTicks: Float) {
|
||||
renderBackground()
|
||||
super.render(mouseX, mouseY, partialTicks)
|
||||
renderHoveredToolTip(mouseX, mouseY)
|
||||
}
|
||||
|
||||
override fun drawGuiContainerBackgroundLayer(partialTicks: Float, mouseX: Int, mouseY: Int){
|
||||
override fun drawGuiContainerBackgroundLayer(partialTicks: Float, mouseX: Int, mouseY: Int) {
|
||||
val x = (width - xSize) / 2
|
||||
val y = (height - ySize) / 2
|
||||
|
||||
@ -33,7 +34,7 @@ abstract class GuiBaseCustomInventory<T : ContainerBaseCustomInventory<*>>(conta
|
||||
blit(x, y, 0, 0, xSize, ySize)
|
||||
}
|
||||
|
||||
override fun drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int){
|
||||
override fun drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) {
|
||||
font.drawString(title.formattedText, 8F, 6F, COLOR_TEXT)
|
||||
font.drawString(playerInventory.displayName.formattedText, 8F, ySize - 94F, COLOR_TEXT)
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.model.block
|
||||
|
||||
import chylex.hee.client.model.beginBox
|
||||
import chylex.hee.client.render.gl.translateZ
|
||||
import chylex.hee.system.forge.Side
|
||||
@ -14,13 +15,13 @@ import kotlin.math.abs
|
||||
import kotlin.math.sin
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object ModelBlockIgneousPlate : Model(RenderType::getEntityCutout){
|
||||
object ModelBlockIgneousPlate : Model(RenderType::getEntityCutout) {
|
||||
const val ANIMATION_PERIOD = PI
|
||||
|
||||
private val outerBox: ModelRenderer
|
||||
private val innerBox: ModelRenderer
|
||||
|
||||
init{
|
||||
init {
|
||||
textureWidth = 32
|
||||
textureHeight = 16
|
||||
|
||||
@ -36,11 +37,11 @@ object ModelBlockIgneousPlate : Model(RenderType::getEntityCutout){
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float){
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float) {
|
||||
outerBox.render(matrix, builder, combinedLight, combinedOverlay, red, green, blue, alpha)
|
||||
}
|
||||
|
||||
fun renderInnerBox(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, color: Vec3d, animation: Double){
|
||||
fun renderInnerBox(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, color: Vec3d, animation: Double) {
|
||||
matrix.push()
|
||||
matrix.translateZ(-abs(sin(-animation)).toFloat() * 0.0925)
|
||||
innerBox.render(matrix, builder, combinedLight, combinedOverlay, color.x.toFloat(), color.y.toFloat(), color.z.toFloat(), 1F)
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.model.entity
|
||||
|
||||
import chylex.hee.client.model.FACE_FRONT
|
||||
import chylex.hee.client.model.beginBox
|
||||
import chylex.hee.client.model.retainFace
|
||||
@ -12,7 +13,7 @@ import net.minecraft.client.renderer.entity.model.EntityModel
|
||||
import net.minecraft.client.renderer.model.ModelRenderer
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object ModelEntityBossEnderEye : EntityModel<EntityBossEnderEye>(){
|
||||
object ModelEntityBossEnderEye : EntityModel<EntityBossEnderEye>() {
|
||||
const val SCALE = 16F / 18F
|
||||
|
||||
private val head: ModelRenderer
|
||||
@ -21,7 +22,7 @@ object ModelEntityBossEnderEye : EntityModel<EntityBossEnderEye>(){
|
||||
|
||||
private var eyeState = 0
|
||||
|
||||
init{
|
||||
init {
|
||||
textureWidth = 128
|
||||
textureHeight = 64
|
||||
|
||||
@ -30,7 +31,7 @@ object ModelEntityBossEnderEye : EntityModel<EntityBossEnderEye>(){
|
||||
beginBox.offset(-9F, -9F, -9F).size(18, 18, 18).tex(0, 0).add()
|
||||
}
|
||||
|
||||
eyes = Array(8){
|
||||
eyes = Array(8) {
|
||||
ModelRenderer(this).apply {
|
||||
setRotationPoint(0F, 15F, 0F)
|
||||
beginBox.offset(-8F, -8F, -9F).size(16, 16, 1).tex(-1 + (16 * it), 47).add()
|
||||
@ -45,22 +46,22 @@ object ModelEntityBossEnderEye : EntityModel<EntityBossEnderEye>(){
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLivingAnimations(entity: EntityBossEnderEye, limbSwing: Float, limbSwingAmount: Float, partialTicks: Float){
|
||||
override fun setLivingAnimations(entity: EntityBossEnderEye, limbSwing: Float, limbSwingAmount: Float, partialTicks: Float) {
|
||||
arms.rotateAngleX = entity.clientArmAngle.get(partialTicks).toRadians()
|
||||
|
||||
eyeState = when{
|
||||
eyeState = when {
|
||||
entity.eyeState == EntityBossEnderEye.EYE_CLOSED -> 0
|
||||
entity.eyeState == EntityBossEnderEye.EYE_LASER -> 7
|
||||
entity.isDemonEye -> 7
|
||||
else -> entity.demonLevel + 1
|
||||
entity.eyeState == EntityBossEnderEye.EYE_LASER -> 7
|
||||
entity.isDemonEye -> 7
|
||||
else -> entity.demonLevel + 1
|
||||
}
|
||||
}
|
||||
|
||||
override fun setRotationAngles(entity: EntityBossEnderEye, limbSwing: Float, limbSwingAmount: Float, age: Float, headYaw: Float, headPitch: Float){
|
||||
override fun setRotationAngles(entity: EntityBossEnderEye, limbSwing: Float, limbSwingAmount: Float, age: Float, headYaw: Float, headPitch: Float) {
|
||||
head.rotateAngleX = headPitch.toRadians()
|
||||
}
|
||||
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float){
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float) {
|
||||
head.render(matrix, builder, combinedLight, combinedOverlay, red, green, blue, alpha)
|
||||
eyes[eyeState].also { it.rotateAngleX = head.rotateAngleX }.render(matrix, builder, combinedLight, combinedOverlay, red, green, blue, alpha)
|
||||
arms.render(matrix, builder, combinedLight, combinedOverlay, red, green, blue, alpha)
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.model.entity
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.model.FACE_FRONT
|
||||
import chylex.hee.client.model.beginBox
|
||||
@ -17,7 +18,7 @@ import net.minecraft.client.renderer.entity.model.EntityModel
|
||||
import net.minecraft.client.renderer.model.ModelRenderer
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object ModelEntityMobBlobby : EntityModel<EntityMobBlobby>(){
|
||||
object ModelEntityMobBlobby : EntityModel<EntityMobBlobby>() {
|
||||
const val GLOBAL_SCALE = 8F / 9F
|
||||
|
||||
private const val SIZE_BODY = 9
|
||||
@ -34,7 +35,7 @@ object ModelEntityMobBlobby : EntityModel<EntityMobBlobby>(){
|
||||
private var g = 255F
|
||||
private var b = 55F
|
||||
|
||||
init{
|
||||
init {
|
||||
textureWidth = 128
|
||||
textureHeight = 256
|
||||
|
||||
@ -54,7 +55,7 @@ object ModelEntityMobBlobby : EntityModel<EntityMobBlobby>(){
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLivingAnimations(entity: EntityMobBlobby, limbSwing: Float, limbSwingAmount: Float, partialTicks: Float){
|
||||
override fun setLivingAnimations(entity: EntityMobBlobby, limbSwing: Float, limbSwingAmount: Float, partialTicks: Float) {
|
||||
entity.color.let {
|
||||
r = it.redF
|
||||
g = it.greenF
|
||||
@ -62,14 +63,14 @@ object ModelEntityMobBlobby : EntityModel<EntityMobBlobby>(){
|
||||
}
|
||||
}
|
||||
|
||||
override fun setRotationAngles(entity: EntityMobBlobby, limbSwing: Float, limbSwingAmount: Float, age: Float, headYaw: Float, headPitch: Float){
|
||||
override fun setRotationAngles(entity: EntityMobBlobby, limbSwing: Float, limbSwingAmount: Float, age: Float, headYaw: Float, headPitch: Float) {
|
||||
val vecBlobbyLook = Vec3.fromYaw(entity.rotationYawHead)
|
||||
val vecCameraDiff = MC.renderManager.info.projectedView.subtract(entity.posVec).normalize()
|
||||
|
||||
isPlayerInFront = vecBlobbyLook.dotProduct(vecCameraDiff) > 0.0
|
||||
}
|
||||
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float){
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float) {
|
||||
matrix.translateY(-0.001)
|
||||
|
||||
matrix.push()
|
||||
|
@ -1,15 +1,16 @@
|
||||
package chylex.hee.client.model.entity
|
||||
|
||||
import chylex.hee.game.entity.living.EntityMobUndread
|
||||
import chylex.hee.system.forge.Side
|
||||
import chylex.hee.system.forge.Sided
|
||||
import net.minecraft.client.renderer.entity.model.AbstractZombieModel
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class ModelEntityMobUndread private constructor(modelSize: Float, textureWidth: Int, textureHeight: Int) : AbstractZombieModel<EntityMobUndread>(modelSize, 0F, textureWidth, textureHeight){
|
||||
class ModelEntityMobUndread private constructor(modelSize: Float, textureWidth: Int, textureHeight: Int) : AbstractZombieModel<EntityMobUndread>(modelSize, 0F, textureWidth, textureHeight) {
|
||||
constructor(modelSize: Float, tallTexture: Boolean) : this(modelSize, 64, if (tallTexture) 32 else 64)
|
||||
constructor() : this(0F, false)
|
||||
|
||||
override fun isAggressive(entity: EntityMobUndread): Boolean{
|
||||
override fun isAggressive(entity: EntityMobUndread): Boolean {
|
||||
return entity.isAggressive
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.model.entity
|
||||
|
||||
import chylex.hee.client.model.beginBox
|
||||
import chylex.hee.game.entity.item.EntityTokenHolder
|
||||
import chylex.hee.system.forge.Side
|
||||
@ -9,10 +10,10 @@ import net.minecraft.client.renderer.entity.model.EntityModel
|
||||
import net.minecraft.client.renderer.model.ModelRenderer
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
object ModelEntityTokenHolder : EntityModel<EntityTokenHolder>(){
|
||||
object ModelEntityTokenHolder : EntityModel<EntityTokenHolder>() {
|
||||
private val box: ModelRenderer
|
||||
|
||||
init{
|
||||
init {
|
||||
textureWidth = 64
|
||||
textureHeight = 32
|
||||
|
||||
@ -21,9 +22,9 @@ object ModelEntityTokenHolder : EntityModel<EntityTokenHolder>(){
|
||||
}
|
||||
}
|
||||
|
||||
override fun setRotationAngles(entity: EntityTokenHolder, limbSwing: Float, limbSwingAmount: Float, age: Float, headYaw: Float, headPitch: Float){}
|
||||
override fun setRotationAngles(entity: EntityTokenHolder, limbSwing: Float, limbSwingAmount: Float, age: Float, headYaw: Float, headPitch: Float) {}
|
||||
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float){
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float) {
|
||||
box.render(matrix, builder, combinedLight, combinedOverlay, red, green, blue, alpha)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.model.item
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.system.facades.Resource
|
||||
@ -23,32 +24,32 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
@Suppress("unused")
|
||||
class ModelItemAmuletOfRecovery private constructor(sourceModel: IBakedModel) : BakedModelWrapper<IBakedModel>(sourceModel){
|
||||
class ModelItemAmuletOfRecovery private constructor(sourceModel: IBakedModel) : BakedModelWrapper<IBakedModel>(sourceModel) {
|
||||
@SubscribeAllEvents(Side.CLIENT, modid = HEE.ID, bus = MOD)
|
||||
companion object{
|
||||
companion object {
|
||||
private val RESOURCE_NORMAL = ModelResourceLocation(Resource.Custom("amulet_of_recovery"), "inventory")
|
||||
private val RESOURCE_HELD = Resource.Custom("item/amulet_of_recovery_held")
|
||||
|
||||
private lateinit var modelRegistry: MutableMap<ResourceLocation, IBakedModel>
|
||||
|
||||
@SubscribeEvent
|
||||
fun onRegisterModels(@Suppress("UNUSED_PARAMETER") e: ModelRegistryEvent){
|
||||
fun onRegisterModels(@Suppress("UNUSED_PARAMETER") e: ModelRegistryEvent) {
|
||||
ModelLoader.addSpecialModel(RESOURCE_HELD)
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onModelBake(e: ModelBakeEvent){
|
||||
fun onModelBake(e: ModelBakeEvent) {
|
||||
modelRegistry = e.modelRegistry
|
||||
modelRegistry[RESOURCE_NORMAL] = ModelItemAmuletOfRecovery(modelRegistry.getValue(RESOURCE_NORMAL))
|
||||
}
|
||||
}
|
||||
|
||||
override fun handlePerspective(transformType: TransformType, matrix: MatrixStack): IBakedModel = when(transformType){
|
||||
override fun handlePerspective(transformType: TransformType, matrix: MatrixStack): IBakedModel = when(transformType) {
|
||||
FIRST_PERSON_LEFT_HAND,
|
||||
FIRST_PERSON_RIGHT_HAND,
|
||||
THIRD_PERSON_LEFT_HAND,
|
||||
THIRD_PERSON_RIGHT_HAND ->
|
||||
modelRegistry.getOrElse(RESOURCE_HELD){ MC.instance.modelManager.missingModel }.handlePerspective(transformType, matrix)
|
||||
modelRegistry.getOrElse(RESOURCE_HELD) { MC.instance.modelManager.missingModel }.handlePerspective(transformType, matrix)
|
||||
|
||||
else ->
|
||||
super.handlePerspective(transformType, matrix)
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.render.gl.DF_ONE_MINUS_SRC_ALPHA
|
||||
@ -33,8 +34,8 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.HELMET
|
||||
|
||||
@SubscribeAllEvents(Side.CLIENT, modid = HEE.ID)
|
||||
object OverlayRenderer{
|
||||
private const val BORDER_SIZE = 4
|
||||
object OverlayRenderer {
|
||||
private const val BORDER_SIZE = 4
|
||||
private const val LINE_SPACING = 7
|
||||
|
||||
private val TEX_ENDER_GOO_OVERLAY = Resource.Custom("textures/overlay/ender_goo.png")
|
||||
@ -45,10 +46,10 @@ object OverlayRenderer{
|
||||
// Ender Goo
|
||||
|
||||
@SubscribeEvent
|
||||
fun onFogDensity(e: FogDensity){
|
||||
fun onFogDensity(e: FogDensity) {
|
||||
val inside = e.info.blockAtCamera.material
|
||||
|
||||
if (inside === Materials.ENDER_GOO || inside === Materials.PURIFIED_ENDER_GOO){
|
||||
if (inside === Materials.ENDER_GOO || inside === Materials.PURIFIED_ENDER_GOO) {
|
||||
GL.setFogMode(FOG_EXP)
|
||||
e.density = if (inside === Materials.ENDER_GOO) 0.66F else 0.06F
|
||||
e.isCanceled = true // otherwise the event is ignored
|
||||
@ -56,25 +57,25 @@ object OverlayRenderer{
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onRenderHelmetOverlayPre(e: RenderGameOverlayEvent.Pre){
|
||||
if (e.type != HELMET){
|
||||
fun onRenderHelmetOverlayPre(e: RenderGameOverlayEvent.Pre) {
|
||||
if (e.type != HELMET) {
|
||||
return
|
||||
}
|
||||
|
||||
val player = MC.player ?: return
|
||||
val inside = MC.gameRenderer.activeRenderInfo.blockAtCamera.material
|
||||
|
||||
if ((inside === Materials.ENDER_GOO || inside === Materials.PURIFIED_ENDER_GOO) && MC.settings.thirdPersonView == 0 && !player.isSpectator){
|
||||
if ((inside === Materials.ENDER_GOO || inside === Materials.PURIFIED_ENDER_GOO) && MC.settings.thirdPersonView == 0 && !player.isSpectator) {
|
||||
val window = MC.window
|
||||
val brightness = player.brightness
|
||||
|
||||
GL.color(brightness, brightness, brightness, 1F)
|
||||
GL.blendFunc(SF_SRC_ALPHA, DF_ONE_MINUS_SRC_ALPHA, SF_ONE, DF_ZERO)
|
||||
|
||||
if (inside === Materials.ENDER_GOO){
|
||||
if (inside === Materials.ENDER_GOO) {
|
||||
GL.bindTexture(TEX_ENDER_GOO_OVERLAY)
|
||||
}
|
||||
else{
|
||||
else {
|
||||
GL.bindTexture(TEX_PURIFIED_ENDER_GOO_OVERLAY)
|
||||
}
|
||||
|
||||
@ -87,11 +88,11 @@ object OverlayRenderer{
|
||||
// Energy Cluster
|
||||
|
||||
@SubscribeEvent
|
||||
fun onRenderText(@Suppress("UNUSED_PARAMETER") e: RenderGameOverlayEvent.Text){
|
||||
fun drawTextOffScreenCenter(x: Int, y: Int, line: Int, text: String, color: IntColor){
|
||||
fun onRenderText(@Suppress("UNUSED_PARAMETER") e: RenderGameOverlayEvent.Text) {
|
||||
fun drawTextOffScreenCenter(x: Int, y: Int, line: Int, text: String, color: IntColor) {
|
||||
val window = MC.window
|
||||
|
||||
with(MC.fontRenderer){
|
||||
with(MC.fontRenderer) {
|
||||
val centerX = x + (window.scaledWidth / 2)
|
||||
val centerY = y + (window.scaledHeight / 2) + (line * (LINE_SPACING + FONT_HEIGHT))
|
||||
|
||||
@ -109,7 +110,7 @@ object OverlayRenderer{
|
||||
clusterLookedAt?.let {
|
||||
clusterLookedAt = null
|
||||
|
||||
fun getQuantityString(quantity: IEnergyQuantity): String{
|
||||
fun getQuantityString(quantity: IEnergyQuantity): String {
|
||||
return if (it.energyLevel == MAX_POSSIBLE_VALUE)
|
||||
"${TextFormatting.OBFUSCATED}##${TextFormatting.RESET}"
|
||||
else
|
||||
@ -126,7 +127,7 @@ object OverlayRenderer{
|
||||
val capacity = getQuantityString(it.energyRegenCapacity)
|
||||
drawTextOffScreenCenter(0, -40, firstLine + 1, I18n.format("hee.energy.overlay.level", level, capacity), RGB(220u))
|
||||
|
||||
if (isIgnored){
|
||||
if (isIgnored) {
|
||||
drawTextOffScreenCenter(0, -40, firstLine + 2, I18n.format("hee.energy.overlay.ignored"), RGB(160u))
|
||||
}
|
||||
}
|
||||
@ -135,17 +136,17 @@ object OverlayRenderer{
|
||||
// Block outlines
|
||||
|
||||
@SubscribeEvent
|
||||
fun onRenderBlockOutline(e: DrawHighlightEvent.HighlightBlock){
|
||||
fun onRenderBlockOutline(e: DrawHighlightEvent.HighlightBlock) {
|
||||
val world = MC.world ?: return
|
||||
|
||||
val pos = e.target.pos
|
||||
val block = pos.getBlock(world)
|
||||
|
||||
if (block === ModBlocks.ENERGY_CLUSTER){
|
||||
if (block === ModBlocks.ENERGY_CLUSTER) {
|
||||
clusterLookedAt = pos.getTile(world)
|
||||
e.isCanceled = true
|
||||
}
|
||||
else if (block is BlockAbstractPortal){
|
||||
else if (block is BlockAbstractPortal) {
|
||||
e.isCanceled = true
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.render.gl.DF_ONE_MINUS_SRC_ALPHA
|
||||
@ -42,7 +43,7 @@ import kotlin.math.min
|
||||
import kotlin.math.pow
|
||||
|
||||
@SubscribeAllEvents(Side.CLIENT, modid = HEE.ID)
|
||||
object TerritoryRenderer{
|
||||
object TerritoryRenderer {
|
||||
@JvmStatic
|
||||
val environment
|
||||
get() = MC.player?.let { TerritoryType.fromX(it.posX.floorToInt()) }?.desc?.environment
|
||||
@ -58,25 +59,25 @@ object TerritoryRenderer{
|
||||
private var prevTerritory: TerritoryType? = null
|
||||
|
||||
@SubscribeEvent
|
||||
fun onClientTick(e: ClientTickEvent){
|
||||
if (e.phase == Phase.START){
|
||||
fun onClientTick(e: ClientTickEvent) {
|
||||
if (e.phase == Phase.START) {
|
||||
val player = MC.player
|
||||
|
||||
if (player != null && player.world.dimension is WorldProviderEndCustom && player.ticksExisted > 0){
|
||||
if (player != null && player.world.dimension is WorldProviderEndCustom && player.ticksExisted > 0) {
|
||||
Void.tick(player)
|
||||
Title.tick()
|
||||
|
||||
val newChunkX = player.chunkCoordX
|
||||
|
||||
if (prevChunkX != newChunkX){
|
||||
if (prevChunkX != newChunkX) {
|
||||
prevChunkX = newChunkX
|
||||
|
||||
val newTerritory = TerritoryType.fromX(player.posX.floorToInt())
|
||||
|
||||
if (prevTerritory != newTerritory){
|
||||
if (prevTerritory != newTerritory) {
|
||||
prevTerritory = newTerritory
|
||||
|
||||
if (newTerritory != null){
|
||||
if (newTerritory != null) {
|
||||
Void.reset()
|
||||
Title.display(newTerritory)
|
||||
newTerritory.desc.environment.setupClient(player)
|
||||
@ -86,7 +87,7 @@ object TerritoryRenderer{
|
||||
|
||||
prevTerritory?.desc?.environment?.tickClient(player)
|
||||
}
|
||||
else if (prevTerritory != null){
|
||||
else if (prevTerritory != null) {
|
||||
prevTerritory = null
|
||||
prevChunkX = Int.MAX_VALUE
|
||||
|
||||
@ -97,15 +98,15 @@ object TerritoryRenderer{
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
fun onFog(@Suppress("UNUSED_PARAMETER") e: RenderFogEvent){
|
||||
fun onFog(@Suppress("UNUSED_PARAMETER") e: RenderFogEvent) {
|
||||
val player = MC.player?.takeIf { it.world.dimension.type == DimensionType.THE_END } ?: return
|
||||
val territory = TerritoryType.fromPos(player)
|
||||
|
||||
if (territory == null || WorldProviderEndCustom.debugMode){
|
||||
if (territory == null || WorldProviderEndCustom.debugMode) {
|
||||
GL.setFogMode(FOG_EXP2)
|
||||
GL.setFogDensity(0F)
|
||||
}
|
||||
else{
|
||||
else {
|
||||
val env = territory.desc.environment
|
||||
val density = env.fogDensity * AbstractEnvironmentRenderer.currentFogDensityMp
|
||||
val modifier = env.fogRenderDistanceModifier * AbstractEnvironmentRenderer.currentRenderDistanceMp
|
||||
@ -120,7 +121,7 @@ object TerritoryRenderer{
|
||||
val VOID_FACTOR_VALUE
|
||||
get() = Void.voidFactor.get(MC.partialTicks)
|
||||
|
||||
private object Void{
|
||||
private object Void {
|
||||
private val VOID_PARTICLE = ParticleSpawnerCustom(
|
||||
type = ParticleVoid,
|
||||
pos = InBox(8F)
|
||||
@ -128,20 +129,20 @@ object TerritoryRenderer{
|
||||
|
||||
val voidFactor = LerpedFloat(TerritoryVoid.OUTSIDE_VOID_FACTOR)
|
||||
|
||||
init{
|
||||
if (Debug.enabled){
|
||||
init {
|
||||
if (Debug.enabled) {
|
||||
MinecraftForge.EVENT_BUS.register(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun tick(player: EntityPlayer){
|
||||
fun tick(player: EntityPlayer) {
|
||||
val factor = TerritoryVoid.getVoidFactor(player).also(voidFactor::update)
|
||||
|
||||
if (factor == TerritoryVoid.OUTSIDE_VOID_FACTOR || MC.instance.isGamePaused){
|
||||
if (factor == TerritoryVoid.OUTSIDE_VOID_FACTOR || MC.instance.isGamePaused) {
|
||||
return
|
||||
}
|
||||
|
||||
if (factor > TerritoryVoid.OUTSIDE_VOID_FACTOR){
|
||||
if (factor > TerritoryVoid.OUTSIDE_VOID_FACTOR) {
|
||||
val rand = player.rng
|
||||
|
||||
val mp = min(1F, (factor * 0.275F) + 0.275F)
|
||||
@ -152,14 +153,14 @@ object TerritoryRenderer{
|
||||
}
|
||||
}
|
||||
|
||||
fun reset(){
|
||||
fun reset() {
|
||||
voidFactor.updateImmediately(TerritoryVoid.OUTSIDE_VOID_FACTOR)
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onRenderGameOverlayText(e: RenderGameOverlayEvent.Text){
|
||||
if (MC.settings.showDebugInfo && MC.player?.dimension === HEE.dim){
|
||||
with(e.left){
|
||||
fun onRenderGameOverlayText(e: RenderGameOverlayEvent.Text) {
|
||||
if (MC.settings.showDebugInfo && MC.player?.dimension === HEE.dim) {
|
||||
with(e.left) {
|
||||
add("")
|
||||
add("End Void Factor: ${"%.3f".format(voidFactor.currentValue)}")
|
||||
}
|
||||
@ -170,7 +171,7 @@ object TerritoryRenderer{
|
||||
// Text rendering
|
||||
|
||||
@SubscribeAllEvents(Side.CLIENT, modid = HEE.ID)
|
||||
private object Title{
|
||||
private object Title {
|
||||
private const val FADE_TICKS = 22
|
||||
|
||||
private var textTime = 0
|
||||
@ -179,19 +180,19 @@ object TerritoryRenderer{
|
||||
private var textMainColor = RGB(0u)
|
||||
private var textShadowColor = RGB(0u)
|
||||
|
||||
fun display(newTerritory: TerritoryType){
|
||||
fun display(newTerritory: TerritoryType) {
|
||||
val title = I18n.format(newTerritory.translationKey)
|
||||
|
||||
textTime = 60 + (2 * title.length)
|
||||
textFade = FADE_TICKS
|
||||
textTitle = title
|
||||
|
||||
with(newTerritory.desc.colors){
|
||||
if (tokenTop.asVec.lengthSquared() > tokenBottom.asVec.lengthSquared()){
|
||||
with(newTerritory.desc.colors) {
|
||||
if (tokenTop.asVec.lengthSquared() > tokenBottom.asVec.lengthSquared()) {
|
||||
textMainColor = tokenTop
|
||||
textShadowColor = tokenBottom
|
||||
}
|
||||
else{
|
||||
else {
|
||||
textMainColor = tokenBottom
|
||||
textShadowColor = tokenTop
|
||||
}
|
||||
@ -200,20 +201,20 @@ object TerritoryRenderer{
|
||||
}
|
||||
}
|
||||
|
||||
fun tick(){
|
||||
if (textTime > 0){
|
||||
fun tick() {
|
||||
if (textTime > 0) {
|
||||
--textTime
|
||||
--textFade
|
||||
}
|
||||
}
|
||||
|
||||
fun reset(){
|
||||
fun reset() {
|
||||
textTime = 0
|
||||
}
|
||||
|
||||
@SubscribeEvent(EventPriority.HIGHEST)
|
||||
fun onRenderGameOverlayText(e: RenderGameOverlayEvent.Text){
|
||||
if (textTime == 0){
|
||||
fun onRenderGameOverlayText(e: RenderGameOverlayEvent.Text) {
|
||||
if (textTime == 0) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -222,7 +223,7 @@ object TerritoryRenderer{
|
||||
val width = resolution.scaledWidth
|
||||
val height = resolution.scaledHeight
|
||||
|
||||
val opacity = when{
|
||||
val opacity = when {
|
||||
textFade > 0 -> ((FADE_TICKS - (textFade - e.partialTicks)) / FADE_TICKS.toFloat()).coerceIn(0F, 1F)
|
||||
textTime < FADE_TICKS -> ((textTime - e.partialTicks) / FADE_TICKS.toFloat()).coerceIn(0F, 1F)
|
||||
else -> 1F
|
||||
@ -248,8 +249,8 @@ object TerritoryRenderer{
|
||||
GL.popMatrix()
|
||||
}
|
||||
|
||||
private fun drawTitle(x: Float, y: Float, color: IntColor){
|
||||
if (color.alpha > 3){ // prevents flickering alpha
|
||||
private fun drawTitle(x: Float, y: Float, color: IntColor) {
|
||||
if (color.alpha > 3) { // prevents flickering alpha
|
||||
MC.fontRenderer.drawString(textTitle, x, y, color.i)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.render.gl.DF_ONE
|
||||
import chylex.hee.client.render.gl.DF_ONE_MINUS_SRC_ALPHA
|
||||
@ -39,20 +40,20 @@ import kotlin.math.sin
|
||||
import kotlin.math.sqrt
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalController>(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<T>(dispatcher){
|
||||
private companion object{
|
||||
abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalController>(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<T>(dispatcher) {
|
||||
private companion object {
|
||||
private val TEX_BACKGROUND = Resource.Vanilla("textures/environment/end_sky.png")
|
||||
private val TEX_PARTICLE_LAYER = Resource.Custom("textures/entity/portal.png")
|
||||
|
||||
private val RENDER_TYPE_BACKGROUND = with(RenderStateBuilder()){
|
||||
private val RENDER_TYPE_BACKGROUND = with(RenderStateBuilder()) {
|
||||
tex(TEX_BACKGROUND)
|
||||
fog(FOG_ENABLED)
|
||||
blend(SF_SRC_ALPHA, DF_ONE_MINUS_SRC_ALPHA)
|
||||
buildType("hee:portal_background_bottom", DefaultVertexFormats.POSITION_COLOR_TEX, GL11.GL_QUADS, bufferSize = 256)
|
||||
}
|
||||
|
||||
private val RENDER_TYPE_LAYER = Array(16){
|
||||
with(RenderStateBuilder()){
|
||||
private val RENDER_TYPE_LAYER = Array(16) {
|
||||
with(RenderStateBuilder()) {
|
||||
tex(TEX_PARTICLE_LAYER)
|
||||
fog(FOG_ENABLED)
|
||||
blend(SF_SRC_ALPHA, DF_ONE)
|
||||
@ -60,7 +61,7 @@ abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalCo
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLayerCount(distSq: Double) = when{
|
||||
private fun getLayerCount(distSq: Double) = when {
|
||||
distSq > square(60) -> 5
|
||||
distSq > square(48) -> 7
|
||||
distSq > square(38) -> 9
|
||||
@ -76,7 +77,7 @@ abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalCo
|
||||
private var isAnimating = false
|
||||
private var animationProgress = 0F
|
||||
|
||||
private fun calculateEasing(layer: Int): Float{
|
||||
private fun calculateEasing(layer: Int): Float {
|
||||
return if (isAnimating)
|
||||
(1.1F - square(animationProgress * 4.5F - 4.816F) + 22.1F * (1F - ((layer - 1F) / 14F).pow(1.2F))).coerceIn(0F, 1F).pow(1.5F)
|
||||
else
|
||||
@ -95,21 +96,21 @@ abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalCo
|
||||
|
||||
// Rendering
|
||||
|
||||
override fun render(tile: T, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
override fun render(tile: T, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int) {
|
||||
val world = tile.world ?: return
|
||||
val pos = tile.pos
|
||||
val mat = matrix.last.matrix
|
||||
|
||||
var dist = -1
|
||||
|
||||
for(facing in Facing4){
|
||||
val testPos = pos.offsetWhile(facing, 1 until BlockAbstractPortal.MAX_SIZE){ it.getTile<TileEntityPortalInner>(world) != null }
|
||||
for(facing in Facing4) {
|
||||
val testPos = pos.offsetWhile(facing, 1 until BlockAbstractPortal.MAX_SIZE) { it.getTile<TileEntityPortalInner>(world) != null }
|
||||
val testDist = abs((testPos.x - pos.x) + (testPos.z - pos.z))
|
||||
|
||||
if (dist == -1){
|
||||
if (dist == -1) {
|
||||
dist = testDist
|
||||
}
|
||||
else if (dist != testDist){
|
||||
else if (dist != testDist) {
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -142,14 +143,14 @@ abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalCo
|
||||
val (x, y, z) = diff
|
||||
val layerCount = getLayerCount((x * x) + (y * y) + (z * z))
|
||||
|
||||
for(layer in 1..15){
|
||||
for(layer in 1..15) {
|
||||
val layerIndexRev = 16 - layer
|
||||
val colorMultiplier = 1F / (layerIndexRev + 1F)
|
||||
|
||||
controller?.let { generateNextColor(it, layer) }
|
||||
transformColor { it * colorMultiplier * calculateEasing(layer) }
|
||||
|
||||
if (layerIndexRev <= layerCount){
|
||||
if (layerIndexRev <= layerCount) {
|
||||
renderLayer(mat, buffer.getBuffer(RENDER_TYPE_LAYER[layer - 1]), layer, dist, diff)
|
||||
}
|
||||
}
|
||||
@ -159,13 +160,13 @@ abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalCo
|
||||
|
||||
// Utilities
|
||||
|
||||
private inline fun transformColor(func: (Float) -> Float){
|
||||
private inline fun transformColor(func: (Float) -> Float) {
|
||||
color[0] = func(color[0])
|
||||
color[1] = func(color[1])
|
||||
color[2] = func(color[2])
|
||||
}
|
||||
|
||||
private fun renderBackgroundBottom(mat: Matrix4f, builder: IVertexBuilder, dist: Int){
|
||||
private fun renderBackgroundBottom(mat: Matrix4f, builder: IVertexBuilder, dist: Int) {
|
||||
val sizePT = 1F + dist
|
||||
val sizeNT = -sizePT + 1F
|
||||
val yB = 0.02F
|
||||
@ -177,7 +178,7 @@ abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalCo
|
||||
builder.pos(mat, sizePT, yB, sizeNT).color().tex(texW, 0F).endVertex()
|
||||
}
|
||||
|
||||
private fun renderBackgroundSides(mat: Matrix4f, builder: IVertexBuilder, dist: Int){
|
||||
private fun renderBackgroundSides(mat: Matrix4f, builder: IVertexBuilder, dist: Int) {
|
||||
val sizePT = 1F + dist
|
||||
val sizePB = sizePT - 0.01F
|
||||
val sizeNT = -sizePT + 1F
|
||||
@ -209,7 +210,7 @@ abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalCo
|
||||
builder.pos(mat, sizeNB, yB, sizeNB).color().tex(texW, 0F).endVertex()
|
||||
}
|
||||
|
||||
private fun renderLayer(mat: Matrix4f, builder: IVertexBuilder, layer: Int, dist: Int, diff: Vec3d){
|
||||
private fun renderLayer(mat: Matrix4f, builder: IVertexBuilder, layer: Int, dist: Int, diff: Vec3d) {
|
||||
val layerIndexRev = 16 - layer
|
||||
val parallaxMp = (1F + abs(diff.y.toFloat() / 32F)).pow(0.12F)
|
||||
|
||||
@ -242,11 +243,11 @@ abstract class RenderTileAbstractPortal<T : TileEntityPortalInner, C : IPortalCo
|
||||
builder.pos(mat, sizeP, yT, sizeN).color().tex(x2, y1, cx, cy, parallaxX, parallaxZ, rotCos, rotSin).endVertex()
|
||||
}
|
||||
|
||||
private fun IVertexBuilder.color(): IVertexBuilder{
|
||||
private fun IVertexBuilder.color(): IVertexBuilder {
|
||||
return this.color(color[0], color[1], color[2], 1F)
|
||||
}
|
||||
|
||||
private fun IVertexBuilder.tex(x: Float, y: Float, cx: Float, cy: Float, ox: Float, oy: Float, rotCos: Float, rotSin: Float): IVertexBuilder{
|
||||
private fun IVertexBuilder.tex(x: Float, y: Float, cx: Float, cy: Float, ox: Float, oy: Float, rotCos: Float, rotSin: Float): IVertexBuilder {
|
||||
return this.tex(
|
||||
cx + (rotCos * (ox + x - cx)) - (rotSin * (oy + y - cy)),
|
||||
cy + (rotSin * (ox + x - cx)) + (rotCos * (oy + y - cy))
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import chylex.hee.game.block.entity.TileEntityDarkChest
|
||||
import chylex.hee.init.ModAtlases
|
||||
import chylex.hee.system.facades.Resource
|
||||
@ -12,8 +13,8 @@ import net.minecraft.state.properties.ChestType.LEFT
|
||||
import net.minecraft.state.properties.ChestType.RIGHT
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderTileDarkChest(dispatcher: TileEntityRendererDispatcher) : ChestTileEntityRenderer<TileEntityDarkChest>(dispatcher){
|
||||
companion object{
|
||||
class RenderTileDarkChest(dispatcher: TileEntityRendererDispatcher) : ChestTileEntityRenderer<TileEntityDarkChest>(dispatcher) {
|
||||
companion object {
|
||||
val TEX_SINGLE = Resource.Custom("entity/dark_chest_single")
|
||||
val TEX_DOUBLE_LEFT = Resource.Custom("entity/dark_chest_left")
|
||||
val TEX_DOUBLE_RIGHT = Resource.Custom("entity/dark_chest_right")
|
||||
@ -23,11 +24,11 @@ class RenderTileDarkChest(dispatcher: TileEntityRendererDispatcher) : ChestTileE
|
||||
private val MAT_DOUBLE_RIGHT = Material(ModAtlases.ATLAS_TILES, TEX_DOUBLE_RIGHT)
|
||||
}
|
||||
|
||||
init{
|
||||
init {
|
||||
isChristmas = false
|
||||
}
|
||||
|
||||
override fun getMaterial(tile: TileEntityDarkChest, type: ChestType) = when(type){
|
||||
override fun getMaterial(tile: TileEntityDarkChest, type: ChestType) = when(type) {
|
||||
LEFT -> MAT_DOUBLE_LEFT
|
||||
RIGHT -> MAT_DOUBLE_RIGHT
|
||||
else -> MAT_SINGLE
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.game.block.BlockAbstractPortal
|
||||
import chylex.hee.game.block.BlockAbstractPortal.IPortalController
|
||||
@ -13,25 +14,25 @@ import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderTileEndPortal(dispatcher: TileEntityRendererDispatcher) : RenderTileAbstractPortal<TileEntityPortalInner.End, IPortalController>(dispatcher){
|
||||
private object AlwaysOnController : IPortalController{
|
||||
class RenderTileEndPortal(dispatcher: TileEntityRendererDispatcher) : RenderTileAbstractPortal<TileEntityPortalInner.End, IPortalController>(dispatcher) {
|
||||
private object AlwaysOnController : IPortalController {
|
||||
override val clientAnimationProgress = LerpedFloat(1F)
|
||||
override val clientPortalOffset = LerpedFloat(0F)
|
||||
}
|
||||
|
||||
override fun findController(world: World, pos: BlockPos): IPortalController?{
|
||||
if (world.dimension.type === HEE.dim){
|
||||
override fun findController(world: World, pos: BlockPos): IPortalController? {
|
||||
if (world.dimension.type === HEE.dim) {
|
||||
return AlwaysOnController
|
||||
}
|
||||
|
||||
return pos.closestTickingTile<TileEntityEndPortalAcceptor>(world, BlockAbstractPortal.MAX_DISTANCE_FROM_FRAME)
|
||||
}
|
||||
|
||||
override fun generateSeed(controller: IPortalController): Long{
|
||||
override fun generateSeed(controller: IPortalController): Long {
|
||||
return 31100L
|
||||
}
|
||||
|
||||
override fun generateNextColor(controller: IPortalController, layer: Int){
|
||||
override fun generateNextColor(controller: IPortalController, layer: Int) {
|
||||
color[0] = (rand.nextFloat() * 0.5F) + 0.1F
|
||||
color[1] = (rand.nextFloat() * 0.5F) + 0.4F
|
||||
color[2] = (rand.nextFloat() * 0.5F) + 0.5F
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.client.render.gl.RenderStateBuilder
|
||||
import chylex.hee.client.render.gl.RenderStateBuilder.Companion.ALPHA_CUTOUT
|
||||
@ -28,15 +29,15 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderTileExperienceGate(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityExperienceGate>(dispatcher){
|
||||
class RenderTileExperienceGate(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityExperienceGate>(dispatcher) {
|
||||
@SubscribeAllEvents(Side.CLIENT, modid = HEE.ID, bus = MOD)
|
||||
companion object{
|
||||
companion object {
|
||||
private const val SPRITE_COUNT = 40
|
||||
|
||||
private val TEX = Array(SPRITE_COUNT){ Resource.Custom("block/experience_gate_top_bar_$it") }
|
||||
private val TEX = Array(SPRITE_COUNT) { Resource.Custom("block/experience_gate_top_bar_$it") }
|
||||
private val SPRITES = mutableListOf<TextureAtlasSprite>()
|
||||
|
||||
private val RENDER_TYPE_BAR = with(RenderStateBuilder()){
|
||||
private val RENDER_TYPE_BAR = with(RenderStateBuilder()) {
|
||||
tex(PlayerContainer.LOCATION_BLOCKS_TEXTURE, mipmap = true)
|
||||
alpha(ALPHA_CUTOUT)
|
||||
shade(SHADE_ENABLED)
|
||||
@ -63,31 +64,31 @@ class RenderTileExperienceGate(dispatcher: TileEntityRendererDispatcher) : TileE
|
||||
private val FRAME_OFFSETS = FRAMES.indices.map { index -> 1 + FRAMES.take(index).sumBy { it.size } }.toIntArray()
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTextureStitchPre(e: TextureStitchEvent.Pre){
|
||||
if (e.map.textureLocation == PlayerContainer.LOCATION_BLOCKS_TEXTURE){
|
||||
with(e){
|
||||
fun onTextureStitchPre(e: TextureStitchEvent.Pre) {
|
||||
if (e.map.textureLocation == PlayerContainer.LOCATION_BLOCKS_TEXTURE) {
|
||||
with(e) {
|
||||
TEX.forEach { addSprite(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTextureStitchPost(e: TextureStitchEvent.Post){
|
||||
if (e.map.textureLocation == PlayerContainer.LOCATION_BLOCKS_TEXTURE){
|
||||
fun onTextureStitchPost(e: TextureStitchEvent.Post) {
|
||||
if (e.map.textureLocation == PlayerContainer.LOCATION_BLOCKS_TEXTURE) {
|
||||
SPRITES.clear()
|
||||
|
||||
with(e.map){
|
||||
with(e.map) {
|
||||
TEX.forEach { SPRITES.add(getSprite(it)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getTexture(index: Int, frame: Int): TextureAtlasSprite?{
|
||||
private fun getTexture(index: Int, frame: Int): TextureAtlasSprite? {
|
||||
return FRAMES[index].getOrNull((frame - FRAME_OFFSETS[index]).coerceAtMost(FRAMES[index].lastIndex))?.let(SPRITES::getOrNull)
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityExperienceGate, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
override fun render(tile: TileEntityExperienceGate, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int) {
|
||||
val world = tile.world ?: return
|
||||
val pos = tile.pos
|
||||
|
||||
@ -109,7 +110,7 @@ class RenderTileExperienceGate(dispatcher: TileEntityRendererDispatcher) : TileE
|
||||
getTexture(7, frame)?.let { builder.renderTextureAt(mat, -1F, 0F, world, pos.add(-1, 1, 0), it, 0b0000, combinedOverlay) }
|
||||
}
|
||||
|
||||
private fun IVertexBuilder.renderTextureAt(mat: Matrix4f, x: Float, z: Float, world: World, pos: BlockPos, tex: TextureAtlasSprite, rot: Int, overlay: Int){
|
||||
private fun IVertexBuilder.renderTextureAt(mat: Matrix4f, x: Float, z: Float, world: World, pos: BlockPos, tex: TextureAtlasSprite, rot: Int, overlay: Int) {
|
||||
val rotX = (((rot shr 1) and 1) - 0.5F) * 1.002F
|
||||
val rotZ = (((rot shr 2) and 1) - 0.5F) * 1.002F
|
||||
|
||||
@ -118,13 +119,13 @@ class RenderTileExperienceGate(dispatcher: TileEntityRendererDispatcher) : TileE
|
||||
val v1 = tex.minV
|
||||
val v2 = tex.maxV
|
||||
|
||||
val c = if (rot and 0b1000 != 0){
|
||||
val c = if (rot and 0b1000 != 0) {
|
||||
floatArrayOf(u2, u1, u1, u2, v1, v1, v2, v2)
|
||||
}
|
||||
else if (rot and 0b0001 == 0){
|
||||
else if (rot and 0b0001 == 0) {
|
||||
floatArrayOf(u2, u2, u1, u1, v2, v1, v1, v2)
|
||||
}
|
||||
else{
|
||||
else {
|
||||
floatArrayOf(u2, u1, u1, u2, v2, v2, v1, v1)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import chylex.hee.client.model.block.ModelBlockIgneousPlate
|
||||
import chylex.hee.client.render.gl.RenderStateBuilder
|
||||
import chylex.hee.client.render.gl.RenderStateBuilder.Companion.BLEND_NONE
|
||||
@ -33,12 +34,12 @@ import net.minecraft.util.math.Vec3d
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderTileIgneousPlate(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityIgneousPlate>(dispatcher){
|
||||
private companion object{
|
||||
class RenderTileIgneousPlate(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityIgneousPlate>(dispatcher) {
|
||||
private companion object {
|
||||
private val TEX_PLATE = Resource.Custom("textures/entity/igneous_plate.png")
|
||||
|
||||
private val RENDER_TYPE_OUTER = RenderType.getEntitySolid(TEX_PLATE)
|
||||
private val RENDER_TYPE_INNER = with(RenderStateBuilder()){
|
||||
private val RENDER_TYPE_INNER = with(RenderStateBuilder()) {
|
||||
tex(TEX_PLATE)
|
||||
blend(BLEND_NONE)
|
||||
lighting(LIGHTING_DISABLED)
|
||||
@ -53,7 +54,7 @@ class RenderTileIgneousPlate(dispatcher: TileEntityRendererDispatcher) : TileEnt
|
||||
RGB(235, 23, 23).asVec
|
||||
)
|
||||
|
||||
private fun getInnerBoxColor(combinedHeat: Float): Vec3d{
|
||||
private fun getInnerBoxColor(combinedHeat: Float): Vec3d {
|
||||
val index = combinedHeat.floorToInt().coerceIn(0, COLOR_TRANSITIONS.lastIndex - 1)
|
||||
val progress = combinedHeat.toDouble() - index
|
||||
|
||||
@ -61,16 +62,16 @@ class RenderTileIgneousPlate(dispatcher: TileEntityRendererDispatcher) : TileEnt
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityIgneousPlate, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
override fun render(tile: TileEntityIgneousPlate, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int) {
|
||||
val state = tile.world?.let(tile.pos::getState)
|
||||
|
||||
if (state?.block !== ModBlocks.IGNEOUS_PLATE){
|
||||
if (state?.block !== ModBlocks.IGNEOUS_PLATE) {
|
||||
return
|
||||
}
|
||||
|
||||
matrix.push()
|
||||
|
||||
when(state[BlockIgneousPlate.FACING_NOT_DOWN]){
|
||||
when(state[BlockIgneousPlate.FACING_NOT_DOWN]) {
|
||||
UP -> {
|
||||
matrix.translateZ(1.0)
|
||||
matrix.rotateX(-90F)
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.render.gl.RenderStateBuilder
|
||||
@ -36,15 +37,15 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderTileJarODust(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityJarODust>(dispatcher){
|
||||
class RenderTileJarODust(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityJarODust>(dispatcher) {
|
||||
@SubscribeAllEvents(Side.CLIENT, modid = HEE.ID, bus = MOD)
|
||||
companion object{
|
||||
companion object {
|
||||
private val TEX_LAYER = Resource.Custom("block/dust_layer")
|
||||
private const val TEX_MP = 1.6
|
||||
|
||||
private lateinit var SPRITE_LAYER: TextureAtlasSprite
|
||||
|
||||
private val RENDER_TYPE_LAYERS = with(RenderStateBuilder()){
|
||||
private val RENDER_TYPE_LAYERS = with(RenderStateBuilder()) {
|
||||
tex(PlayerContainer.LOCATION_BLOCKS_TEXTURE, mipmap = true)
|
||||
shade(SHADE_ENABLED)
|
||||
lightmap(LIGHTMAP_ENABLED)
|
||||
@ -57,20 +58,20 @@ class RenderTileJarODust(dispatcher: TileEntityRendererDispatcher) : TileEntityR
|
||||
private const val EPSILON_XZ = 0.005
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTextureStitchPre(e: TextureStitchEvent.Pre){
|
||||
if (e.map.textureLocation == PlayerContainer.LOCATION_BLOCKS_TEXTURE){
|
||||
fun onTextureStitchPre(e: TextureStitchEvent.Pre) {
|
||||
if (e.map.textureLocation == PlayerContainer.LOCATION_BLOCKS_TEXTURE) {
|
||||
e.addSprite(TEX_LAYER)
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTextureStitchPost(e: TextureStitchEvent.Post){
|
||||
if (e.map.textureLocation == PlayerContainer.LOCATION_BLOCKS_TEXTURE){
|
||||
fun onTextureStitchPost(e: TextureStitchEvent.Post) {
|
||||
if (e.map.textureLocation == PlayerContainer.LOCATION_BLOCKS_TEXTURE) {
|
||||
SPRITE_LAYER = e.map.getSprite(TEX_LAYER)
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderLayers(layers: DustLayers, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int, renderBottom: Boolean){
|
||||
private fun renderLayers(layers: DustLayers, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int, renderBottom: Boolean) {
|
||||
val contents = layers.contents.takeUnless { it.isEmpty() } ?: return
|
||||
val unit = AABB.let { it.maxY - it.minY - (EPSILON_Y * 2) } / layers.totalCapacity
|
||||
|
||||
@ -91,7 +92,7 @@ class RenderTileJarODust(dispatcher: TileEntityRendererDispatcher) : TileEntityR
|
||||
|
||||
var relY = 0.0
|
||||
|
||||
for((index, info) in contents.withIndex()){
|
||||
for((index, info) in contents.withIndex()) {
|
||||
val (dustType, dustAmount) = info
|
||||
|
||||
val color = dustType.color
|
||||
@ -107,7 +108,7 @@ class RenderTileJarODust(dispatcher: TileEntityRendererDispatcher) : TileEntityR
|
||||
val sideG = (color[1] / 1.125F).floorToInt().coerceAtLeast(0)
|
||||
val sideB = (color[2] / 1.125F).floorToInt().coerceAtLeast(0)
|
||||
|
||||
with(builder){
|
||||
with(builder) {
|
||||
pos(mat, minX, minY, minZ).color(sideR, sideG, sideB, 255).tex(texMin, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, minY, maxZ).color(sideR, sideG, sideB, 255).tex(texMin, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, maxY, maxZ).color(sideR, sideG, sideB, 255).tex(texMax, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
@ -129,12 +130,12 @@ class RenderTileJarODust(dispatcher: TileEntityRendererDispatcher) : TileEntityR
|
||||
pos(mat, minX, maxY, maxZ).color(sideR, sideG, sideB, 255).tex(texMax, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
}
|
||||
|
||||
if (index == 0 && renderBottom){
|
||||
if (index == 0 && renderBottom) {
|
||||
val bottomR = color[0]
|
||||
val bottomG = color[1]
|
||||
val bottomB = color[2]
|
||||
|
||||
with(builder){
|
||||
with(builder) {
|
||||
pos(mat, maxX, minY, minZ).color(bottomR, bottomG, bottomB, 255).tex(maxU, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, maxX, minY, maxZ).color(bottomR, bottomG, bottomB, 255).tex(maxU, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, minY, maxZ).color(bottomR, bottomG, bottomB, 255).tex(minU, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
@ -142,12 +143,12 @@ class RenderTileJarODust(dispatcher: TileEntityRendererDispatcher) : TileEntityR
|
||||
}
|
||||
}
|
||||
|
||||
if (index == contents.lastIndex){
|
||||
if (index == contents.lastIndex) {
|
||||
val topR = (color[0] * 1.125F).floorToInt().coerceAtMost(255)
|
||||
val topG = (color[1] * 1.125F).floorToInt().coerceAtMost(255)
|
||||
val topB = (color[2] * 1.125F).floorToInt().coerceAtMost(255)
|
||||
|
||||
with(builder){
|
||||
with(builder) {
|
||||
pos(mat, minX, maxY, minZ).color(topR, topG, topB, 255).tex(minU, minV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, minX, maxY, maxZ).color(topR, topG, topB, 255).tex(minU, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
pos(mat, maxX, maxY, maxZ).color(topR, topG, topB, 255).tex(maxU, maxV).lightmap(combinedLight).overlay(combinedOverlay).endVertex()
|
||||
@ -160,31 +161,31 @@ class RenderTileJarODust(dispatcher: TileEntityRendererDispatcher) : TileEntityR
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityJarODust, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
override fun render(tile: TileEntityJarODust, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int) {
|
||||
renderLayers(tile.layers, matrix, buffer, combinedLight, combinedOverlay, renderBottom = false)
|
||||
}
|
||||
|
||||
@SubscribeAllEvents(Side.CLIENT, modid = HEE.ID, bus = MOD)
|
||||
object AsItem : ItemStackTileEntityRenderer(){
|
||||
object AsItem : ItemStackTileEntityRenderer() {
|
||||
private val RESOURCE_MODEL = Resource.Custom("block/jar_o_dust_simple")
|
||||
private lateinit var MODEL: IBakedModel
|
||||
|
||||
@SubscribeEvent
|
||||
fun onRegisterModels(@Suppress("UNUSED_PARAMETER") e: ModelRegistryEvent){
|
||||
fun onRegisterModels(@Suppress("UNUSED_PARAMETER") e: ModelRegistryEvent) {
|
||||
ModelLoader.addSpecialModel(RESOURCE_MODEL)
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onModelBake(e: ModelBakeEvent){
|
||||
fun onModelBake(e: ModelBakeEvent) {
|
||||
MODEL = e.modelRegistry.getValue(RESOURCE_MODEL)
|
||||
}
|
||||
|
||||
private val layers = DustLayers(TileEntityJarODust.DUST_CAPACITY)
|
||||
|
||||
override fun render(stack: ItemStack, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
override fun render(stack: ItemStack, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int) {
|
||||
val nbt = stack.heeTagOrNull?.getListOfCompounds(TileEntityJarODust.LAYERS_TAG)
|
||||
|
||||
if (nbt != null){
|
||||
if (nbt != null) {
|
||||
layers.deserializeNBT(nbt)
|
||||
renderLayers(layers, matrix, buffer, combinedLight, combinedOverlay, renderBottom = true)
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import chylex.hee.game.block.entity.TileEntityLootChest
|
||||
import chylex.hee.init.ModAtlases
|
||||
import chylex.hee.system.facades.Resource
|
||||
@ -10,17 +11,17 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.state.properties.ChestType
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderTileLootChest(dispatcher: TileEntityRendererDispatcher) : ChestTileEntityRenderer<TileEntityLootChest>(dispatcher){
|
||||
companion object{
|
||||
class RenderTileLootChest(dispatcher: TileEntityRendererDispatcher) : ChestTileEntityRenderer<TileEntityLootChest>(dispatcher) {
|
||||
companion object {
|
||||
val TEX = Resource.Custom("entity/loot_chest")
|
||||
private val MAT = Material(ModAtlases.ATLAS_TILES, TEX)
|
||||
}
|
||||
|
||||
init{
|
||||
init {
|
||||
isChristmas = false
|
||||
}
|
||||
|
||||
override fun getMaterial(tile: TileEntityLootChest, type: ChestType): Material{
|
||||
override fun getMaterial(tile: TileEntityLootChest, type: ChestType): Material {
|
||||
return MAT
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.model.ModelHelper
|
||||
import chylex.hee.client.render.gl.rotateX
|
||||
@ -15,14 +16,14 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderTileMinersBurialAltar(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityMinersBurialAltar>(dispatcher){
|
||||
private companion object{
|
||||
class RenderTileMinersBurialAltar(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityMinersBurialAltar>(dispatcher) {
|
||||
private companion object {
|
||||
private val PUZZLE_MEDALLION = ItemStack(ModItems.PUZZLE_MEDALLION)
|
||||
private const val SCALE_XZ = 1.85F
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityMinersBurialAltar, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
if (!tile.hasMedallion){
|
||||
override fun render(tile: TileEntityMinersBurialAltar, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int) {
|
||||
if (!tile.hasMedallion) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import net.minecraft.client.renderer.entity.model.ShulkerModel
|
||||
import net.minecraft.client.renderer.tileentity.ShulkerBoxTileEntityRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.render.gl.rotateX
|
||||
import chylex.hee.client.render.gl.rotateY
|
||||
@ -14,8 +15,8 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher
|
||||
import kotlin.math.max
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderTileSpawner(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityBaseSpawner>(dispatcher){
|
||||
override fun render(tile: TileEntityBaseSpawner, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
class RenderTileSpawner(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityBaseSpawner>(dispatcher) {
|
||||
override fun render(tile: TileEntityBaseSpawner, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int) {
|
||||
val entity = tile.clientEntity
|
||||
val scale = 0.53125F / max(entity.width, entity.height).coerceAtLeast(1F)
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.model.ModelHelper
|
||||
import chylex.hee.client.model.getQuads
|
||||
@ -26,8 +27,8 @@ import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.client.ForgeHooksClient
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderTileTable(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityBaseTable>(dispatcher){
|
||||
private companion object{
|
||||
class RenderTileTable(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityBaseTable>(dispatcher) {
|
||||
private companion object {
|
||||
private const val COLOR_SHADE = 80F / 255F
|
||||
private const val COLOR_ALPHA = 30F / 255F
|
||||
private val LIGHT = LightTexture.packLight(15, 0)
|
||||
@ -35,11 +36,11 @@ class RenderTileTable(dispatcher: TileEntityRendererDispatcher) : TileEntityRend
|
||||
private const val Y_OFFSET = 0.8
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityBaseTable, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
override fun render(tile: TileEntityBaseTable, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int) {
|
||||
val world = tile.world ?: return
|
||||
val dustType = tile.tableDustType ?: return
|
||||
|
||||
if (tile.pos.up().getTile<TileEntityJarODust>(world)?.layers?.getDustType(DustLayers.Side.BOTTOM) == dustType){
|
||||
if (tile.pos.up().getTile<TileEntityJarODust>(world)?.layers?.getDustType(DustLayers.Side.BOTTOM) == dustType) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -59,7 +60,7 @@ class RenderTileTable(dispatcher: TileEntityRendererDispatcher) : TileEntityRend
|
||||
val mat = matrix.last
|
||||
val builder = ItemRenderer.getBuffer(buffer, RenderTypeLookup.getRenderType(itemStack), true /* isItem */, false /* hasGlint */)
|
||||
|
||||
for(quad in itemModel.getQuads()){
|
||||
for(quad in itemModel.getQuads()) {
|
||||
builder.addVertexData(mat, quad, COLOR_SHADE, COLOR_SHADE, COLOR_SHADE, COLOR_ALPHA, LIGHT, OverlayTexture.NO_OVERLAY)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.model.ModelHelper
|
||||
import chylex.hee.client.render.gl.DF_ONE_MINUS_SRC_ALPHA
|
||||
@ -39,11 +40,11 @@ import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderTileTablePedestal(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityTablePedestal>(dispatcher){
|
||||
private companion object{
|
||||
class RenderTileTablePedestal(dispatcher: TileEntityRendererDispatcher) : TileEntityRenderer<TileEntityTablePedestal>(dispatcher) {
|
||||
private companion object {
|
||||
private val RAND = Random()
|
||||
|
||||
private val RENDER_TYPE_SHADOW = with(RenderStateBuilder()){
|
||||
private val RENDER_TYPE_SHADOW = with(RenderStateBuilder()) {
|
||||
tex(Resource.Vanilla("textures/misc/shadow.png"))
|
||||
blend(SF_SRC_ALPHA, DF_ONE_MINUS_SRC_ALPHA, SF_ONE, DF_ZERO)
|
||||
lighting(LIGHTING_ENABLED)
|
||||
@ -67,7 +68,7 @@ class RenderTileTablePedestal(dispatcher: TileEntityRendererDispatcher) : TileEn
|
||||
map { (it - 0.5F) * section }
|
||||
}
|
||||
|
||||
private fun getItemModelCount(stackSize: Int) = when{
|
||||
private fun getItemModelCount(stackSize: Int) = when {
|
||||
stackSize > 48 -> 5
|
||||
stackSize > 32 -> 4
|
||||
stackSize > 16 -> 3
|
||||
@ -76,7 +77,7 @@ class RenderTileTablePedestal(dispatcher: TileEntityRendererDispatcher) : TileEn
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(tile: TileEntityTablePedestal, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
override fun render(tile: TileEntityTablePedestal, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int) {
|
||||
val itemRenderer = MC.itemRenderer
|
||||
|
||||
val pos = tile.pos
|
||||
@ -95,18 +96,18 @@ class RenderTileTablePedestal(dispatcher: TileEntityRendererDispatcher) : TileEn
|
||||
else
|
||||
0F
|
||||
|
||||
for((index, stack) in stacks.withIndex()){
|
||||
for((index, stack) in stacks.withIndex()) {
|
||||
renderItemStack(matrix, buffer, itemRenderer, stack, index, itemRotation, baseSeed, offsetAngleIndices, shadowAlpha, combinedLight)
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderItemStack(matrix: MatrixStack, buffer: IRenderTypeBuffer, renderer: ItemRenderer, stack: ItemStack, index: Int, baseRotation: Float, baseSeed: Long, offsetAngleIndices: MutableList<Float>, shadowAlpha: Float, combinedLight: Int){
|
||||
private fun renderItemStack(matrix: MatrixStack, buffer: IRenderTypeBuffer, renderer: ItemRenderer, stack: ItemStack, index: Int, baseRotation: Float, baseSeed: Long, offsetAngleIndices: MutableList<Float>, shadowAlpha: Float, combinedLight: Int) {
|
||||
matrix.push()
|
||||
|
||||
var offsetY = 0F
|
||||
var rotationMp = 1F
|
||||
|
||||
if (index > 0 && offsetAngleIndices.isNotEmpty()){
|
||||
if (index > 0 && offsetAngleIndices.isNotEmpty()) {
|
||||
val seed = baseSeed + (Item.getIdFromItem(stack.item) xor (33867 shl index))
|
||||
RAND.setSeed(seed)
|
||||
|
||||
@ -120,7 +121,7 @@ class RenderTileTablePedestal(dispatcher: TileEntityRendererDispatcher) : TileEn
|
||||
rotationMp = RAND.nextFloat(0.4F, 1.2F)
|
||||
}
|
||||
|
||||
if (shadowAlpha > 0F){
|
||||
if (shadowAlpha > 0F) {
|
||||
renderShadow(buffer, matrix.last.matrix, shadowAlpha)
|
||||
}
|
||||
|
||||
@ -136,30 +137,30 @@ class RenderTileTablePedestal(dispatcher: TileEntityRendererDispatcher) : TileEn
|
||||
matrix.pop()
|
||||
}
|
||||
|
||||
private fun renderItemWithSpread(matrix: MatrixStack, buffer: IRenderTypeBuffer, renderer: ItemRenderer, stack: ItemStack, model: IBakedModel, isModel3D: Boolean, combinedLight: Int){
|
||||
private fun renderItemWithSpread(matrix: MatrixStack, buffer: IRenderTypeBuffer, renderer: ItemRenderer, stack: ItemStack, model: IBakedModel, isModel3D: Boolean, combinedLight: Int) {
|
||||
val extraModels = getItemModelCount(stack.size) - 1
|
||||
|
||||
if (extraModels > 0){
|
||||
if (extraModels > 0) {
|
||||
RAND.setSeed(Item.getIdFromItem(stack.item).toLong())
|
||||
|
||||
if (!isModel3D){
|
||||
if (!isModel3D) {
|
||||
matrix.translateZ(-SPREAD_DEPTH_PER_2D_MODEL * (extraModels / 2.0))
|
||||
}
|
||||
}
|
||||
|
||||
renderer.renderItem(stack, GROUND, false, matrix, buffer, combinedLight, OverlayTexture.NO_OVERLAY, model)
|
||||
|
||||
repeat(extraModels){
|
||||
repeat(extraModels) {
|
||||
matrix.push()
|
||||
|
||||
if (isModel3D){
|
||||
if (isModel3D) {
|
||||
matrix.translate(
|
||||
RAND.nextFloat(-SPREAD_RAND_3D_XZ, SPREAD_RAND_3D_XZ),
|
||||
RAND.nextFloat(-SPREAD_RAND_3D_Y, SPREAD_RAND_3D_Y),
|
||||
RAND.nextFloat(-SPREAD_RAND_3D_XZ, SPREAD_RAND_3D_XZ)
|
||||
)
|
||||
}
|
||||
else{
|
||||
else {
|
||||
matrix.translate(
|
||||
RAND.nextFloat(-SPREAD_RAND_2D, SPREAD_RAND_2D),
|
||||
RAND.nextFloat(-SPREAD_RAND_2D, SPREAD_RAND_2D),
|
||||
@ -172,8 +173,8 @@ class RenderTileTablePedestal(dispatcher: TileEntityRendererDispatcher) : TileEn
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderShadow(buffer: IRenderTypeBuffer, mat: Matrix4f, alpha: Float){
|
||||
with(buffer.getBuffer(RENDER_TYPE_SHADOW)){
|
||||
private fun renderShadow(buffer: IRenderTypeBuffer, mat: Matrix4f, alpha: Float) {
|
||||
with(buffer.getBuffer(RENDER_TYPE_SHADOW)) {
|
||||
pos(mat, SHADOW_XZ_MIN, SHADOW_Y, SHADOW_XZ_MIN).color(1F, 1F, 1F, alpha).tex(0F, 0F).endVertex()
|
||||
pos(mat, SHADOW_XZ_MIN, SHADOW_Y, SHADOW_XZ_MAX).color(1F, 1F, 1F, alpha).tex(0F, 1F).endVertex()
|
||||
pos(mat, SHADOW_XZ_MAX, SHADOW_Y, SHADOW_XZ_MAX).color(1F, 1F, 1F, alpha).tex(1F, 1F).endVertex()
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.block
|
||||
|
||||
import chylex.hee.game.block.BlockAbstractPortal
|
||||
import chylex.hee.game.block.BlockVoidPortalInner.Companion.TYPE
|
||||
import chylex.hee.game.block.BlockVoidPortalInner.ITerritoryInstanceFactory
|
||||
@ -20,9 +21,9 @@ import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderTileVoidPortal(dispatcher: TileEntityRendererDispatcher) : RenderTileAbstractPortal<TileEntityPortalInner.Void, IVoidPortalController>(dispatcher){
|
||||
private object ActiveReturnController : IVoidPortalController{
|
||||
override val currentInstanceFactory = object : ITerritoryInstanceFactory{
|
||||
class RenderTileVoidPortal(dispatcher: TileEntityRendererDispatcher) : RenderTileAbstractPortal<TileEntityPortalInner.Void, IVoidPortalController>(dispatcher) {
|
||||
private object ActiveReturnController : IVoidPortalController {
|
||||
override val currentInstanceFactory = object : ITerritoryInstanceFactory {
|
||||
override val territory = THE_HUB_INSTANCE.territory
|
||||
override fun create(entity: Entity) = THE_HUB_INSTANCE
|
||||
}
|
||||
@ -31,17 +32,17 @@ class RenderTileVoidPortal(dispatcher: TileEntityRendererDispatcher) : RenderTil
|
||||
override val clientPortalOffset = LerpedFloat(0F)
|
||||
}
|
||||
|
||||
override fun findController(world: World, pos: BlockPos) = when(pos.getState(world).takeIf { it.block === ModBlocks.VOID_PORTAL_INNER }?.get(TYPE)){
|
||||
HUB -> pos.closestTickingTile<TileEntityVoidPortalStorage>(world, BlockAbstractPortal.MAX_DISTANCE_FROM_FRAME)
|
||||
override fun findController(world: World, pos: BlockPos) = when(pos.getState(world).takeIf { it.block === ModBlocks.VOID_PORTAL_INNER }?.get(TYPE)) {
|
||||
HUB -> pos.closestTickingTile<TileEntityVoidPortalStorage>(world, BlockAbstractPortal.MAX_DISTANCE_FROM_FRAME)
|
||||
RETURN_ACTIVE -> ActiveReturnController
|
||||
else -> null
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun generateSeed(controller: IVoidPortalController): Long{
|
||||
override fun generateSeed(controller: IVoidPortalController): Long {
|
||||
return controller.currentInstanceFactory?.territory?.desc?.colors?.portalSeed ?: 0L
|
||||
}
|
||||
|
||||
override fun generateNextColor(controller: IVoidPortalController, layer: Int){
|
||||
override fun generateNextColor(controller: IVoidPortalController, layer: Int) {
|
||||
controller.currentInstanceFactory?.territory?.desc?.colors?.nextPortalColor(rand, color)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.client.model.entity.ModelEntityBossEnderEye
|
||||
import chylex.hee.client.model.entity.ModelEntityBossEnderEye.SCALE
|
||||
import chylex.hee.client.render.entity.layer.LayerEnderEyeLaser
|
||||
@ -13,19 +14,19 @@ import net.minecraft.client.renderer.entity.MobRenderer
|
||||
import net.minecraft.util.ResourceLocation
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityBossEnderEye(manager: EntityRendererManager) : MobRenderer<EntityBossEnderEye, ModelEntityBossEnderEye>(manager, ModelEntityBossEnderEye, SCALE){
|
||||
class RenderEntityBossEnderEye(manager: EntityRendererManager) : MobRenderer<EntityBossEnderEye, ModelEntityBossEnderEye>(manager, ModelEntityBossEnderEye, SCALE) {
|
||||
private val texture = Resource.Custom("textures/entity/ender_eye.png")
|
||||
|
||||
init{
|
||||
init {
|
||||
addLayer(LayerEnderEyeLaser(this))
|
||||
}
|
||||
|
||||
override fun preRenderCallback(entity: EntityBossEnderEye, matrix: MatrixStack, partialTicks: Float){
|
||||
override fun preRenderCallback(entity: EntityBossEnderEye, matrix: MatrixStack, partialTicks: Float) {
|
||||
matrix.scale(SCALE)
|
||||
super.preRenderCallback(entity, matrix, partialTicks)
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityBossEnderEye): ResourceLocation{
|
||||
override fun getEntityTexture(entity: EntityBossEnderEye): ResourceLocation {
|
||||
return texture
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.system.forge.Side
|
||||
import chylex.hee.system.forge.Sided
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.system.forge.Side
|
||||
import chylex.hee.system.forge.Sided
|
||||
@ -6,6 +7,6 @@ import net.minecraft.client.renderer.entity.EntityRendererManager
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityItemNoBob(manager: EntityRendererManager) : ItemRenderer(manager, MC.itemRenderer){
|
||||
class RenderEntityItemNoBob(manager: EntityRendererManager) : ItemRenderer(manager, MC.itemRenderer) {
|
||||
override fun shouldBob() = false
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.client.render.gl.DF_ONE_MINUS_SRC_ALPHA
|
||||
import chylex.hee.client.render.gl.RenderStateBuilder
|
||||
import chylex.hee.client.render.gl.RenderStateBuilder.Companion.CULL_DISABLED
|
||||
@ -27,8 +28,8 @@ import org.lwjgl.opengl.GL11
|
||||
import java.util.Random
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
open class RenderEntityMobAbstractEnderman(manager: EntityRendererManager) : EndermanRenderer(manager){
|
||||
private fun RENDER_TYPE_CLONE(tex: ResourceLocation) = with(RenderStateBuilder()){
|
||||
open class RenderEntityMobAbstractEnderman(manager: EntityRendererManager) : EndermanRenderer(manager) {
|
||||
private fun RENDER_TYPE_CLONE(tex: ResourceLocation) = with(RenderStateBuilder()) {
|
||||
tex(tex)
|
||||
blend(SF_SRC_ALPHA, DF_ONE_MINUS_SRC_ALPHA)
|
||||
lighting(LIGHTING_ENABLED)
|
||||
@ -44,9 +45,9 @@ open class RenderEntityMobAbstractEnderman(manager: EntityRendererManager) : End
|
||||
private val originalLayerList: List<LayerRenderer<EntityEnderman, EndermanModel<EntityEnderman>>>
|
||||
private var isRenderingClone = false
|
||||
|
||||
init{
|
||||
entityModel = object : EndermanModel<EntityEnderman>(0F){
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float){
|
||||
init {
|
||||
entityModel = object : EndermanModel<EntityEnderman>(0F) {
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float) {
|
||||
super.render(matrix, builder, combinedLight, combinedOverlay, red, green, blue, if (isRenderingClone) rand.nextFloat(0.05F, 0.3F) else alpha)
|
||||
}
|
||||
}
|
||||
@ -54,12 +55,12 @@ open class RenderEntityMobAbstractEnderman(manager: EntityRendererManager) : End
|
||||
originalLayerList = ArrayList(layerRenderers)
|
||||
}
|
||||
|
||||
override fun render(entity: EntityEnderman, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int){
|
||||
if (entity !is EntityMobAbstractEnderman){
|
||||
override fun render(entity: EntityEnderman, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int) {
|
||||
if (entity !is EntityMobAbstractEnderman) {
|
||||
return
|
||||
}
|
||||
|
||||
if (entity.isShaking){
|
||||
if (entity.isShaking) {
|
||||
rand.setSeed(entity.world.totalTime)
|
||||
|
||||
matrix.push()
|
||||
@ -67,13 +68,13 @@ open class RenderEntityMobAbstractEnderman(manager: EntityRendererManager) : End
|
||||
super.render(entity, yaw, partialTicks, matrix, buffer, combinedLight)
|
||||
matrix.pop()
|
||||
}
|
||||
else{
|
||||
else {
|
||||
super.render(entity, yaw, partialTicks, matrix, buffer, combinedLight)
|
||||
}
|
||||
|
||||
val cloneCount = getCloneCount(entity)
|
||||
|
||||
if (cloneCount > 0){
|
||||
if (cloneCount > 0) {
|
||||
rand.setSeed(entity.world.totalTime * 2L / 3L)
|
||||
|
||||
val prevPrevYaw = entity.prevRotationYawHead
|
||||
@ -85,8 +86,8 @@ open class RenderEntityMobAbstractEnderman(manager: EntityRendererManager) : End
|
||||
isRenderingClone = true
|
||||
layerRenderers.clear()
|
||||
|
||||
repeat(cloneCount){
|
||||
if (rand.nextInt(3) == 0){
|
||||
repeat(cloneCount) {
|
||||
if (rand.nextInt(3) == 0) {
|
||||
entity.rotationYawHead += rand.nextFloat(-45F, 45F)
|
||||
entity.prevRotationYawHead = entity.rotationYawHead
|
||||
|
||||
@ -111,11 +112,11 @@ open class RenderEntityMobAbstractEnderman(manager: EntityRendererManager) : End
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun getCloneCount(entity: EntityMobAbstractEnderman): Int{
|
||||
protected open fun getCloneCount(entity: EntityMobAbstractEnderman): Int {
|
||||
return if (entity.hurtTime == 0 && entity.isAggro) 2 else 0
|
||||
}
|
||||
|
||||
override fun func_230042_a_(entity: EntityEnderman, isVisible: Boolean, isTranslucent: Boolean): RenderType?{
|
||||
override fun func_230042_a_(entity: EntityEnderman, isVisible: Boolean, isTranslucent: Boolean): RenderType? {
|
||||
return if (isRenderingClone)
|
||||
RENDER_TYPE_CLONE(getEntityTexture(entity))
|
||||
else
|
||||
|
@ -1,12 +1,13 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.game.entity.living.EntityMobAbstractEnderman
|
||||
import chylex.hee.system.forge.Side
|
||||
import chylex.hee.system.forge.Sided
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityMobAngryEnderman(manager: EntityRendererManager) : RenderEntityMobAbstractEnderman(manager){
|
||||
override fun getCloneCount(entity: EntityMobAbstractEnderman) = when{
|
||||
class RenderEntityMobAngryEnderman(manager: EntityRendererManager) : RenderEntityMobAbstractEnderman(manager) {
|
||||
override fun getCloneCount(entity: EntityMobAbstractEnderman) = when {
|
||||
entity.hurtTime != 0 -> 0
|
||||
entity.isAggro -> 2
|
||||
else -> 1
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.model.ModelHelper
|
||||
import chylex.hee.client.model.entity.ModelEntityMobBlobby
|
||||
@ -37,28 +38,28 @@ import net.minecraftforge.client.ForgeHooksClient
|
||||
import java.util.Random
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityMobBlobby(manager: EntityRendererManager) : MobRenderer<EntityMobBlobby, ModelEntityMobBlobby>(manager, ModelEntityMobBlobby, 0.27F){
|
||||
class RenderEntityMobBlobby(manager: EntityRendererManager) : MobRenderer<EntityMobBlobby, ModelEntityMobBlobby>(manager, ModelEntityMobBlobby, 0.27F) {
|
||||
private val texture = Resource.Custom("textures/entity/blobby.png")
|
||||
private val renderType = RenderType.getEntityTranslucent(texture)
|
||||
private val fallbackStack = ItemStack(Blocks.BEDROCK)
|
||||
private val rand = Random()
|
||||
|
||||
init{
|
||||
init {
|
||||
shadowOpaque = 0.6F
|
||||
}
|
||||
|
||||
override fun preRenderCallback(entity: EntityMobBlobby, matrix: MatrixStack, partialTicks: Float){
|
||||
override fun preRenderCallback(entity: EntityMobBlobby, matrix: MatrixStack, partialTicks: Float) {
|
||||
matrix.scale(entity.scale * GLOBAL_SCALE)
|
||||
matrix.scaleY(1F + entity.renderSquishClient.get(partialTicks))
|
||||
|
||||
super.preRenderCallback(entity, matrix, partialTicks)
|
||||
}
|
||||
|
||||
override fun render(entity: EntityMobBlobby, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int){
|
||||
override fun render(entity: EntityMobBlobby, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int) {
|
||||
val scale = entity.scale
|
||||
val stack = entity.heldItem
|
||||
|
||||
if (stack.isNotEmpty && entity.deathTime == 0){
|
||||
if (stack.isNotEmpty && entity.deathTime == 0) {
|
||||
renderItemInGel(stack, entity, matrix, buffer, combinedLight)
|
||||
}
|
||||
|
||||
@ -66,15 +67,15 @@ class RenderEntityMobBlobby(manager: EntityRendererManager) : MobRenderer<Entity
|
||||
super.render(entity, yaw, partialTicks, matrix, buffer, combinedLight)
|
||||
}
|
||||
|
||||
override fun func_230042_a_(entity: EntityMobBlobby, isVisible: Boolean, isTranslucent: Boolean): RenderType{
|
||||
override fun func_230042_a_(entity: EntityMobBlobby, isVisible: Boolean, isTranslucent: Boolean): RenderType {
|
||||
return renderType
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityMobBlobby): ResourceLocation{
|
||||
override fun getEntityTexture(entity: EntityMobBlobby): ResourceLocation {
|
||||
return texture
|
||||
}
|
||||
|
||||
private fun renderItemInGel(stack: ItemStack, entity: EntityMobBlobby, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int){
|
||||
private fun renderItemInGel(stack: ItemStack, entity: EntityMobBlobby, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int) {
|
||||
val scale = entity.scale
|
||||
|
||||
matrix.push()
|
||||
@ -84,12 +85,12 @@ class RenderEntityMobBlobby(manager: EntityRendererManager) : MobRenderer<Entity
|
||||
val modelRotOff: Double
|
||||
val modelScale: Float
|
||||
|
||||
if (model.isGui3d){
|
||||
if (model.isGui3d) {
|
||||
modelYOff = 0.75
|
||||
modelRotOff = 0.0
|
||||
modelScale = 0.75F
|
||||
}
|
||||
else{
|
||||
else {
|
||||
modelYOff = 0.5
|
||||
modelRotOff = 0.1
|
||||
modelScale = 0.66F
|
||||
@ -105,25 +106,25 @@ class RenderEntityMobBlobby(manager: EntityRendererManager) : MobRenderer<Entity
|
||||
matrix.scale(modelScale * scale)
|
||||
matrix.translate(-0.5, entity.height * scale * 0.5 - modelYOff, -0.5)
|
||||
|
||||
if (model.isBuiltInRenderer){
|
||||
val overrideType = when((stack.item as? ItemBlock)?.block){
|
||||
if (model.isBuiltInRenderer) {
|
||||
val overrideType = when((stack.item as? ItemBlock)?.block) {
|
||||
is AbstractChestBlock<*> -> RenderType.getEntityTranslucentCull(Atlases.CHEST_ATLAS)
|
||||
else -> null // POLISH implement more special cases
|
||||
else -> null // POLISH implement more special cases
|
||||
}
|
||||
|
||||
if (overrideType != null){
|
||||
if (overrideType != null) {
|
||||
stack.item.itemStackTileEntityRenderer.render(stack, matrix, { buffer.getBuffer(overrideType) }, combinedLight, OverlayTexture.NO_OVERLAY)
|
||||
}
|
||||
else if (stack !== fallbackStack){
|
||||
else if (stack !== fallbackStack) {
|
||||
matrix.pop()
|
||||
renderItemInGel(fallbackStack, entity, matrix, buffer, combinedLight)
|
||||
return
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
val builder = buffer.getBuffer(Atlases.getTranslucentCullBlockType())
|
||||
|
||||
for(facing in Facing6){
|
||||
for(facing in Facing6) {
|
||||
renderItemQuads(stack, model, facing, matrix, builder, combinedLight)
|
||||
}
|
||||
|
||||
@ -133,7 +134,7 @@ class RenderEntityMobBlobby(manager: EntityRendererManager) : MobRenderer<Entity
|
||||
matrix.pop()
|
||||
}
|
||||
|
||||
private fun renderItemQuads(stack: ItemStack, model: IBakedModel, facing: Direction?, matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int){
|
||||
private fun renderItemQuads(stack: ItemStack, model: IBakedModel, facing: Direction?, matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int) {
|
||||
MC.itemRenderer.renderQuads(matrix, builder, model.getQuads(facing), stack, combinedLight, OverlayTexture.NO_OVERLAY)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.client.render.entity.layer.LayerSpiderlingEyes
|
||||
import chylex.hee.client.render.gl.scale
|
||||
import chylex.hee.game.entity.living.EntityMobSpiderling
|
||||
@ -18,27 +19,27 @@ import net.minecraft.world.LightType.BLOCK
|
||||
import net.minecraft.world.LightType.SKY
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityMobSpiderling(manager: EntityRendererManager) : MobRenderer<EntityMobSpiderling, SpiderModel<EntityMobSpiderling>>(manager, SpiderModel(), 0.5F){
|
||||
class RenderEntityMobSpiderling(manager: EntityRendererManager) : MobRenderer<EntityMobSpiderling, SpiderModel<EntityMobSpiderling>>(manager, SpiderModel(), 0.5F) {
|
||||
private val texture = Resource.Custom("textures/entity/spiderling.png")
|
||||
|
||||
init{
|
||||
init {
|
||||
addLayer(LayerSpiderlingEyes(this, (entityModel as SpiderModel).spiderHead))
|
||||
}
|
||||
|
||||
override fun preRenderCallback(entity: EntityMobSpiderling, matrix: MatrixStack, partialTicks: Float){
|
||||
override fun preRenderCallback(entity: EntityMobSpiderling, matrix: MatrixStack, partialTicks: Float) {
|
||||
matrix.scale(0.5F)
|
||||
super.preRenderCallback(entity, matrix, partialTicks)
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityMobSpiderling): ResourceLocation{
|
||||
override fun getEntityTexture(entity: EntityMobSpiderling): ResourceLocation {
|
||||
return texture
|
||||
}
|
||||
|
||||
override fun getPackedLight(entity: EntityMobSpiderling, partialTicks: Float): Int{
|
||||
override fun getPackedLight(entity: EntityMobSpiderling, partialTicks: Float): Int {
|
||||
val world = entity.world
|
||||
val pos = Pos(entity)
|
||||
|
||||
if (!pos.isLoaded(world)){
|
||||
if (!pos.isLoaded(world)) {
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ class RenderEntityMobSpiderling(manager: EntityRendererManager) : MobRenderer<En
|
||||
return LightTexture.packLight(sky, block)
|
||||
}
|
||||
|
||||
override fun getDeathMaxRotation(entity: EntityMobSpiderling): Float{
|
||||
override fun getDeathMaxRotation(entity: EntityMobSpiderling): Float {
|
||||
return 180F
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.client.model.entity.ModelEntityMobUndread
|
||||
import chylex.hee.game.entity.living.EntityMobUndread
|
||||
import chylex.hee.system.facades.Resource
|
||||
@ -12,23 +13,23 @@ import net.minecraft.client.renderer.entity.model.AbstractZombieModel
|
||||
import net.minecraft.util.ResourceLocation
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityMobUndread(manager: EntityRendererManager) : BipedRenderer<EntityMobUndread, AbstractZombieModel<EntityMobUndread>>(manager, ModelEntityMobUndread(), 0.5F){
|
||||
class RenderEntityMobUndread(manager: EntityRendererManager) : BipedRenderer<EntityMobUndread, AbstractZombieModel<EntityMobUndread>>(manager, ModelEntityMobUndread(), 0.5F) {
|
||||
private val texture = Resource.Custom("textures/entity/undread.png")
|
||||
|
||||
init{
|
||||
init {
|
||||
addLayer(BipedArmorLayer(this, ModelEntityMobUndread(0.5125F, true), ModelEntityMobUndread(1F, true)))
|
||||
}
|
||||
|
||||
override fun preRenderCallback(entity: EntityMobUndread, matrix: MatrixStack, partialTicks: Float){
|
||||
override fun preRenderCallback(entity: EntityMobUndread, matrix: MatrixStack, partialTicks: Float) {
|
||||
matrix.scale(1.025F, 0.965F, 1.025F)
|
||||
super.preRenderCallback(entity, matrix, partialTicks)
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityMobUndread): ResourceLocation{
|
||||
override fun getEntityTexture(entity: EntityMobUndread): ResourceLocation {
|
||||
return texture
|
||||
}
|
||||
|
||||
override fun getDeathMaxRotation(entity: EntityMobUndread): Float{
|
||||
override fun getDeathMaxRotation(entity: EntityMobUndread): Float {
|
||||
val uuid = entity.uniqueID
|
||||
return 15F * (if ((uuid.leastSignificantBits % 2L) xor (uuid.mostSignificantBits % 2L) == 0L) 1F else -1F)
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.system.facades.Resource
|
||||
import chylex.hee.system.forge.Side
|
||||
import chylex.hee.system.forge.Sided
|
||||
@ -8,10 +9,10 @@ import net.minecraft.client.renderer.entity.EntityRendererManager
|
||||
import net.minecraft.util.ResourceLocation
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityMobVampireBat(manager: EntityRendererManager) : BatRenderer(manager){
|
||||
class RenderEntityMobVampireBat(manager: EntityRendererManager) : BatRenderer(manager) {
|
||||
private val texture = Resource.Custom("textures/entity/vampire_bat.png")
|
||||
|
||||
override fun getEntityTexture(entity: EntityBat): ResourceLocation{
|
||||
override fun getEntityTexture(entity: EntityBat): ResourceLocation {
|
||||
return texture
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.render.gl.scale
|
||||
import chylex.hee.game.entity.living.EntityMobVillagerDying
|
||||
@ -22,11 +23,11 @@ import java.util.Random
|
||||
import kotlin.math.min
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityMobVillagerDying(manager: EntityRendererManager) : MobRenderer<EntityMobVillagerDying, VillagerModel<EntityMobVillagerDying>>(manager, Model, 0.5F){
|
||||
private object Model : VillagerModel<EntityMobVillagerDying>(0F){
|
||||
class RenderEntityMobVillagerDying(manager: EntityRendererManager) : MobRenderer<EntityMobVillagerDying, VillagerModel<EntityMobVillagerDying>>(manager, Model, 0.5F) {
|
||||
private object Model : VillagerModel<EntityMobVillagerDying>(0F) {
|
||||
private val overrideOverlay = OverlayTexture.getPackedUV(OverlayTexture.getU(0F), OverlayTexture.getV(false)) // disable red hurt overlay
|
||||
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float){
|
||||
override fun render(matrix: MatrixStack, builder: IVertexBuilder, combinedLight: Int, combinedOverlay: Int, red: Float, green: Float, blue: Float, alpha: Float) {
|
||||
super.render(matrix, builder, combinedLight, overrideOverlay, red, green, blue, alpha)
|
||||
}
|
||||
}
|
||||
@ -34,13 +35,13 @@ class RenderEntityMobVillagerDying(manager: EntityRendererManager) : MobRenderer
|
||||
private val rand = Random()
|
||||
private val texture = Resource.Vanilla("textures/entity/villager/villager.png")
|
||||
|
||||
init{
|
||||
init {
|
||||
addLayer(HeadLayer(this))
|
||||
addLayer(VillagerLevelPendantLayer(this, MC.instance.resourceManager as IReloadableResourceManager, "villager"))
|
||||
addLayer(CrossedArmsItemLayer(this))
|
||||
}
|
||||
|
||||
override fun render(entity: EntityMobVillagerDying, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int){
|
||||
override fun render(entity: EntityMobVillagerDying, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int) {
|
||||
rand.setSeed(entity.world.totalTime)
|
||||
val mp = min(1F, entity.deathTime / 50F) * 0.005F
|
||||
|
||||
@ -50,18 +51,18 @@ class RenderEntityMobVillagerDying(manager: EntityRendererManager) : MobRenderer
|
||||
matrix.pop()
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityMobVillagerDying): ResourceLocation{
|
||||
override fun getEntityTexture(entity: EntityMobVillagerDying): ResourceLocation {
|
||||
return texture
|
||||
}
|
||||
|
||||
override fun preRenderCallback(entity: EntityMobVillagerDying, matrix: MatrixStack, partialTicks: Float){
|
||||
override fun preRenderCallback(entity: EntityMobVillagerDying, matrix: MatrixStack, partialTicks: Float) {
|
||||
val scale: Float
|
||||
|
||||
if (entity.isChild){
|
||||
if (entity.isChild) {
|
||||
scale = 0.46875F
|
||||
shadowSize = 0.25F
|
||||
}
|
||||
else{
|
||||
else {
|
||||
scale = 0.9375F
|
||||
shadowSize = 0.5F
|
||||
}
|
||||
@ -69,7 +70,7 @@ class RenderEntityMobVillagerDying(manager: EntityRendererManager) : MobRenderer
|
||||
matrix.scale(scale)
|
||||
}
|
||||
|
||||
override fun getDeathMaxRotation(entity: EntityMobVillagerDying): Float{
|
||||
override fun getDeathMaxRotation(entity: EntityMobVillagerDying): Float {
|
||||
return 0F
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.system.forge.Side
|
||||
import chylex.hee.system.forge.Sided
|
||||
import net.minecraft.client.renderer.culling.ClippingHelperImpl
|
||||
@ -8,7 +9,7 @@ import net.minecraft.entity.Entity
|
||||
import net.minecraft.util.ResourceLocation
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityNothing(manager: EntityRendererManager) : EntityRenderer<Entity>(manager){
|
||||
class RenderEntityNothing(manager: EntityRendererManager) : EntityRenderer<Entity>(manager) {
|
||||
override fun shouldRender(entity: Entity, camera: ClippingHelperImpl, camX: Double, camY: Double, camZ: Double) = false
|
||||
override fun getEntityTexture(entity: Entity): ResourceLocation? = null
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.model.ModelHelper
|
||||
import chylex.hee.client.render.gl.rotateY
|
||||
@ -18,10 +19,10 @@ import net.minecraft.item.Items
|
||||
import net.minecraft.util.ResourceLocation
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityProjectileEyeOfEnder(manager: EntityRendererManager) : EntityRenderer<EntityProjectileEyeOfEnder>(manager){
|
||||
class RenderEntityProjectileEyeOfEnder(manager: EntityRendererManager) : EntityRenderer<EntityProjectileEyeOfEnder>(manager) {
|
||||
private val renderedItem = ItemStack(Items.ENDER_EYE)
|
||||
|
||||
override fun render(entity: EntityProjectileEyeOfEnder, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int){
|
||||
override fun render(entity: EntityProjectileEyeOfEnder, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int) {
|
||||
matrix.push()
|
||||
matrix.translateY(entity.renderBob.get(partialTicks))
|
||||
matrix.rotateY(yaw)
|
||||
@ -33,7 +34,7 @@ class RenderEntityProjectileEyeOfEnder(manager: EntityRendererManager) : EntityR
|
||||
super.render(entity, yaw, partialTicks, matrix, buffer, combinedLight)
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityProjectileEyeOfEnder): ResourceLocation{
|
||||
override fun getEntityTexture(entity: EntityProjectileEyeOfEnder): ResourceLocation {
|
||||
return PlayerContainer.LOCATION_BLOCKS_TEXTURE
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.system.forge.Side
|
||||
import chylex.hee.system.forge.Sided
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.game.entity.effect.EntityTerritoryLightningBolt
|
||||
import chylex.hee.system.forge.Side
|
||||
import chylex.hee.system.forge.Sided
|
||||
@ -14,8 +15,8 @@ import net.minecraft.util.ResourceLocation
|
||||
import java.util.Random
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityTerritoryLightningBolt(manager: EntityRendererManager) : EntityRenderer<EntityTerritoryLightningBolt>(manager){
|
||||
override fun render(entity: EntityTerritoryLightningBolt, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int){
|
||||
class RenderEntityTerritoryLightningBolt(manager: EntityRendererManager) : EntityRenderer<EntityTerritoryLightningBolt>(manager) {
|
||||
override fun render(entity: EntityTerritoryLightningBolt, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int) {
|
||||
val xCoords = FloatArray(8)
|
||||
val zCoords = FloatArray(8)
|
||||
var xOffset = 0F
|
||||
@ -24,7 +25,7 @@ class RenderEntityTerritoryLightningBolt(manager: EntityRendererManager) : Entit
|
||||
run {
|
||||
val rand = Random(entity.boltVertex)
|
||||
|
||||
for(i in 7 downTo 0){
|
||||
for(i in 7 downTo 0) {
|
||||
xCoords[i] = xOffset
|
||||
zCoords[i] = zOffset
|
||||
xOffset += rand.nextInt(11) - 5
|
||||
@ -35,25 +36,25 @@ class RenderEntityTerritoryLightningBolt(manager: EntityRendererManager) : Entit
|
||||
val builder = buffer.getBuffer(RenderType.getLightning())
|
||||
val mat = matrix.last.matrix
|
||||
|
||||
for(iter in 0..3){
|
||||
for(iter in 0..3) {
|
||||
val rand = Random(entity.boltVertex)
|
||||
|
||||
for(branch in 0..2){
|
||||
for(branch in 0..2) {
|
||||
val i1 = 7 - branch
|
||||
val i2 = if (branch > 0) i1 - 2 else 0
|
||||
|
||||
var x = xCoords[i1] - xOffset
|
||||
var z = zCoords[i1] - zOffset
|
||||
|
||||
for(y in i1 downTo i2){
|
||||
for(y in i1 downTo i2) {
|
||||
val origX = x
|
||||
val origZ = z
|
||||
|
||||
if (branch == 0){
|
||||
if (branch == 0) {
|
||||
x += rand.nextInt(11) - 5
|
||||
z += rand.nextInt(11) - 5
|
||||
}
|
||||
else{
|
||||
else {
|
||||
x += rand.nextInt(31) - 15
|
||||
z += rand.nextInt(31) - 15
|
||||
}
|
||||
@ -70,14 +71,14 @@ class RenderEntityTerritoryLightningBolt(manager: EntityRendererManager) : Entit
|
||||
}
|
||||
}
|
||||
|
||||
private fun addVertex(mat: Matrix4f, builder: IVertexBuilder, x1: Float, z1: Float, y: Int, x2: Float, z2: Float, off1: Float, off2: Float, offX1: Boolean, offZ1: Boolean, offX2: Boolean, offZ2: Boolean){
|
||||
private fun addVertex(mat: Matrix4f, builder: IVertexBuilder, x1: Float, z1: Float, y: Int, x2: Float, z2: Float, off1: Float, off2: Float, offX1: Boolean, offZ1: Boolean, offX2: Boolean, offZ2: Boolean) {
|
||||
builder.pos(mat, x1 + if (offX1) off2 else -off2, (y * 16).toFloat(), z1 + if (offZ1) off2 else -off2).color(0.45F, 0.45F, 0.5F, 0.3F).endVertex()
|
||||
builder.pos(mat, x2 + if (offX1) off1 else -off1, ((y + 1) * 16).toFloat(), z2 + if (offZ1) off1 else -off1).color(0.45F, 0.45F, 0.5F, 0.3F).endVertex()
|
||||
builder.pos(mat, x2 + if (offX2) off1 else -off1, ((y + 1) * 16).toFloat(), z2 + if (offZ2) off1 else -off1).color(0.45F, 0.45F, 0.5F, 0.3F).endVertex()
|
||||
builder.pos(mat, x1 + if (offX2) off2 else -off2, (y * 16).toFloat(), z1 + if (offZ2) off2 else -off2).color(0.45F, 0.45F, 0.5F, 0.3F).endVertex()
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityTerritoryLightningBolt): ResourceLocation{
|
||||
override fun getEntityTexture(entity: EntityTerritoryLightningBolt): ResourceLocation {
|
||||
return PlayerContainer.LOCATION_BLOCKS_TEXTURE
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity
|
||||
|
||||
import chylex.hee.client.model.entity.ModelEntityTokenHolder
|
||||
import chylex.hee.client.render.gl.rotateX
|
||||
import chylex.hee.client.render.gl.rotateY
|
||||
@ -22,19 +23,19 @@ import net.minecraft.util.ResourceLocation
|
||||
import kotlin.math.pow
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderEntityTokenHolder(manager: EntityRendererManager) : EntityRenderer<EntityTokenHolder>(manager){
|
||||
class RenderEntityTokenHolder(manager: EntityRendererManager) : EntityRenderer<EntityTokenHolder>(manager) {
|
||||
private val textures = mapOf(
|
||||
NORMAL to Resource.Custom("textures/entity/token_holder.png"),
|
||||
RARE to Resource.Custom("textures/entity/token_holder_rare.png"),
|
||||
SOLITARY to Resource.Custom("textures/entity/token_holder_solitary.png")
|
||||
)
|
||||
|
||||
init{
|
||||
init {
|
||||
shadowSize = 0.4F
|
||||
shadowOpaque = 0.6F
|
||||
}
|
||||
|
||||
override fun render(entity: EntityTokenHolder, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int){
|
||||
override fun render(entity: EntityTokenHolder, yaw: Float, partialTicks: Float, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int) {
|
||||
val charge = entity.renderCharge.get(partialTicks)
|
||||
val scale = 0.25F + (0.25F * charge.pow(1.5F))
|
||||
val alpha = 0.35F + (0.475F * charge.pow(5.5F))
|
||||
@ -54,7 +55,7 @@ class RenderEntityTokenHolder(manager: EntityRendererManager) : EntityRenderer<E
|
||||
matrix.pop()
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityTokenHolder): ResourceLocation?{
|
||||
override fun getEntityTexture(entity: EntityTokenHolder): ResourceLocation? {
|
||||
return textures[entity.tokenType]
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity.layer
|
||||
|
||||
import chylex.hee.client.model.entity.ModelEntityBossEnderEye
|
||||
import chylex.hee.client.render.gl.RenderStateBuilder
|
||||
import chylex.hee.client.render.gl.RenderStateBuilder.Companion.CULL_DISABLED
|
||||
@ -22,8 +23,8 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class LayerEnderEyeLaser(entity: IEntityRenderer<EntityBossEnderEye, ModelEntityBossEnderEye>) : LayerRenderer<EntityBossEnderEye, ModelEntityBossEnderEye>(entity){
|
||||
private val renderType = with(RenderStateBuilder()){
|
||||
class LayerEnderEyeLaser(entity: IEntityRenderer<EntityBossEnderEye, ModelEntityBossEnderEye>) : LayerRenderer<EntityBossEnderEye, ModelEntityBossEnderEye>(entity) {
|
||||
private val renderType = with(RenderStateBuilder()) {
|
||||
tex(BeaconTileEntityRenderer.TEXTURE_BEACON_BEAM)
|
||||
shade(SHADE_ENABLED)
|
||||
cull(CULL_DISABLED)
|
||||
@ -31,8 +32,8 @@ class LayerEnderEyeLaser(entity: IEntityRenderer<EntityBossEnderEye, ModelEntity
|
||||
buildType("hee:ender_eye_laser", DefaultVertexFormats.POSITION_COLOR_TEX, drawMode = GL11.GL_QUADS, bufferSize = 256)
|
||||
}
|
||||
|
||||
override fun render(matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, entity: EntityBossEnderEye, limbSwing: Float, limbSwingAmount: Float, partialTicks: Float, age: Float, headYaw: Float, headPitch: Float){
|
||||
if (entity.eyeState != EntityBossEnderEye.EYE_LASER){
|
||||
override fun render(matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, entity: EntityBossEnderEye, limbSwing: Float, limbSwingAmount: Float, partialTicks: Float, age: Float, headYaw: Float, headPitch: Float) {
|
||||
if (entity.eyeState != EntityBossEnderEye.EYE_LASER) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -50,35 +51,35 @@ class LayerEnderEyeLaser(entity: IEntityRenderer<EntityBossEnderEye, ModelEntity
|
||||
val tex = len * 1500F
|
||||
val mat = matrix.last.matrix
|
||||
|
||||
builder.pos(mat, -hw, -hw, 0F).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, -hw, -hw, 0F).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, -hw, -hw, -len).color().tex(0F, tex).endVertex()
|
||||
builder.pos(mat, hw, -hw, -len).color().tex(1F, tex).endVertex()
|
||||
builder.pos(mat, hw, -hw, 0F).color().tex(1F, 0F).endVertex()
|
||||
builder.pos(mat, +hw, -hw, -len).color().tex(1F, tex).endVertex()
|
||||
builder.pos(mat, +hw, -hw, 0F).color().tex(1F, 0F).endVertex()
|
||||
|
||||
builder.pos(mat, -hw, hw, 0F).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, -hw, hw, -len).color().tex(0F, tex).endVertex()
|
||||
builder.pos(mat, -hw, +hw, 0F).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, -hw, +hw, -len).color().tex(0F, tex).endVertex()
|
||||
builder.pos(mat, -hw, -hw, -len).color().tex(1F, tex).endVertex()
|
||||
builder.pos(mat, -hw, -hw, 0F).color().tex(1F, 0F).endVertex()
|
||||
builder.pos(mat, -hw, -hw, 0F).color().tex(1F, 0F).endVertex()
|
||||
|
||||
builder.pos(mat, hw, -hw, 0F).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, hw, -hw, 0F).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, hw, -hw, -len).color().tex(0F, tex).endVertex()
|
||||
builder.pos(mat, hw, hw, -len).color().tex(1F, tex).endVertex()
|
||||
builder.pos(mat, hw, hw, 0F).color().tex(1F, 0F).endVertex()
|
||||
builder.pos(mat, hw, +hw, -len).color().tex(1F, tex).endVertex()
|
||||
builder.pos(mat, hw, +hw, 0F).color().tex(1F, 0F).endVertex()
|
||||
|
||||
builder.pos(mat, hw, hw, 0F).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, hw, hw, -len).color().tex(0F, tex).endVertex()
|
||||
builder.pos(mat, +hw, hw, 0F).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, +hw, hw, -len).color().tex(0F, tex).endVertex()
|
||||
builder.pos(mat, -hw, hw, -len).color().tex(1F, tex).endVertex()
|
||||
builder.pos(mat, -hw, hw, 0F).color().tex(1F, 0F).endVertex()
|
||||
builder.pos(mat, -hw, hw, 0F).color().tex(1F, 0F).endVertex()
|
||||
|
||||
builder.pos(mat, -hw, -hw, -len).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, -hw, hw, -len).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, hw, hw, -len).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, hw, -hw, -len).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, -hw, +hw, -len).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, +hw, +hw, -len).color().tex(0F, 0F).endVertex()
|
||||
builder.pos(mat, +hw, -hw, -len).color().tex(0F, 0F).endVertex()
|
||||
|
||||
matrix.pop()
|
||||
}
|
||||
|
||||
private fun IVertexBuilder.color(): IVertexBuilder{
|
||||
private fun IVertexBuilder.color(): IVertexBuilder {
|
||||
return this.color(0.99F, 0.11F, 0.08F, 1F)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.entity.layer
|
||||
|
||||
import chylex.hee.client.render.entity.RenderEntityMobSpiderling
|
||||
import chylex.hee.client.render.gl.scale
|
||||
import chylex.hee.game.entity.living.EntityMobSpiderling
|
||||
@ -14,28 +15,28 @@ import net.minecraft.client.renderer.model.ModelRenderer
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class LayerSpiderlingEyes(spiderlingRenderer: RenderEntityMobSpiderling, private val headRenderer: ModelRenderer) : AbstractEyesLayer<EntityMobSpiderling, SpiderModel<EntityMobSpiderling>>(spiderlingRenderer){
|
||||
class LayerSpiderlingEyes(spiderlingRenderer: RenderEntityMobSpiderling, private val headRenderer: ModelRenderer) : AbstractEyesLayer<EntityMobSpiderling, SpiderModel<EntityMobSpiderling>>(spiderlingRenderer) {
|
||||
private val renderType = RenderType.getEyes(Resource.Custom("textures/entity/spiderling_eyes.png"))
|
||||
|
||||
override fun render(matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, entity: EntityMobSpiderling, limbSwing: Float, limbSwingAmount: Float, partialTicks: Float, age: Float, headYaw: Float, headPitch: Float){
|
||||
if (entity.isSleeping){
|
||||
override fun render(matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, entity: EntityMobSpiderling, limbSwing: Float, limbSwingAmount: Float, partialTicks: Float, age: Float, headYaw: Float, headPitch: Float) {
|
||||
if (entity.isSleeping) {
|
||||
return
|
||||
}
|
||||
|
||||
val builder = buffer.getBuffer(getRenderType())
|
||||
|
||||
if (headPitch == 0F){
|
||||
if (headPitch == 0F) {
|
||||
matrix.push()
|
||||
matrix.scale(1.001F) // hack around z-fighting
|
||||
headRenderer.render(matrix, builder, 15728640, OverlayTexture.NO_OVERLAY, 1F, 1F, 1F, 1F)
|
||||
matrix.pop()
|
||||
}
|
||||
else{
|
||||
else {
|
||||
headRenderer.render(matrix, builder, 15728640, OverlayTexture.NO_OVERLAY, 1F, 1F, 1F, 1F)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getRenderType(): RenderType{
|
||||
override fun getRenderType(): RenderType {
|
||||
return renderType
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.item
|
||||
|
||||
import chylex.hee.system.forge.Side
|
||||
import chylex.hee.system.forge.Sided
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
@ -9,8 +10,8 @@ import net.minecraft.item.ItemStack
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
class RenderItemTileEntitySimple<T : TileEntity>(val tile: T) : ItemStackTileEntityRenderer(){
|
||||
override fun render(stack: ItemStack, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int){
|
||||
class RenderItemTileEntitySimple<T : TileEntity>(val tile: T) : ItemStackTileEntityRenderer() {
|
||||
override fun render(stack: ItemStack, matrix: MatrixStack, buffer: IRenderTypeBuffer, combinedLight: Int, combinedOverlay: Int) {
|
||||
TileEntityRendererDispatcher.instance.renderItem(tile, matrix, buffer, combinedLight, combinedOverlay)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.territory
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.render.TerritoryRenderer
|
||||
import chylex.hee.client.render.gl.GL
|
||||
@ -17,8 +18,8 @@ import net.minecraftforge.client.SkyRenderHandler
|
||||
import org.lwjgl.opengl.GL11.GL_QUADS
|
||||
import kotlin.math.pow
|
||||
|
||||
abstract class AbstractEnvironmentRenderer : SkyRenderHandler{
|
||||
companion object{
|
||||
abstract class AbstractEnvironmentRenderer : SkyRenderHandler {
|
||||
companion object {
|
||||
val currentSkyAlpha
|
||||
@Sided(Side.CLIENT)
|
||||
get() = remapRange(TerritoryRenderer.VOID_FACTOR_VALUE, (-1F)..(0.5F), (1F)..(0F)).coerceIn(0F, 1F)
|
||||
@ -35,10 +36,10 @@ abstract class AbstractEnvironmentRenderer : SkyRenderHandler{
|
||||
val DEFAULT_COLOR = Vec3.xyz(1.0)
|
||||
const val DEFAULT_ALPHA = 1F
|
||||
|
||||
fun renderPlane(matrix: MatrixStack, y: Float, size: Float, rescale: Float){
|
||||
fun renderPlane(matrix: MatrixStack, y: Float, size: Float, rescale: Float) {
|
||||
val mat = matrix.last.matrix
|
||||
|
||||
with(Tessellator.getInstance()){
|
||||
with(Tessellator.getInstance()) {
|
||||
buffer.begin(GL_QUADS, DefaultVertexFormats.POSITION_TEX)
|
||||
buffer.pos(mat, -size, -y, -size).tex(0F, 0F).endVertex()
|
||||
buffer.pos(mat, -size, -y, size).tex(0F, rescale).endVertex()
|
||||
@ -50,7 +51,7 @@ abstract class AbstractEnvironmentRenderer : SkyRenderHandler{
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
final override fun render(ticks: Int, partialTicks: Float, matrix: MatrixStack, world: ClientWorld, mc: Minecraft){
|
||||
final override fun render(ticks: Int, partialTicks: Float, matrix: MatrixStack, world: ClientWorld, mc: Minecraft) {
|
||||
GL.depthMask(false)
|
||||
RenderHelper.disableStandardItemLighting()
|
||||
render(world, matrix, partialTicks)
|
||||
|
@ -1,13 +1,14 @@
|
||||
package chylex.hee.client.render.territory
|
||||
|
||||
import chylex.hee.system.forge.Side
|
||||
import chylex.hee.system.forge.Sided
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.world.ClientWorld
|
||||
|
||||
class MultiRenderer(private vararg val renderers: AbstractEnvironmentRenderer) : AbstractEnvironmentRenderer(){
|
||||
class MultiRenderer(private vararg val renderers: AbstractEnvironmentRenderer) : AbstractEnvironmentRenderer() {
|
||||
@Sided(Side.CLIENT)
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float){
|
||||
for(renderer in renderers){
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float) {
|
||||
for(renderer in renderers) {
|
||||
renderer.render(world, matrix, partialTicks)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.territory.components
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.render.gl.DF_ONE_MINUS_SRC_ALPHA
|
||||
import chylex.hee.client.render.gl.DF_ZERO
|
||||
@ -14,8 +15,8 @@ import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import net.minecraft.client.world.ClientWorld
|
||||
import org.lwjgl.opengl.GL11.GL_GREATER
|
||||
|
||||
abstract class SkyCubeBase : AbstractEnvironmentRenderer(){
|
||||
protected companion object{
|
||||
abstract class SkyCubeBase : AbstractEnvironmentRenderer() {
|
||||
protected companion object {
|
||||
const val DEFAULT_RESCALE = 16F
|
||||
const val DEFAULT_DISTANCE = 125F
|
||||
}
|
||||
@ -27,7 +28,7 @@ abstract class SkyCubeBase : AbstractEnvironmentRenderer(){
|
||||
protected open val distance = DEFAULT_DISTANCE
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float){
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float) {
|
||||
val distance = distance.coerceAtMost(18.5F * MC.settings.renderDistanceChunks)
|
||||
val rescale = rescale
|
||||
|
||||
@ -40,14 +41,14 @@ abstract class SkyCubeBase : AbstractEnvironmentRenderer(){
|
||||
GL.color(color, alpha * currentSkyAlpha)
|
||||
GL.bindTexture(texture)
|
||||
|
||||
for(side in 0..5){
|
||||
for(side in 0..5) {
|
||||
matrix.push()
|
||||
|
||||
when(side){
|
||||
1 -> matrix.rotateX( 90F)
|
||||
when(side) {
|
||||
1 -> matrix.rotateX(+90F)
|
||||
2 -> matrix.rotateX(-90F)
|
||||
3 -> matrix.rotateX(180F)
|
||||
4 -> matrix.rotateZ( 90F)
|
||||
4 -> matrix.rotateZ(+90F)
|
||||
5 -> matrix.rotateZ(-90F)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.territory.components
|
||||
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraft.util.math.Vec3d
|
||||
|
||||
@ -7,5 +8,5 @@ class SkyCubeStatic(
|
||||
override val color: Vec3d = DEFAULT_COLOR,
|
||||
override val alpha: Float = DEFAULT_ALPHA,
|
||||
override val rescale: Float = DEFAULT_RESCALE,
|
||||
override val distance: Float = DEFAULT_DISTANCE
|
||||
override val distance: Float = DEFAULT_DISTANCE,
|
||||
) : SkyCubeBase()
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.territory.components
|
||||
|
||||
import chylex.hee.client.render.gl.DF_ONE_MINUS_SRC_ALPHA
|
||||
import chylex.hee.client.render.gl.GL
|
||||
import chylex.hee.client.render.gl.SF_SRC_ALPHA
|
||||
@ -18,19 +19,19 @@ import org.lwjgl.opengl.GL11.GL_SMOOTH
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.sqrt
|
||||
|
||||
abstract class SkyDomeBase : AbstractEnvironmentRenderer(){
|
||||
abstract class SkyDomeBase : AbstractEnvironmentRenderer() {
|
||||
@Sided(Side.CLIENT)
|
||||
private object Skybox{
|
||||
private object Skybox {
|
||||
data class Vertex(val x: Float, val y: Float, val z: Float, val c: Float, val u: Byte, val v: Byte)
|
||||
|
||||
private const val SIZE = 8
|
||||
private const val COUNT = 15
|
||||
|
||||
private fun yOffset(xp: Float, zp: Float): Float{
|
||||
private fun yOffset(xp: Float, zp: Float): Float {
|
||||
return 32F - (1.15F * (square(xp) + square(zp)).pow(0.75F))
|
||||
}
|
||||
|
||||
private fun yColor(xp: Float, zp: Float): Float{
|
||||
private fun yColor(xp: Float, zp: Float): Float {
|
||||
val distance = sqrt(square(xp) + square(zp)) / (COUNT - 2F)
|
||||
val stretched = 1F - ((distance - 0.4F) / 0.6F)
|
||||
|
||||
@ -40,9 +41,9 @@ abstract class SkyDomeBase : AbstractEnvironmentRenderer(){
|
||||
val VERTICES = lazy {
|
||||
val list = mutableListOf<Vertex>()
|
||||
|
||||
for(xi in -COUNT..COUNT){
|
||||
for(zi in -COUNT..COUNT){
|
||||
if (square(xi) + square(zi) < square(COUNT)){
|
||||
for(xi in -COUNT..COUNT) {
|
||||
for(zi in -COUNT..COUNT) {
|
||||
if (square(xi) + square(zi) < square(COUNT)) {
|
||||
val x1 = ((xi * SIZE) - SIZE / 2).toFloat()
|
||||
val x2 = ((xi * SIZE) + SIZE / 2).toFloat()
|
||||
|
||||
@ -78,7 +79,7 @@ abstract class SkyDomeBase : AbstractEnvironmentRenderer(){
|
||||
protected open val alpha2 = DEFAULT_ALPHA
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float){
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float) {
|
||||
val mat = matrix.last.matrix
|
||||
|
||||
val color1 = color1
|
||||
@ -104,10 +105,10 @@ abstract class SkyDomeBase : AbstractEnvironmentRenderer(){
|
||||
GL.enableTexture()
|
||||
GL.bindTexture(texture)
|
||||
|
||||
with(Tessellator.getInstance()){
|
||||
with(Tessellator.getInstance()) {
|
||||
buffer.begin(GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX)
|
||||
|
||||
for((x, y, z, c, u, v) in Skybox.VERTICES.value){
|
||||
for((x, y, z, c, u, v) in Skybox.VERTICES.value) {
|
||||
val r = offsetTowards(r2, r1, c)
|
||||
val g = offsetTowards(g2, g1, c)
|
||||
val b = offsetTowards(b2, b1, c)
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.territory.components
|
||||
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraft.util.math.Vec3d
|
||||
|
||||
@ -7,8 +8,8 @@ class SkyDomeStatic(
|
||||
override val color1: Vec3d = DEFAULT_COLOR,
|
||||
override val color2: Vec3d = DEFAULT_COLOR,
|
||||
override val alpha1: Float = DEFAULT_ALPHA,
|
||||
override val alpha2: Float = DEFAULT_ALPHA
|
||||
) : SkyDomeBase(){
|
||||
override val alpha2: Float = DEFAULT_ALPHA,
|
||||
) : SkyDomeBase() {
|
||||
constructor(texture: ResourceLocation = DEFAULT_TEXTURE, color: Vec3d = DEFAULT_COLOR, alpha: Float = DEFAULT_ALPHA) : this(texture, color, color, alpha, alpha)
|
||||
constructor(texture: ResourceLocation = DEFAULT_TEXTURE, color1: Vec3d, color2: Vec3d, alpha: Float = DEFAULT_ALPHA) : this(texture, color1, color2, alpha, alpha)
|
||||
constructor(texture: ResourceLocation = DEFAULT_TEXTURE, color: Vec3d = DEFAULT_COLOR, alpha1: Float, alpha2: Float) : this(texture, color, color, alpha1, alpha2)
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.territory.components
|
||||
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.client.render.gl.DF_ONE_MINUS_SRC_ALPHA
|
||||
import chylex.hee.client.render.gl.DF_ZERO
|
||||
@ -20,10 +21,10 @@ class SkyPlaneTopFoggy(
|
||||
override val alpha: Float = DEFAULT_ALPHA,
|
||||
override val rescale: Float = DEFAULT_RESCALE,
|
||||
override val distance: Float = DEFAULT_DISTANCE,
|
||||
private val width: Float = distance
|
||||
) : SkyCubeBase(){
|
||||
private val width: Float = distance,
|
||||
) : SkyCubeBase() {
|
||||
@Sided(Side.CLIENT)
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float){
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float) {
|
||||
val dist = distance.coerceAtMost(18.5F * MC.settings.renderDistanceChunks)
|
||||
val rescale = rescale
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.territory.components
|
||||
|
||||
import chylex.hee.client.render.gl.DF_ONE
|
||||
import chylex.hee.client.render.gl.DF_ZERO
|
||||
import chylex.hee.client.render.gl.GL
|
||||
@ -14,8 +15,8 @@ import net.minecraft.client.world.ClientWorld
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import org.lwjgl.opengl.GL11.GL_GREATER
|
||||
|
||||
abstract class SunBase : AbstractEnvironmentRenderer(){
|
||||
protected companion object{
|
||||
abstract class SunBase : AbstractEnvironmentRenderer() {
|
||||
protected companion object {
|
||||
const val DEFAULT_DISTANCE = 100F
|
||||
}
|
||||
|
||||
@ -26,13 +27,13 @@ abstract class SunBase : AbstractEnvironmentRenderer(){
|
||||
protected open val distance = DEFAULT_DISTANCE
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
protected open fun setRotation(world: ClientWorld, matrix: MatrixStack, partialTicks: Float){
|
||||
protected open fun setRotation(world: ClientWorld, matrix: MatrixStack, partialTicks: Float) {
|
||||
matrix.rotateY(-90F)
|
||||
matrix.rotateX(world.getCelestialAngle(partialTicks) * 360F)
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float){
|
||||
override fun render(world: ClientWorld, matrix: MatrixStack, partialTicks: Float) {
|
||||
val width = size
|
||||
val dist = distance
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.client.render.territory.components
|
||||
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraft.util.math.Vec3d
|
||||
|
||||
@ -7,5 +8,5 @@ class SunStatic(
|
||||
override val color: Vec3d = DEFAULT_COLOR,
|
||||
override val alpha: Float = DEFAULT_ALPHA,
|
||||
override val size: Float,
|
||||
override val distance: Float = DEFAULT_DISTANCE
|
||||
override val distance: Float = DEFAULT_DISTANCE,
|
||||
) : SunBase()
|
||||
|
@ -1,20 +1,21 @@
|
||||
package chylex.hee.client.sound
|
||||
|
||||
import chylex.hee.game.entity.projectile.EntityProjectileSpatialDash
|
||||
import chylex.hee.system.migration.Sounds
|
||||
import chylex.hee.system.random.nextFloat
|
||||
import net.minecraft.client.audio.TickableSound
|
||||
import net.minecraft.util.SoundCategory
|
||||
|
||||
class MovingSoundSpatialDash(private val entity: EntityProjectileSpatialDash) : TickableSound(Sounds.ITEM_ELYTRA_FLYING, SoundCategory.PLAYERS){
|
||||
init{
|
||||
class MovingSoundSpatialDash(private val entity: EntityProjectileSpatialDash) : TickableSound(Sounds.ITEM_ELYTRA_FLYING, SoundCategory.PLAYERS) {
|
||||
init {
|
||||
volume = 0.9F
|
||||
pitch = entity.world.rand.nextFloat(1.1F, 1.4F)
|
||||
repeat = true
|
||||
repeatDelay = 0
|
||||
}
|
||||
|
||||
override fun tick(){
|
||||
if (!entity.isAlive){
|
||||
override fun tick() {
|
||||
if (!entity.isAlive) {
|
||||
donePlaying = true
|
||||
return
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.commands
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.client.MC
|
||||
import chylex.hee.commands.client.CommandClientHelp
|
||||
@ -12,7 +13,7 @@ import net.minecraftforge.api.distmarker.Dist
|
||||
import net.minecraftforge.client.event.ClientChatEvent
|
||||
|
||||
@SubscribeAllEvents(Dist.CLIENT, modid = HEE.ID)
|
||||
object ClientCommandHandler{ // UPDATE
|
||||
object ClientCommandHandler { // UPDATE
|
||||
val nonHelpCommands = listOf(
|
||||
CommandClientHelp,
|
||||
CommandClientScaffolding,
|
||||
@ -20,17 +21,17 @@ object ClientCommandHandler{ // UPDATE
|
||||
).associateBy { it.name }
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
fun onClientChat(e: ClientChatEvent){
|
||||
fun onClientChat(e: ClientChatEvent) {
|
||||
val secondPart = e.message.removePrefix("/${ModCommands.ROOT}")
|
||||
|
||||
if (secondPart == e.message){
|
||||
if (secondPart == e.message) {
|
||||
return
|
||||
}
|
||||
|
||||
val source = MC.player!!.commandSource
|
||||
val arguments = secondPart.split(' ').filter { it.isNotEmpty() }
|
||||
|
||||
val command = when{
|
||||
val command = when {
|
||||
arguments.isEmpty() -> CommandClientHelp
|
||||
arguments[0] == CommandClientHelp.name -> CommandClientHelp.takeIf { arguments.size < 2 || arguments[1] == "1" } ?: return
|
||||
else -> nonHelpCommands[arguments[0]] ?: return
|
||||
|
@ -1,13 +1,14 @@
|
||||
package chylex.hee.commands.client
|
||||
|
||||
import chylex.hee.commands.ClientCommandHandler
|
||||
import chylex.hee.commands.IClientCommand
|
||||
import chylex.hee.commands.server.CommandServerHelp
|
||||
import net.minecraft.command.CommandSource
|
||||
|
||||
object CommandClientHelp : IClientCommand{
|
||||
object CommandClientHelp : IClientCommand {
|
||||
override val name = "help"
|
||||
|
||||
override fun executeCommand(sender: CommandSource, args: Array<String>){
|
||||
override fun executeCommand(sender: CommandSource, args: Array<String>) {
|
||||
CommandServerHelp.sendCommandListPage(sender, ClientCommandHandler.nonHelpCommands.keys, emptyMap(), "commands.hee.help.header.client", 1, null)
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package chylex.hee.commands.client
|
||||
|
||||
import chylex.hee.commands.IClientCommand
|
||||
import chylex.hee.commands.server.CommandDebugStructure
|
||||
import net.minecraft.command.CommandSource
|
||||
import net.minecraft.util.text.StringTextComponent
|
||||
import java.util.prefs.Preferences
|
||||
|
||||
object CommandClientScaffolding : IClientCommand{
|
||||
object CommandClientScaffolding : IClientCommand {
|
||||
override val name = "scaffolding"
|
||||
|
||||
private val data
|
||||
@ -17,17 +18,17 @@ object CommandClientScaffolding : IClientCommand{
|
||||
val currentFile
|
||||
get() = data.get("File", "")!!.ifBlank { "structure.nbt" }
|
||||
|
||||
override fun executeCommand(sender: CommandSource, args: Array<String>){
|
||||
override fun executeCommand(sender: CommandSource, args: Array<String>) {
|
||||
val structure = args.getOrNull(0) ?: return
|
||||
|
||||
if (!CommandDebugStructure.structureDescriptions.containsKey(structure)){
|
||||
if (!CommandDebugStructure.structureDescriptions.containsKey(structure)) {
|
||||
sender.sendFeedback(StringTextComponent("Unknown structure."), false)
|
||||
return
|
||||
}
|
||||
|
||||
with(data){
|
||||
with(data) {
|
||||
put("Structure", structure)
|
||||
put("File", args.getOrElse(1){ "" })
|
||||
put("File", args.getOrElse(1) { "" })
|
||||
}
|
||||
|
||||
sender.sendFeedback(StringTextComponent("Structure set."), false)
|
||||
|
@ -1,21 +1,22 @@
|
||||
package chylex.hee.commands.client
|
||||
|
||||
import chylex.hee.commands.IClientCommand
|
||||
import chylex.hee.game.world.WorldProviderEndCustom
|
||||
import chylex.hee.init.ModBlocks
|
||||
import net.minecraft.command.CommandSource
|
||||
import net.minecraft.util.text.StringTextComponent
|
||||
|
||||
object CommandDebugToggles : IClientCommand{
|
||||
object CommandDebugToggles : IClientCommand {
|
||||
override val name = "debug"
|
||||
|
||||
override fun executeCommand(sender: CommandSource, args: Array<String>){
|
||||
override fun executeCommand(sender: CommandSource, args: Array<String>) {
|
||||
val name = args.getOrNull(0) ?: return
|
||||
|
||||
if (name == "territory"){
|
||||
if (name == "territory") {
|
||||
WorldProviderEndCustom.debugMode = !WorldProviderEndCustom.debugMode
|
||||
sender.sendFeedback(StringTextComponent("Territory debugging ${if (WorldProviderEndCustom.debugMode) "enabled" else "disabled"}."), false)
|
||||
}
|
||||
else if (name == "scaffolding"){
|
||||
else if (name == "scaffolding") {
|
||||
ModBlocks.SCAFFOLDING.enableShape = !ModBlocks.SCAFFOLDING.enableShape
|
||||
sender.sendFeedback(StringTextComponent("Scaffolding shape ${if (ModBlocks.SCAFFOLDING.enableShape) "enabled" else "disabled"}."), false)
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.commands.server
|
||||
|
||||
import chylex.hee.commands.ICommand
|
||||
import chylex.hee.commands.executes
|
||||
import chylex.hee.commands.getInt
|
||||
@ -14,10 +15,10 @@ import net.minecraft.command.Commands.argument
|
||||
import net.minecraft.command.Commands.literal
|
||||
import net.minecraft.util.text.StringTextComponent
|
||||
|
||||
object CommandDebugInstability : ICommand{
|
||||
object CommandDebugInstability : ICommand {
|
||||
override val name = "instability"
|
||||
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>){
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>) {
|
||||
val execModify = this::executeModify
|
||||
val instabilityAmountArg = integer(UShort.MIN_VALUE.toInt(), UShort.MAX_VALUE.toInt())
|
||||
|
||||
@ -34,27 +35,27 @@ object CommandDebugInstability : ICommand{
|
||||
)
|
||||
}
|
||||
|
||||
private fun executeCheck(ctx: CommandContext<CommandSource>): Int{
|
||||
private fun executeCheck(ctx: CommandContext<CommandSource>): Int {
|
||||
val instability = getInstability(ctx) ?: return 0
|
||||
|
||||
with(ctx.source){
|
||||
with(ctx.source) {
|
||||
sendFeedback(StringTextComponent("Instability level: " + instability.getLevel(Pos(pos))), false)
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
private fun executeModify(ctx: CommandContext<CommandSource>, add: Boolean): Int{
|
||||
private fun executeModify(ctx: CommandContext<CommandSource>, add: Boolean): Int {
|
||||
val instability = getInstability(ctx) ?: return 0
|
||||
val amount = ctx.getInt("amount")
|
||||
|
||||
with(ctx.source){
|
||||
with(ctx.source) {
|
||||
val pos = Pos(pos)
|
||||
|
||||
if (add){
|
||||
if (add) {
|
||||
instability.resetActionMultiplier(pos)
|
||||
instability.triggerAction(amount.toUShort(), pos)
|
||||
}
|
||||
else{
|
||||
else {
|
||||
instability.triggerRelief(amount.toUShort(), pos)
|
||||
}
|
||||
|
||||
@ -63,11 +64,11 @@ object CommandDebugInstability : ICommand{
|
||||
}
|
||||
}
|
||||
|
||||
private fun getInstability(ctx: CommandContext<CommandSource>): IDimensionInstability?{
|
||||
with(ctx.source){
|
||||
private fun getInstability(ctx: CommandContext<CommandSource>): IDimensionInstability? {
|
||||
with(ctx.source) {
|
||||
val instability = Instability.get(world)
|
||||
|
||||
if (instability === DimensionInstabilityNull){
|
||||
if (instability === DimensionInstabilityNull) {
|
||||
sendFeedback(StringTextComponent("Invalid dimension."), false)
|
||||
return null
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.commands.server
|
||||
|
||||
import chylex.hee.commands.ICommand
|
||||
import chylex.hee.commands.arguments.ValidatedStringArgument.Companion.validatedString
|
||||
import chylex.hee.commands.executes
|
||||
@ -29,7 +30,7 @@ import net.minecraft.util.Rotation
|
||||
import net.minecraft.util.text.StringTextComponent
|
||||
import java.util.Random
|
||||
|
||||
object CommandDebugStructure : ICommand{
|
||||
object CommandDebugStructure : ICommand {
|
||||
val structureDescriptions = mapOf(
|
||||
"stronghold" to StrongholdPieces,
|
||||
"energyshrine" to EnergyShrinePieces,
|
||||
@ -39,7 +40,7 @@ object CommandDebugStructure : ICommand{
|
||||
|
||||
override val name = "structure"
|
||||
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>){
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>) {
|
||||
val execPieces = this::executePieces
|
||||
val execPiecesDev = this::executePiecesDev
|
||||
val execBuild = this::executeBuild
|
||||
@ -67,22 +68,22 @@ object CommandDebugStructure : ICommand{
|
||||
)
|
||||
}
|
||||
|
||||
private fun executeResetCache(ctx: CommandContext<CommandSource>) = returning(1){
|
||||
private fun executeResetCache(ctx: CommandContext<CommandSource>) = returning(1) {
|
||||
StructureFiles.resetCache()
|
||||
ctx.source.sendFeedback(StringTextComponent("Done."), false)
|
||||
}
|
||||
|
||||
private fun executePieces(ctx: CommandContext<CommandSource>, transforms: List<Transform>) = returning(1){
|
||||
private fun executePieces(ctx: CommandContext<CommandSource>, transforms: List<Transform>) = returning(1) {
|
||||
val world = ctx.source.world
|
||||
val pos = Pos(ctx.source.pos)
|
||||
|
||||
val structure = structureDescriptions.getValue(ctx.getString("structure"))
|
||||
var x = 0
|
||||
|
||||
for(piece in structure.ALL_PIECES){
|
||||
for(piece in structure.ALL_PIECES) {
|
||||
val size = piece.size
|
||||
|
||||
for((index, transform) in transforms.withIndex()){
|
||||
for((index, transform) in transforms.withIndex()) {
|
||||
val adaptedWorld = WorldToStructureWorldAdapter(world, world.rand, pos.add(x, index * (size.y + 2), -size.centerZ))
|
||||
val transformedWorld = TransformedStructureWorld(adaptedWorld, size, transform)
|
||||
|
||||
@ -94,7 +95,7 @@ object CommandDebugStructure : ICommand{
|
||||
}
|
||||
}
|
||||
|
||||
private fun executePiecesDev(ctx: CommandContext<CommandSource>, hasTransformArg: Boolean) = returning(1){
|
||||
private fun executePiecesDev(ctx: CommandContext<CommandSource>, hasTransformArg: Boolean) = returning(1) {
|
||||
val world = ctx.source.world
|
||||
val pos = Pos(ctx.source.pos)
|
||||
|
||||
@ -104,16 +105,16 @@ object CommandDebugStructure : ICommand{
|
||||
val transformArg = if (hasTransformArg) ctx.getString("transform") else "0"
|
||||
val mirror = transformArg[0] == 'M'
|
||||
|
||||
val transform = when(transformArg.trimStart('M')){
|
||||
"0" -> Transform(Rotation.NONE, mirror)
|
||||
"90" -> Transform(Rotation.CLOCKWISE_90, mirror)
|
||||
val transform = when(transformArg.trimStart('M')) {
|
||||
"0" -> Transform(Rotation.NONE, mirror)
|
||||
"90" -> Transform(Rotation.CLOCKWISE_90, mirror)
|
||||
"180" -> Transform(Rotation.CLOCKWISE_180, mirror)
|
||||
"270" -> Transform(Rotation.COUNTERCLOCKWISE_90, mirror)
|
||||
else -> return 0
|
||||
else -> return 0
|
||||
}
|
||||
|
||||
for(piece in structure.ALL_PIECES){
|
||||
if (piece is IStructurePieceFromFile){
|
||||
for(piece in structure.ALL_PIECES) {
|
||||
if (piece is IStructurePieceFromFile) {
|
||||
val adaptedWorld = WorldToStructureWorldAdapter(world, world.rand, pos.add(x, 0, -piece.size.centerZ))
|
||||
val transformedWorld = TransformedStructureWorld(adaptedWorld, piece.size, transform)
|
||||
|
||||
@ -123,17 +124,17 @@ object CommandDebugStructure : ICommand{
|
||||
}
|
||||
}
|
||||
|
||||
private fun executeBuild(ctx: CommandContext<CommandSource>, hasSeedArg: Boolean): Int{
|
||||
with(ctx.source){
|
||||
private fun executeBuild(ctx: CommandContext<CommandSource>, hasSeedArg: Boolean): Int {
|
||||
with(ctx.source) {
|
||||
val structure = structureDescriptions.getValue(ctx.getString("structure"))
|
||||
|
||||
val rand = Random(if (hasSeedArg) ctx.getLong("seed") else world.rand.nextLong())
|
||||
val world = WorldToStructureWorldAdapter(world, rand, Pos(pos).subtract(structure.STRUCTURE_SIZE.centerPos))
|
||||
|
||||
for(attempt in 1..100){
|
||||
for(attempt in 1..100) {
|
||||
val builder = structure.STRUCTURE_BUILDER.build(rand)
|
||||
|
||||
if (builder != null){
|
||||
if (builder != null) {
|
||||
sendFeedback(StringTextComponent("Successful attempt: $attempt"), false)
|
||||
world.apply(builder::generate).finalize()
|
||||
return 1
|
||||
@ -145,11 +146,11 @@ object CommandDebugStructure : ICommand{
|
||||
}
|
||||
}
|
||||
|
||||
private fun executeLocate(ctx: CommandContext<CommandSource>): Int{
|
||||
with(ctx.source){
|
||||
private fun executeLocate(ctx: CommandContext<CommandSource>): Int {
|
||||
with(ctx.source) {
|
||||
val closest = structureDescriptions.getValue(ctx.getString("structure")).STRUCTURE_LOCATOR(world, PosXZ(Pos(pos)))
|
||||
|
||||
if (closest == null){
|
||||
if (closest == null) {
|
||||
sendFeedback(StringTextComponent("Structure not found."), false)
|
||||
return 0
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.commands.server
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.commands.ICommand
|
||||
import chylex.hee.commands.executes
|
||||
@ -22,10 +23,10 @@ import net.minecraft.command.Commands.literal
|
||||
import net.minecraft.util.text.StringTextComponent
|
||||
import java.util.Random
|
||||
|
||||
object CommandDebugTerritory : ICommand{
|
||||
object CommandDebugTerritory : ICommand {
|
||||
override val name = "territory"
|
||||
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>){
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>) {
|
||||
val execRegenerate = this::executeRegenerate
|
||||
|
||||
builder.then(
|
||||
@ -35,19 +36,19 @@ object CommandDebugTerritory : ICommand{
|
||||
)
|
||||
}
|
||||
|
||||
private fun executeRegenerate(ctx: CommandContext<CommandSource>, hasSeedArg: Boolean): Int{
|
||||
with(ctx.source){
|
||||
private fun executeRegenerate(ctx: CommandContext<CommandSource>, hasSeedArg: Boolean): Int {
|
||||
with(ctx.source) {
|
||||
val world = ctx.source.world
|
||||
val pos = Pos(ctx.source.pos)
|
||||
val instance = TerritoryInstance.fromPos(pos)
|
||||
val seed = if (hasSeedArg) ctx.getLong("seed") else null
|
||||
|
||||
if (world.dimension.type !== HEE.dim){
|
||||
if (world.dimension.type !== HEE.dim) {
|
||||
sendFeedback(StringTextComponent("Invalid dimension."), false)
|
||||
return 0
|
||||
}
|
||||
|
||||
if (instance == null){
|
||||
if (instance == null) {
|
||||
sendFeedback(StringTextComponent("Invalid territory position."), false)
|
||||
return 0
|
||||
}
|
||||
@ -71,14 +72,14 @@ object CommandDebugTerritory : ICommand{
|
||||
val startChunkBlockZ = startChunkZ * 16
|
||||
|
||||
for(chunkX in startChunkX until (startChunkX + chunks))
|
||||
for(chunkZ in startChunkZ until (startChunkZ + chunks)){
|
||||
for(chunkZ in startChunkZ until (startChunkZ + chunks)) {
|
||||
val chunk = world.getChunk(chunkX, chunkZ)
|
||||
|
||||
for(entity in chunk.entityLists.flatMap { it }.filter { it !is EntityPlayer }){
|
||||
for(entity in chunk.entityLists.flatMap { it }.filter { it !is EntityPlayer }) {
|
||||
entity.remove()
|
||||
}
|
||||
|
||||
for(tilePos in chunk.tileEntitiesPos){
|
||||
for(tilePos in chunk.tileEntitiesPos) {
|
||||
world.removeTileEntity(tilePos)
|
||||
}
|
||||
|
||||
@ -86,18 +87,18 @@ object CommandDebugTerritory : ICommand{
|
||||
val chunkBlockZ = chunkZ * 16
|
||||
val internalOffset = Pos(chunkBlockX - startChunkBlockX, 0, chunkBlockZ - startChunkBlockZ)
|
||||
|
||||
for(blockY in 0 until height) for(blockX in 0..15) for(blockZ in 0..15){
|
||||
for(blockY in 0 until height) for(blockX in 0..15) for(blockZ in 0..15) {
|
||||
val state = constructed.getState(internalOffset.add(blockX, blockY, blockZ))
|
||||
|
||||
Pos(chunkBlockX + blockX, bottomOffset + blockY, chunkBlockZ + blockZ).let {
|
||||
if (it.getState(world) != state){
|
||||
if (it.getState(world) != state) {
|
||||
it.setState(world, state, FLAG_SYNC_CLIENT or FLAG_REPLACE_NO_DROPS)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for((triggerPos, trigger) in constructed.getTriggers()){
|
||||
for((triggerPos, trigger) in constructed.getTriggers()) {
|
||||
trigger.realize(world, triggerPos.add(startChunkBlockX, bottomOffset, startChunkBlockZ), Transform.NONE)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.commands.server
|
||||
|
||||
import chylex.hee.commands.CommandExecutionFunction
|
||||
import chylex.hee.commands.ICommand
|
||||
import chylex.hee.commands.returning
|
||||
@ -6,17 +7,17 @@ import com.mojang.brigadier.builder.ArgumentBuilder
|
||||
import com.mojang.brigadier.context.CommandContext
|
||||
import net.minecraft.command.CommandSource
|
||||
|
||||
object CommandDebugTestWorld : ICommand, CommandExecutionFunction{
|
||||
object CommandDebugTestWorld : ICommand, CommandExecutionFunction {
|
||||
override val name = "testworld"
|
||||
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>){
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>) {
|
||||
builder.executes(this)
|
||||
}
|
||||
|
||||
override fun run(ctx: CommandContext<CommandSource>) = returning(1){
|
||||
override fun run(ctx: CommandContext<CommandSource>) = returning(1) {
|
||||
val source = ctx.source
|
||||
|
||||
with(source.server.commandManager){
|
||||
with(source.server.commandManager) {
|
||||
handleCommand(source, "/gamerule keepInventory true")
|
||||
handleCommand(source, "/gamerule doDaylightCycle false")
|
||||
handleCommand(source, "/gamerule doWeatherCycle false")
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.commands.server
|
||||
|
||||
import chylex.hee.commands.ICommand
|
||||
import chylex.hee.commands.arguments.EnumArgument.Companion.enum
|
||||
import chylex.hee.commands.executes
|
||||
@ -18,10 +19,10 @@ import net.minecraft.command.arguments.EntityArgument.players
|
||||
import net.minecraft.util.text.StringTextComponent
|
||||
import java.util.Locale
|
||||
|
||||
object CommandServerCausatum : ICommand{
|
||||
object CommandServerCausatum : ICommand {
|
||||
override val name = "causatum"
|
||||
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>){
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>) {
|
||||
val execCheck = this::executeCheck
|
||||
val execSet = this::executeSet
|
||||
|
||||
@ -44,18 +45,18 @@ object CommandServerCausatum : ICommand{
|
||||
)
|
||||
}
|
||||
|
||||
private fun executeList(ctx: CommandContext<CommandSource>) = returning(1){
|
||||
with(ctx.source){
|
||||
private fun executeList(ctx: CommandContext<CommandSource>) = returning(1) {
|
||||
with(ctx.source) {
|
||||
sendFeedback(message("list"), false)
|
||||
|
||||
for(stage in CausatumStage.values()){
|
||||
for(stage in CausatumStage.values()) {
|
||||
sendFeedback(StringTextComponent(stage.name.toLowerCase(Locale.ENGLISH)), false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun executeCheck(ctx: CommandContext<CommandSource>, hasPlayerParameter: Boolean): Int{
|
||||
with(ctx.source){
|
||||
private fun executeCheck(ctx: CommandContext<CommandSource>, hasPlayerParameter: Boolean): Int {
|
||||
with(ctx.source) {
|
||||
val player = if (hasPlayerParameter) EntityArgument.getPlayer(ctx, "player") else asPlayer()
|
||||
val stage = EnderCausatum.getStage(player)
|
||||
|
||||
@ -64,13 +65,13 @@ object CommandServerCausatum : ICommand{
|
||||
}
|
||||
}
|
||||
|
||||
private fun executeSet(ctx: CommandContext<CommandSource>, hasPlayerParameter: Boolean): Int{
|
||||
private fun executeSet(ctx: CommandContext<CommandSource>, hasPlayerParameter: Boolean): Int {
|
||||
val newStage = ctx.getEnum<CausatumStage>("stage")
|
||||
|
||||
with(ctx.source){
|
||||
with(ctx.source) {
|
||||
val players = if (hasPlayerParameter) EntityArgument.getPlayers(ctx, "players") else listOf(asPlayer())
|
||||
|
||||
for(player in players){
|
||||
for(player in players) {
|
||||
EnderCausatum.triggerStage(player, newStage, force = true)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.commands.server
|
||||
|
||||
import chylex.hee.commands.CommandExecutionFunctionCtx
|
||||
import chylex.hee.commands.ICommand
|
||||
import chylex.hee.commands.executes
|
||||
@ -23,12 +24,12 @@ import net.minecraft.util.text.event.ClickEvent
|
||||
import net.minecraft.util.text.event.ClickEvent.Action.RUN_COMMAND
|
||||
import net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND
|
||||
|
||||
object CommandServerHelp : ICommand, CommandExecutionFunctionCtx<Boolean>{
|
||||
object CommandServerHelp : ICommand, CommandExecutionFunctionCtx<Boolean> {
|
||||
private const val COMMANDS_PER_PAGE = 7
|
||||
|
||||
override val name = "help"
|
||||
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>){
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>) {
|
||||
builder.executes(this, false)
|
||||
|
||||
builder.then(
|
||||
@ -36,40 +37,40 @@ object CommandServerHelp : ICommand, CommandExecutionFunctionCtx<Boolean>{
|
||||
)
|
||||
}
|
||||
|
||||
override fun invoke(ctx: CommandContext<CommandSource>, hasDisplayPage: Boolean) = returning(1){
|
||||
override fun invoke(ctx: CommandContext<CommandSource>, hasDisplayPage: Boolean) = returning(1) {
|
||||
val source = ctx.source
|
||||
val displayPage = if (hasDisplayPage) ctx.getInt("page") else 1
|
||||
|
||||
var totalPages = (ModCommands.admin.size.toFloat() / COMMANDS_PER_PAGE).ceilToInt()
|
||||
var debugPage = -1
|
||||
|
||||
if (ModCommands.debug.isNotEmpty()){
|
||||
if (ModCommands.debug.isNotEmpty()) {
|
||||
totalPages++
|
||||
debugPage = totalPages
|
||||
}
|
||||
|
||||
val actualPage: Int
|
||||
|
||||
if (source.entity is EntityPlayer){
|
||||
if (source.entity is EntityPlayer) {
|
||||
actualPage = displayPage - 1
|
||||
totalPages++
|
||||
}
|
||||
else{
|
||||
else {
|
||||
actualPage = displayPage
|
||||
}
|
||||
|
||||
if (displayPage < 1 || displayPage > totalPages){
|
||||
if (displayPage < 1 || displayPage > totalPages) {
|
||||
throw CommandException(TranslationTextComponent("commands.hee.help.failed", totalPages))
|
||||
}
|
||||
|
||||
val responseHeaderKey: String
|
||||
val responseCommands: Iterable<ICommand>
|
||||
|
||||
if (actualPage == debugPage){
|
||||
if (actualPage == debugPage) {
|
||||
responseHeaderKey = "commands.hee.help.header.debug"
|
||||
responseCommands = ModCommands.debug.asIterable()
|
||||
}
|
||||
else{
|
||||
else {
|
||||
responseHeaderKey = "commands.hee.help.header.admin"
|
||||
responseCommands = ModCommands.admin.drop((actualPage - 1) * COMMANDS_PER_PAGE).take(COMMANDS_PER_PAGE)
|
||||
}
|
||||
@ -80,7 +81,7 @@ object CommandServerHelp : ICommand, CommandExecutionFunctionCtx<Boolean>{
|
||||
sendCommandListPage(source, commandNames, commandUsages, responseHeaderKey, displayPage, totalPages)
|
||||
}
|
||||
|
||||
fun sendCommandListPage(source: CommandSource, commandNames: Iterable<String>, commandUsages: Map<String, String>, headerKey: String, currentPage: Int, totalPages: Int?){
|
||||
fun sendCommandListPage(source: CommandSource, commandNames: Iterable<String>, commandUsages: Map<String, String>, headerKey: String, currentPage: Int, totalPages: Int?) {
|
||||
val emptyLine = StringTextComponent("")
|
||||
|
||||
send(source, emptyLine)
|
||||
@ -89,7 +90,7 @@ object CommandServerHelp : ICommand, CommandExecutionFunctionCtx<Boolean>{
|
||||
})
|
||||
send(source, emptyLine)
|
||||
|
||||
for(name in commandNames){
|
||||
for(name in commandNames) {
|
||||
val entry = commandUsages.entries.find { it.key == name }
|
||||
val usage = entry?.value?.replaceFirst("[$name]", name) ?: name
|
||||
|
||||
@ -105,22 +106,22 @@ object CommandServerHelp : ICommand, CommandExecutionFunctionCtx<Boolean>{
|
||||
))
|
||||
}
|
||||
|
||||
if (source.entity is EntityPlayer){
|
||||
if (source.entity is EntityPlayer) {
|
||||
send(source, emptyLine)
|
||||
sendInteractiveNavigation(source, currentPage, totalPages)
|
||||
send(source, emptyLine)
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendInteractiveNavigation(source: CommandSource, currentPage: Int, totalPages: Int?){
|
||||
private fun sendInteractiveNavigation(source: CommandSource, currentPage: Int, totalPages: Int?) {
|
||||
val components = mutableListOf<ITextComponent>()
|
||||
|
||||
if (totalPages == null){
|
||||
if (totalPages == null) {
|
||||
components.add(TranslationTextComponent("commands.hee.help.footer.admin").also {
|
||||
it.style.clickEvent = ClickEvent(RUN_COMMAND, "/hee help ${currentPage + 1}")
|
||||
})
|
||||
}
|
||||
else{
|
||||
else {
|
||||
val showPrev = currentPage > 1
|
||||
val showNext = currentPage < totalPages
|
||||
|
||||
@ -142,24 +143,24 @@ object CommandServerHelp : ICommand, CommandExecutionFunctionCtx<Boolean>{
|
||||
))
|
||||
}
|
||||
|
||||
private fun send(source: CommandSource, text: ITextComponent){
|
||||
private fun send(source: CommandSource, text: ITextComponent) {
|
||||
source.sendFeedback(text, false)
|
||||
}
|
||||
|
||||
private fun setupNavigation(text: ITextComponent, page: Int?){
|
||||
private fun setupNavigation(text: ITextComponent, page: Int?) {
|
||||
val style = text.style
|
||||
|
||||
if (page != null){
|
||||
if (page != null) {
|
||||
style.clickEvent = ClickEvent(RUN_COMMAND, "/${ModCommands.ROOT} help $page")
|
||||
style.color = GREEN
|
||||
style.underlined = true
|
||||
}
|
||||
else{
|
||||
else {
|
||||
style.color = DARK_GREEN
|
||||
}
|
||||
}
|
||||
|
||||
private fun chainTextComponents(vararg components: ITextComponent): ITextComponent{
|
||||
private fun chainTextComponents(vararg components: ITextComponent): ITextComponent {
|
||||
return components.reduce(ITextComponent::appendSibling)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.commands.server
|
||||
|
||||
import chylex.hee.commands.ICommand
|
||||
import chylex.hee.commands.arguments.EnumArgument.Companion.enum
|
||||
import chylex.hee.commands.exception
|
||||
@ -17,10 +18,10 @@ import net.minecraft.command.Commands.literal
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.text.TranslationTextComponent
|
||||
|
||||
object CommandServerInfusions : ICommand{
|
||||
object CommandServerInfusions : ICommand {
|
||||
override val name = "infusions"
|
||||
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>){
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>) {
|
||||
builder.then(
|
||||
literal("reset").executes(this::executeReset)
|
||||
)
|
||||
@ -44,18 +45,18 @@ object CommandServerInfusions : ICommand{
|
||||
private val ALREADY_PRESENT = exception("already_present")
|
||||
private val NOT_PRESENT = exception("not_present")
|
||||
|
||||
private inline fun updateHeldItem(ctx: CommandContext<CommandSource>, modify: (ItemStack, InfusionList) -> ItemStack){
|
||||
private inline fun updateHeldItem(ctx: CommandContext<CommandSource>, modify: (ItemStack, InfusionList) -> ItemStack) {
|
||||
val player = ctx.source.asPlayer()
|
||||
val heldItem = player.getHeldItem(MAIN_HAND)
|
||||
|
||||
if (heldItem.isEmpty){
|
||||
if (heldItem.isEmpty) {
|
||||
throw NO_HELD_ITEM.create()
|
||||
}
|
||||
|
||||
player.setHeldItem(MAIN_HAND, modify(heldItem, InfusionTag.getList(heldItem)))
|
||||
}
|
||||
|
||||
private fun executeReset(ctx: CommandContext<CommandSource>): Int{
|
||||
private fun executeReset(ctx: CommandContext<CommandSource>): Int {
|
||||
var removedInfusions = 0
|
||||
|
||||
updateHeldItem(ctx) { stack, list ->
|
||||
@ -72,11 +73,11 @@ object CommandServerInfusions : ICommand{
|
||||
return removedInfusions
|
||||
}
|
||||
|
||||
private fun executeAdd(ctx: CommandContext<CommandSource>) = returning(1){
|
||||
private fun executeAdd(ctx: CommandContext<CommandSource>) = returning(1) {
|
||||
val infusion = ctx.getEnum<Infusion>("infusion")
|
||||
|
||||
updateHeldItem(ctx) { stack, list ->
|
||||
if (list.has(infusion)){
|
||||
if (list.has(infusion)) {
|
||||
throw ALREADY_PRESENT.create()
|
||||
}
|
||||
|
||||
@ -86,11 +87,11 @@ object CommandServerInfusions : ICommand{
|
||||
ctx.source.sendFeedback(message("add_success", TranslationTextComponent(infusion.translationKey)), true)
|
||||
}
|
||||
|
||||
private fun executeRemove(ctx: CommandContext<CommandSource>) = returning(1){
|
||||
private fun executeRemove(ctx: CommandContext<CommandSource>) = returning(1) {
|
||||
val infusion = ctx.getEnum<Infusion>("infusion")
|
||||
|
||||
updateHeldItem(ctx) { stack, list ->
|
||||
if (!list.has(infusion)){
|
||||
if (!list.has(infusion)) {
|
||||
throw NOT_PRESENT.create()
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.commands.server
|
||||
|
||||
import chylex.hee.commands.ICommand
|
||||
import chylex.hee.commands.exception
|
||||
import chylex.hee.commands.getPos
|
||||
@ -17,10 +18,10 @@ import net.minecraft.command.arguments.ResourceLocationArgument.getResourceLocat
|
||||
import net.minecraft.command.arguments.ResourceLocationArgument.resourceLocation
|
||||
import net.minecraft.world.storage.loot.LootTable
|
||||
|
||||
object CommandServerLootChest : ICommand{
|
||||
object CommandServerLootChest : ICommand {
|
||||
override val name = "lootchest"
|
||||
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>){
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>) {
|
||||
builder.then(
|
||||
argument("pos", blockPos()).then(
|
||||
literal("table").then(
|
||||
@ -39,15 +40,15 @@ object CommandServerLootChest : ICommand{
|
||||
private val TABLE_NOT_FOUND = exception("table_not_found")
|
||||
private val NOT_LOOT_CHEST = exception("not_loot_chest")
|
||||
|
||||
private fun getLootChest(ctx: CommandContext<CommandSource>): TileEntityLootChest{
|
||||
private fun getLootChest(ctx: CommandContext<CommandSource>): TileEntityLootChest {
|
||||
return ctx.getPos("pos").getTile(ctx.source.world) ?: throw NOT_LOOT_CHEST.create()
|
||||
}
|
||||
|
||||
private fun executeSetTable(ctx: CommandContext<CommandSource>) = returning(1){
|
||||
private fun executeSetTable(ctx: CommandContext<CommandSource>) = returning(1) {
|
||||
val tile = getLootChest(ctx)
|
||||
val lootTable = getResourceLocation(ctx, "loot_table")
|
||||
|
||||
if (Environment.getLootTable(lootTable) === LootTable.EMPTY_LOOT_TABLE){
|
||||
if (Environment.getLootTable(lootTable) === LootTable.EMPTY_LOOT_TABLE) {
|
||||
throw TABLE_NOT_FOUND.create()
|
||||
}
|
||||
|
||||
@ -55,12 +56,12 @@ object CommandServerLootChest : ICommand{
|
||||
ctx.source.sendFeedback(message("set_table_success"), true)
|
||||
}
|
||||
|
||||
private fun executeResetTable(ctx: CommandContext<CommandSource>) = returning(1){
|
||||
private fun executeResetTable(ctx: CommandContext<CommandSource>) = returning(1) {
|
||||
getLootChest(ctx).setLootTable(null)
|
||||
ctx.source.sendFeedback(message("remove_table_success"), true)
|
||||
}
|
||||
|
||||
private fun executeResetPlayers(ctx: CommandContext<CommandSource>): Int{
|
||||
private fun executeResetPlayers(ctx: CommandContext<CommandSource>): Int {
|
||||
val total = getLootChest(ctx).resetPlayerInventories()
|
||||
|
||||
ctx.source.sendFeedback(message("reset_success", total), true)
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.commands.server
|
||||
|
||||
import chylex.hee.commands.CommandExecutionFunctionCtx
|
||||
import chylex.hee.commands.ICommand
|
||||
import chylex.hee.commands.arguments.EnumArgument.Companion.enum
|
||||
@ -15,10 +16,10 @@ import net.minecraft.command.CommandSource
|
||||
import net.minecraft.command.Commands.argument
|
||||
import net.minecraft.util.text.TranslationTextComponent
|
||||
|
||||
object CommandServerPortalToken : ICommand, CommandExecutionFunctionCtx<Boolean>{
|
||||
object CommandServerPortalToken : ICommand, CommandExecutionFunctionCtx<Boolean> {
|
||||
override val name = "token"
|
||||
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>){
|
||||
override fun register(builder: ArgumentBuilder<CommandSource, *>) {
|
||||
builder.then(
|
||||
argument("territory", enum<TerritoryType>()).executes(this, false).then(
|
||||
argument("type", enum<TokenType>()).executes(this, true)
|
||||
@ -26,11 +27,11 @@ object CommandServerPortalToken : ICommand, CommandExecutionFunctionCtx<Boolean>
|
||||
)
|
||||
}
|
||||
|
||||
override fun invoke(ctx: CommandContext<CommandSource>, hasType: Boolean) = returning(1){
|
||||
override fun invoke(ctx: CommandContext<CommandSource>, hasType: Boolean) = returning(1) {
|
||||
val territory = ctx.getEnum<TerritoryType>("territory")
|
||||
val type = if (hasType) ctx.getEnum("type") else TokenType.NORMAL
|
||||
|
||||
with(ctx.source){
|
||||
with(ctx.source) {
|
||||
asPlayer().addItemStackToInventory(ModItems.PORTAL_TOKEN.forTerritory(type, territory))
|
||||
sendFeedback(message("success", TranslationTextComponent(territory.translationKey)), true)
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.inventory.isNotEmpty
|
||||
@ -26,17 +27,17 @@ import net.minecraft.util.math.BlockRayTraceResult
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent
|
||||
|
||||
abstract class BlockAbstractCauldron(builder: BlockBuilder) : BlockCauldron(builder.p){
|
||||
abstract class BlockAbstractCauldron(builder: BlockBuilder) : BlockCauldron(builder.p) {
|
||||
@SubscribeAllEvents(modid = HEE.ID)
|
||||
companion object{
|
||||
companion object {
|
||||
const val MAX_LEVEL = 3
|
||||
|
||||
@SubscribeEvent
|
||||
fun onEntityItemPickup(e: EntityItemPickupEvent){
|
||||
fun onEntityItemPickup(e: EntityItemPickupEvent) {
|
||||
val item = e.item
|
||||
val pos = Pos(item)
|
||||
|
||||
if (pos.getBlock(item.world) is BlockCauldron && Pos(e.player) != pos){
|
||||
if (pos.getBlock(item.world) is BlockCauldron && Pos(e.player) != pos) {
|
||||
e.isCanceled = true
|
||||
}
|
||||
}
|
||||
@ -45,35 +46,35 @@ abstract class BlockAbstractCauldron(builder: BlockBuilder) : BlockCauldron(buil
|
||||
protected abstract fun createFilledBucket(): ItemStack?
|
||||
protected abstract fun createFilledBottle(): ItemStack?
|
||||
|
||||
override fun setWaterLevel(world: World, pos: BlockPos, state: BlockState, level: Int){
|
||||
override fun setWaterLevel(world: World, pos: BlockPos, state: BlockState, level: Int) {
|
||||
super.setWaterLevel(world, pos, if (level == 0) Blocks.CAULDRON.defaultState else state, level)
|
||||
}
|
||||
|
||||
private fun useAndUpdateHeldItem(player: EntityPlayer, hand: Hand, newHeldItem: ItemStack){
|
||||
private fun useAndUpdateHeldItem(player: EntityPlayer, hand: Hand, newHeldItem: ItemStack) {
|
||||
val oldHeldItem = player.getHeldItem(hand)
|
||||
|
||||
oldHeldItem.shrink(1)
|
||||
|
||||
if (oldHeldItem.isEmpty){
|
||||
if (oldHeldItem.isEmpty) {
|
||||
player.setHeldItem(hand, newHeldItem)
|
||||
}
|
||||
else if (!player.inventory.addItemStackToInventory(newHeldItem)){
|
||||
else if (!player.inventory.addItemStackToInventory(newHeldItem)) {
|
||||
player.dropItem(newHeldItem, false)
|
||||
}
|
||||
}
|
||||
|
||||
final override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
final override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType {
|
||||
val item = player.getHeldItem(hand).takeIf { it.isNotEmpty }?.item
|
||||
|
||||
if (item == null){
|
||||
if (item == null) {
|
||||
return PASS
|
||||
}
|
||||
|
||||
if (item === Items.BUCKET){
|
||||
if (item === Items.BUCKET) {
|
||||
val filledBucket = createFilledBucket()
|
||||
|
||||
if (filledBucket != null && state[LEVEL] == MAX_LEVEL){
|
||||
if (!world.isRemote){
|
||||
if (filledBucket != null && state[LEVEL] == MAX_LEVEL) {
|
||||
if (!world.isRemote) {
|
||||
player.addStat(Stats.CAULDRON_USED)
|
||||
useAndUpdateHeldItem(player, hand, filledBucket)
|
||||
setWaterLevel(world, pos, state, 0)
|
||||
@ -84,11 +85,11 @@ abstract class BlockAbstractCauldron(builder: BlockBuilder) : BlockCauldron(buil
|
||||
|
||||
return SUCCESS
|
||||
}
|
||||
else if (item === Items.GLASS_BOTTLE){
|
||||
else if (item === Items.GLASS_BOTTLE) {
|
||||
val filledBottle = createFilledBottle()
|
||||
|
||||
if (filledBottle != null && state[LEVEL] > 0){
|
||||
if (!world.isRemote){
|
||||
if (filledBottle != null && state[LEVEL] > 0) {
|
||||
if (!world.isRemote) {
|
||||
player.addStat(Stats.CAULDRON_USED)
|
||||
useAndUpdateHeldItem(player, hand, filledBottle)
|
||||
setWaterLevel(world, pos, state, state[LEVEL] - 1)
|
||||
@ -103,6 +104,6 @@ abstract class BlockAbstractCauldron(builder: BlockBuilder) : BlockCauldron(buil
|
||||
return PASS
|
||||
}
|
||||
|
||||
override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity){}
|
||||
override fun fillWithRain(world: World, pos: BlockPos){}
|
||||
override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) {}
|
||||
override fun fillWithRain(world: World, pos: BlockPos) {}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.entity.base.TileEntityBaseChest
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.entity.living.ai.AIOcelotSitOverride.IOcelotCanSitOn
|
||||
@ -39,20 +40,20 @@ import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.IWorldReader
|
||||
import net.minecraft.world.World
|
||||
|
||||
abstract class BlockAbstractChest<T : TileEntityBaseChest>(builder: BlockBuilder) : AbstractChestBlock<T>(builder.p, supply(null)), IOcelotCanSitOn{
|
||||
private companion object{
|
||||
abstract class BlockAbstractChest<T : TileEntityBaseChest>(builder: BlockBuilder) : AbstractChestBlock<T>(builder.p, supply(null)), IOcelotCanSitOn {
|
||||
private companion object {
|
||||
private val AABB = AxisAlignedBB(0.0625, 0.0, 0.0625, 0.9375, 0.875, 0.9375).asVoxelShape
|
||||
}
|
||||
|
||||
init{
|
||||
init {
|
||||
defaultState = stateContainer.baseState.withFacing(NORTH)
|
||||
}
|
||||
|
||||
override fun fillStateContainer(container: Builder<Block, BlockState>){
|
||||
override fun fillStateContainer(container: Builder<Block, BlockState>) {
|
||||
container.add(FACING)
|
||||
}
|
||||
|
||||
override fun getShape(state: BlockState, world: IBlockReader, pos: BlockPos, context: ISelectionContext): VoxelShape{
|
||||
override fun getShape(state: BlockState, world: IBlockReader, pos: BlockPos, context: ISelectionContext): VoxelShape {
|
||||
return AABB
|
||||
}
|
||||
|
||||
@ -60,47 +61,47 @@ abstract class BlockAbstractChest<T : TileEntityBaseChest>(builder: BlockBuilder
|
||||
|
||||
abstract fun createTileEntity(): T
|
||||
|
||||
override fun hasTileEntity(state: BlockState): Boolean{
|
||||
override fun hasTileEntity(state: BlockState): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
final override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity{
|
||||
final override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity {
|
||||
return createTileEntity()
|
||||
}
|
||||
|
||||
final override fun createNewTileEntity(world: IBlockReader): TileEntity{
|
||||
final override fun createNewTileEntity(world: IBlockReader): TileEntity {
|
||||
return createTileEntity()
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
override fun combine(state: BlockState, world: World, pos: BlockPos, unknown: Boolean): ICallbackWrapper<out TileEntityChest>{
|
||||
override fun combine(state: BlockState, world: World, pos: BlockPos, unknown: Boolean): ICallbackWrapper<out TileEntityChest> {
|
||||
return (Blocks.ENDER_CHEST as AbstractChestBlock<*>).combine(state, world, pos, unknown) // UPDATE reduce hackiness
|
||||
}
|
||||
|
||||
// Placement and interaction
|
||||
|
||||
override fun getStateForPlacement(context: BlockItemUseContext): BlockState{
|
||||
override fun getStateForPlacement(context: BlockItemUseContext): BlockState {
|
||||
return this.withFacing(context.placementHorizontalFacing.opposite)
|
||||
}
|
||||
|
||||
final override fun onBlockPlacedBy(world: World, pos: BlockPos, state: BlockState, placer: EntityLivingBase?, stack: ItemStack){
|
||||
if (stack.hasDisplayName()){
|
||||
final override fun onBlockPlacedBy(world: World, pos: BlockPos, state: BlockState, placer: EntityLivingBase?, stack: ItemStack) {
|
||||
if (stack.hasDisplayName()) {
|
||||
pos.getTile<TileEntityBaseChest>(world)?.setCustomName(stack.displayName)
|
||||
}
|
||||
}
|
||||
|
||||
final override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
if (world.isRemote){
|
||||
final override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType {
|
||||
if (world.isRemote) {
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
val posAbove = pos.up()
|
||||
|
||||
if (posAbove.getState(world).isNormalCube(world, posAbove)){
|
||||
if (posAbove.getState(world).isNormalCube(world, posAbove)) {
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
if (world.selectExistingEntities.inBox<EntityCat>(AxisAlignedBB(posAbove)).any { it.isSitting }){
|
||||
if (world.selectExistingEntities.inBox<EntityCat>(AxisAlignedBB(posAbove)).any { it.isSitting }) {
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
@ -108,7 +109,7 @@ abstract class BlockAbstractChest<T : TileEntityBaseChest>(builder: BlockBuilder
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
protected open fun openChest(world: World, pos: BlockPos, player: EntityPlayer){
|
||||
protected open fun openChest(world: World, pos: BlockPos, player: EntityPlayer) {
|
||||
pos.getTile<TileEntityBaseChest>(world)?.let {
|
||||
ModContainers.open(player, it, pos)
|
||||
}
|
||||
@ -116,17 +117,17 @@ abstract class BlockAbstractChest<T : TileEntityBaseChest>(builder: BlockBuilder
|
||||
|
||||
// Ocelot behavior
|
||||
|
||||
override fun canOcelotSitOn(world: IWorldReader, pos: BlockPos): Boolean{
|
||||
override fun canOcelotSitOn(world: IWorldReader, pos: BlockPos): Boolean {
|
||||
return pos.getTile<TileEntityBaseChest>(world)?.isLidClosed == true
|
||||
}
|
||||
|
||||
// State handling
|
||||
|
||||
override fun rotate(state: BlockState, rot: Rotation): BlockState{
|
||||
override fun rotate(state: BlockState, rot: Rotation): BlockState {
|
||||
return state.withFacing(rot.rotate(state[FACING]))
|
||||
}
|
||||
|
||||
override fun mirror(state: BlockState, mirror: Mirror): BlockState{
|
||||
override fun mirror(state: BlockState, mirror: Mirror): BlockState {
|
||||
return state.withFacing(mirror.mirror(state[FACING]))
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.fluid.FlowingFluid5
|
||||
import chylex.hee.game.block.fluid.FluidBase
|
||||
import chylex.hee.game.block.logic.BlockCollisionLimiter
|
||||
@ -26,9 +27,9 @@ import net.minecraft.world.World
|
||||
|
||||
abstract class BlockAbstractGoo(
|
||||
private val fluid: FluidBase,
|
||||
material: Material
|
||||
) : BlockFlowingFluid(supply(fluid.still), Properties.create(material, fluid.mapColor).hardnessAndResistance(fluid.resistance).doesNotBlockMovement().noDrops()){
|
||||
protected companion object{
|
||||
material: Material,
|
||||
) : BlockFlowingFluid(supply(fluid.still), Properties.create(material, fluid.mapColor).hardnessAndResistance(fluid.resistance).doesNotBlockMovement().noDrops()) {
|
||||
protected companion object {
|
||||
private const val LAST_TIME_TAG = "Time"
|
||||
private const val TOTAL_TICKS_TAG = "Ticks"
|
||||
}
|
||||
@ -41,8 +42,8 @@ abstract class BlockAbstractGoo(
|
||||
|
||||
// Behavior
|
||||
|
||||
final override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity){
|
||||
if (collisionLimiter.check(world, entity)){
|
||||
final override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) {
|
||||
if (collisionLimiter.check(world, entity)) {
|
||||
// handling from Entity.doBlockCollisions
|
||||
val bb = entity.boundingBox
|
||||
val posMin = Pos(bb.minX - 0.001, bb.minY - 0.001, bb.minZ - 0.001)
|
||||
@ -50,41 +51,41 @@ abstract class BlockAbstractGoo(
|
||||
|
||||
var lowestLevel = Int.MAX_VALUE
|
||||
|
||||
for(testPos in posMin.allInBoxMutable(posMax)){
|
||||
for(testPos in posMin.allInBoxMutable(posMax)) {
|
||||
val level = testPos.getState(world).takeIf { it.block === this }?.let { FlowingFluid5.stateToLevel(it) } ?: continue
|
||||
|
||||
if (level < lowestLevel){
|
||||
if (level < lowestLevel) {
|
||||
lowestLevel = level
|
||||
}
|
||||
}
|
||||
|
||||
if (lowestLevel != Int.MAX_VALUE){
|
||||
if (!world.isRemote){
|
||||
if (lowestLevel != Int.MAX_VALUE) {
|
||||
if (!world.isRemote) {
|
||||
onInsideGoo(entity)
|
||||
}
|
||||
|
||||
if (!(entity is EntityPlayer && entity.abilities.isFlying)){
|
||||
if (!(entity is EntityPlayer && entity.abilities.isFlying)) {
|
||||
modifyMotion(entity, lowestLevel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected fun trackTick(entity: Entity, maxTicks: Int): Int{
|
||||
protected fun trackTick(entity: Entity, maxTicks: Int): Int {
|
||||
val world = entity.world
|
||||
val currentWorldTime = world.totalTime
|
||||
|
||||
with(entity.heeTag.getOrCreateCompound(tickTrackingKey)){
|
||||
with(entity.heeTag.getOrCreateCompound(tickTrackingKey)) {
|
||||
val lastWorldTime = getLongOrNull(LAST_TIME_TAG) ?: (currentWorldTime - 1)
|
||||
var totalTicks = getInt(TOTAL_TICKS_TAG)
|
||||
|
||||
val ticksSinceLastUpdate = currentWorldTime - lastWorldTime
|
||||
|
||||
if (ticksSinceLastUpdate > 1L){
|
||||
if (ticksSinceLastUpdate > 1L) {
|
||||
totalTicks = (totalTicks - (ticksSinceLastUpdate / 2).toInt()).coerceAtLeast(0)
|
||||
}
|
||||
|
||||
if (totalTicks < maxTicks && world.rand.nextInt(10) != 0){
|
||||
if (totalTicks < maxTicks && world.rand.nextInt(10) != 0) {
|
||||
++totalTicks
|
||||
}
|
||||
|
||||
@ -98,12 +99,12 @@ abstract class BlockAbstractGoo(
|
||||
abstract fun onInsideGoo(entity: Entity)
|
||||
abstract fun modifyMotion(entity: Entity, level: Int)
|
||||
|
||||
override fun getMaterialColor(state: BlockState, world: IBlockReader, pos: BlockPos): MaterialColor{
|
||||
override fun getMaterialColor(state: BlockState, world: IBlockReader, pos: BlockPos): MaterialColor {
|
||||
return fluid.mapColor
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
override fun getFogColor(state: BlockState, world: IWorldReader, pos: BlockPos, entity: Entity, originalColor: Vec3d, partialTicks: Float): Vec3d{
|
||||
override fun getFogColor(state: BlockState, world: IWorldReader, pos: BlockPos, entity: Entity, originalColor: Vec3d, partialTicks: Float): Vec3d {
|
||||
return fluid.fogColor
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.world.allInBox
|
||||
import chylex.hee.game.world.allInBoxMutable
|
||||
@ -26,8 +27,8 @@ import net.minecraft.util.math.shapes.VoxelShape
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.World
|
||||
|
||||
abstract class BlockAbstractPortal(builder: BlockBuilder) : BlockSimpleShaped(builder, AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 0.75, 1.0)){
|
||||
companion object{
|
||||
abstract class BlockAbstractPortal(builder: BlockBuilder) : BlockSimpleShaped(builder, AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 0.75, 1.0)) {
|
||||
companion object {
|
||||
const val MAX_DISTANCE_FROM_FRAME = 6.0
|
||||
const val MAX_SIZE = 5
|
||||
|
||||
@ -36,21 +37,21 @@ abstract class BlockAbstractPortal(builder: BlockBuilder) : BlockSimpleShaped(bu
|
||||
|
||||
private val COLLISION_AABB = AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 0.025, 1.0).asVoxelShape
|
||||
|
||||
fun findInnerArea(world: World, controllerPos: BlockPos, frameBlock: Block): Pair<BlockPos, BlockPos>?{
|
||||
fun findInnerArea(world: World, controllerPos: BlockPos, frameBlock: Block): Pair<BlockPos, BlockPos>? {
|
||||
val mirrorRange = 1..(MAX_SIZE + 1)
|
||||
val halfRange = 1..(1 + (MAX_SIZE / 2))
|
||||
|
||||
for(facing in Facing4){
|
||||
val mirrorPos = controllerPos.offsetUntil(facing, mirrorRange){ it.getBlock(world) === frameBlock } ?: continue
|
||||
for(facing in Facing4) {
|
||||
val mirrorPos = controllerPos.offsetUntil(facing, mirrorRange) { it.getBlock(world) === frameBlock } ?: continue
|
||||
val centerPos = controllerPos.offset(facing, controllerPos.distanceTo(mirrorPos).floorToInt() / 2)
|
||||
|
||||
val perpendicular1 = centerPos.offsetUntil(facing.rotateY(), halfRange){ it.getBlock(world) === frameBlock } ?: continue
|
||||
val perpendicular2 = centerPos.offsetUntil(facing.rotateYCCW(), halfRange){ it.getBlock(world) === frameBlock } ?: continue
|
||||
val perpendicular1 = centerPos.offsetUntil(facing.rotateY(), halfRange) { it.getBlock(world) === frameBlock } ?: continue
|
||||
val perpendicular2 = centerPos.offsetUntil(facing.rotateYCCW(), halfRange) { it.getBlock(world) === frameBlock } ?: continue
|
||||
|
||||
val minPos = controllerPos.min(mirrorPos).min(perpendicular1).min(perpendicular2).add(1, 0, 1)
|
||||
val maxPos = controllerPos.max(mirrorPos).max(perpendicular1).max(perpendicular2).add(-1, 0, -1)
|
||||
|
||||
if (maxPos.x - minPos.x != maxPos.z - minPos.z){
|
||||
if (maxPos.x - minPos.x != maxPos.z - minPos.z) {
|
||||
return null
|
||||
}
|
||||
|
||||
@ -60,51 +61,51 @@ abstract class BlockAbstractPortal(builder: BlockBuilder) : BlockSimpleShaped(bu
|
||||
return null
|
||||
}
|
||||
|
||||
fun spawnInnerBlocks(world: World, controllerPos: BlockPos, frameBlock: Block, innerBlock: Block, minSize: Int){
|
||||
fun spawnInnerBlocks(world: World, controllerPos: BlockPos, frameBlock: Block, innerBlock: Block, minSize: Int) {
|
||||
val (minPos, maxPos) = findInnerArea(world, controllerPos, frameBlock) ?: return
|
||||
|
||||
if (maxPos.x - minPos.x + 1 >= minSize &&
|
||||
maxPos.z - minPos.z + 1 >= minSize &&
|
||||
minPos.allInBoxMutable(maxPos).all { it.isAir(world) }
|
||||
){
|
||||
maxPos.z - minPos.z + 1 >= minSize &&
|
||||
minPos.allInBoxMutable(maxPos).all { it.isAir(world) }
|
||||
) {
|
||||
minPos.allInBoxMutable(maxPos).forEach { it.setBlock(world, innerBlock) }
|
||||
}
|
||||
}
|
||||
|
||||
fun ensureClearance(world: World, spawnPos: BlockPos, radius: Int){
|
||||
for(pos in spawnPos.add(-radius, 1, -radius).allInBox(spawnPos.add(radius, 2, radius))){
|
||||
fun ensureClearance(world: World, spawnPos: BlockPos, radius: Int) {
|
||||
for(pos in spawnPos.add(-radius, 1, -radius).allInBox(spawnPos.add(radius, 2, radius))) {
|
||||
pos.setAir(world)
|
||||
}
|
||||
}
|
||||
|
||||
fun ensurePlatform(world: World, spawnPos: BlockPos, block: Block, radius: Int){
|
||||
for(pos in spawnPos.add(-radius, -1, -radius).allInBox(spawnPos.add(radius, -1, radius))){
|
||||
if (!pos.isTopSolid(world)){
|
||||
fun ensurePlatform(world: World, spawnPos: BlockPos, block: Block, radius: Int) {
|
||||
for(pos in spawnPos.add(-radius, -1, -radius).allInBox(spawnPos.add(radius, -1, radius))) {
|
||||
if (!pos.isTopSolid(world)) {
|
||||
pos.setBlock(world, block)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface IPortalController{
|
||||
interface IPortalController {
|
||||
val clientAnimationProgress: LerpedFloat
|
||||
val clientPortalOffset: LerpedFloat
|
||||
}
|
||||
|
||||
override fun hasTileEntity(state: BlockState): Boolean{
|
||||
override fun hasTileEntity(state: BlockState): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
abstract override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity
|
||||
protected abstract fun onEntityInside(world: World, pos: BlockPos, entity: Entity)
|
||||
|
||||
final override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity){
|
||||
if (!world.isRemote && !entity.isPassenger && !entity.isBeingRidden && entity.isNonBoss && entity.posY <= pos.y + 0.05){
|
||||
final override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) {
|
||||
if (!world.isRemote && !entity.isPassenger && !entity.isBeingRidden && entity.isNonBoss && entity.posY <= pos.y + 0.05) {
|
||||
onEntityInside(world, pos, entity)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCollisionShape(state: BlockState, world: IBlockReader, pos: BlockPos, context: ISelectionContext): VoxelShape{
|
||||
override fun getCollisionShape(state: BlockState, world: IBlockReader, pos: BlockPos, context: ISelectionContext): VoxelShape {
|
||||
return COLLISION_AABB
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.client.render.block.IBlockLayerCutout
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.system.forge.Side
|
||||
@ -9,14 +10,14 @@ import net.minecraft.util.text.ITextComponent
|
||||
import net.minecraft.util.text.TranslationTextComponent
|
||||
import net.minecraft.world.IBlockReader
|
||||
|
||||
abstract class BlockAbstractTable(builder: BlockBuilder, val tier: Int, val firstTier: Int) : BlockSimple(builder), IBlockLayerCutout{
|
||||
init{
|
||||
require(tier in 1..3){ "[BlockAbstractTable] tier must be in the range 1..3" }
|
||||
require(firstTier <= tier){ "[BlockAbstractTable] firstTier cannot be larger than current tier" }
|
||||
abstract class BlockAbstractTable(builder: BlockBuilder, val tier: Int, val firstTier: Int) : BlockSimple(builder), IBlockLayerCutout {
|
||||
init {
|
||||
require(tier in 1..3) { "[BlockAbstractTable] tier must be in the range 1..3" }
|
||||
require(firstTier <= tier) { "[BlockAbstractTable] firstTier cannot be larger than current tier" }
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
override fun addInformation(stack: ItemStack, world: IBlockReader?, lines: MutableList<ITextComponent>, flags: ITooltipFlag){
|
||||
override fun addInformation(stack: ItemStack, world: IBlockReader?, lines: MutableList<ITextComponent>, flags: ITooltipFlag) {
|
||||
lines.add(TranslationTextComponent("block.tooltip.hee.table.tier", tier))
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.entity.base.TileEntityBaseTable
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.world.getTile
|
||||
@ -9,31 +10,31 @@ import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.World
|
||||
|
||||
abstract class BlockAbstractTableTile<T : TileEntityBaseTable>(builder: BlockBuilder, protected val name: String, tier: Int, firstTier: Int) : BlockAbstractTable(builder, tier, firstTier){
|
||||
abstract class BlockAbstractTableTile<T : TileEntityBaseTable>(builder: BlockBuilder, protected val name: String, tier: Int, firstTier: Int) : BlockAbstractTable(builder, tier, firstTier) {
|
||||
private val translationKey = "block.hee.$name"
|
||||
|
||||
override fun getTranslationKey(): String{
|
||||
override fun getTranslationKey(): String {
|
||||
return translationKey
|
||||
}
|
||||
|
||||
abstract fun createTileEntity(): T
|
||||
|
||||
override fun hasTileEntity(state: BlockState): Boolean{
|
||||
override fun hasTileEntity(state: BlockState): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
final override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity{
|
||||
final override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity {
|
||||
return createTileEntity()
|
||||
}
|
||||
|
||||
override fun onBlockHarvested(world: World, pos: BlockPos, state: BlockState, player: EntityPlayer){
|
||||
if (!world.isRemote && player.isCreative){
|
||||
override fun onBlockHarvested(world: World, pos: BlockPos, state: BlockState, player: EntityPlayer) {
|
||||
if (!world.isRemote && player.isCreative) {
|
||||
pos.getTile<TileEntityBaseTable>(world)?.onTableDestroyed(dropTableLink = false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onReplaced(state: BlockState, world: World, pos: BlockPos, newState: BlockState, isMoving: Boolean){
|
||||
if (newState.block !== this){
|
||||
override fun onReplaced(state: BlockState, world: World, pos: BlockPos, newState: BlockState, isMoving: Boolean) {
|
||||
if (newState.block !== this) {
|
||||
pos.getTile<TileEntityBaseTable>(world)?.onTableDestroyed(dropTableLink = true)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.client.render.block.IBlockLayerCutout
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.world.breakBlock
|
||||
@ -25,50 +26,50 @@ import net.minecraftforge.common.MinecraftForge
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed
|
||||
import java.util.Random
|
||||
|
||||
class BlockAncientCobweb(builder: BlockBuilder) : BlockWeb(builder.p), IBlockLayerCutout{
|
||||
init{
|
||||
class BlockAncientCobweb(builder: BlockBuilder) : BlockWeb(builder.p), IBlockLayerCutout {
|
||||
init {
|
||||
MinecraftForge.EVENT_BUS.register(this)
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onBreakSpeed(e: BreakSpeed){
|
||||
if (e.state.block !== this){
|
||||
fun onBreakSpeed(e: BreakSpeed) {
|
||||
if (e.state.block !== this) {
|
||||
return
|
||||
}
|
||||
|
||||
val item = e.player.getHeldItem(MAIN_HAND).item
|
||||
|
||||
if (item is ItemSword){
|
||||
if (item is ItemSword) {
|
||||
e.newSpeed = e.originalSpeed * 15.8F
|
||||
}
|
||||
else if (item is ItemShears){
|
||||
else if (item is ItemShears) {
|
||||
e.newSpeed = e.originalSpeed * 5.6F
|
||||
}
|
||||
}
|
||||
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random) {
|
||||
pos.breakBlock(world, true)
|
||||
}
|
||||
|
||||
override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity){
|
||||
if (entity is EntityItem){
|
||||
override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) {
|
||||
if (entity is EntityItem) {
|
||||
entity.setMotionMultiplier(state, Vec3.xyz(0.6))
|
||||
}
|
||||
else if (!world.isRemote){
|
||||
val canBreak = when(entity){
|
||||
else if (!world.isRemote) {
|
||||
val canBreak = when(entity) {
|
||||
is EntityPlayer -> !entity.abilities.isFlying
|
||||
is EntityMob -> entity.attackTarget != null && (entity.width * entity.height) > 0.5F
|
||||
is EntityLivingBase -> false
|
||||
else -> true
|
||||
}
|
||||
|
||||
if (canBreak){
|
||||
if (canBreak) {
|
||||
world.pendingBlockTicks.scheduleTick(pos, this, 1) // delay required to avoid client-side particle crash
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCollisionShape(state: BlockState, world: IBlockReader, pos: BlockPos, context: ISelectionContext): VoxelShape{
|
||||
override fun getCollisionShape(state: BlockState, world: IBlockReader, pos: BlockPos, context: ISelectionContext): VoxelShape {
|
||||
return VoxelShapes.empty()
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.client.render.block.IBlockLayerCutout
|
||||
import chylex.hee.game.block.entity.TileEntityBrewingStandCustom
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
@ -19,22 +20,22 @@ import net.minecraft.util.math.BlockRayTraceResult
|
||||
import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.World
|
||||
|
||||
open class BlockBrewingStandCustom(builder: BlockBuilder) : BlockBrewingStand(builder.p), IBlockLayerCutout{
|
||||
override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity{
|
||||
open class BlockBrewingStandCustom(builder: BlockBuilder) : BlockBrewingStand(builder.p), IBlockLayerCutout {
|
||||
override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity {
|
||||
return TileEntityBrewingStandCustom()
|
||||
}
|
||||
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType{
|
||||
if (world.isRemote){
|
||||
override fun onBlockActivated(state: BlockState, world: World, pos: BlockPos, player: EntityPlayer, hand: Hand, hit: BlockRayTraceResult): ActionResultType {
|
||||
if (world.isRemote) {
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
val tile = pos.getTile<TileEntityBrewingStand>(world)
|
||||
|
||||
if (tile is TileEntityBrewingStandCustom){
|
||||
if (tile is TileEntityBrewingStandCustom) {
|
||||
ModContainers.open(player, tile, pos)
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// POLISH maybe make the tile entity upgrade smoother but this is fine lol
|
||||
pos.breakBlock(world, false)
|
||||
pos.setBlock(world, this)
|
||||
|
@ -1,14 +1,15 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.item.Items
|
||||
|
||||
class BlockCauldronWithDragonsBreath(builder: BlockBuilder) : BlockAbstractCauldron(builder){
|
||||
override fun createFilledBucket(): ItemStack?{
|
||||
class BlockCauldronWithDragonsBreath(builder: BlockBuilder) : BlockAbstractCauldron(builder) {
|
||||
override fun createFilledBucket(): ItemStack? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun createFilledBottle(): ItemStack?{
|
||||
override fun createFilledBottle(): ItemStack? {
|
||||
return ItemStack(Items.DRAGON_BREATH)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.potion.brewing.PotionItems
|
||||
import chylex.hee.system.migration.PotionTypes
|
||||
@ -9,18 +10,18 @@ import net.minecraft.item.Items
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
|
||||
class BlockCauldronWithGoo(builder: BlockBuilder, private val goo: BlockAbstractGoo) : BlockAbstractCauldron(builder){
|
||||
override fun createFilledBucket(): ItemStack?{
|
||||
class BlockCauldronWithGoo(builder: BlockBuilder, private val goo: BlockAbstractGoo) : BlockAbstractCauldron(builder) {
|
||||
override fun createFilledBucket(): ItemStack? {
|
||||
return ItemStack(goo.fluid.filledBucket)
|
||||
}
|
||||
|
||||
override fun createFilledBottle(): ItemStack?{
|
||||
override fun createFilledBottle(): ItemStack? {
|
||||
return PotionItems.getBottle(Items.POTION, PotionTypes.THICK)
|
||||
}
|
||||
|
||||
override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity){
|
||||
override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) {
|
||||
goo.onInsideGoo(entity)
|
||||
}
|
||||
|
||||
override fun fillWithRain(world: World, pos: BlockPos){}
|
||||
override fun fillWithRain(world: World, pos: BlockPos) {}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.BlockCorruptedEnergy.SpawnResult.FAIL
|
||||
import chylex.hee.game.block.BlockCorruptedEnergy.SpawnResult.PASSTHROUGH
|
||||
import chylex.hee.game.block.BlockCorruptedEnergy.SpawnResult.SUCCESS
|
||||
@ -45,8 +46,8 @@ import net.minecraft.world.World
|
||||
import net.minecraft.world.server.ServerWorld
|
||||
import java.util.Random
|
||||
|
||||
class BlockCorruptedEnergy(builder: BlockBuilder) : BlockSimple(builder){
|
||||
companion object{
|
||||
class BlockCorruptedEnergy(builder: BlockBuilder) : BlockSimple(builder) {
|
||||
companion object {
|
||||
private const val MIN_LEVEL = 0
|
||||
private const val MAX_LEVEL = 20
|
||||
|
||||
@ -65,30 +66,30 @@ class BlockCorruptedEnergy(builder: BlockBuilder) : BlockSimple(builder){
|
||||
hideOnMinimalSetting = false
|
||||
)
|
||||
|
||||
private fun tickRateForLevel(level: Int): Int{
|
||||
private fun tickRateForLevel(level: Int): Int {
|
||||
return (MAX_TICK_RATE - (level / 2)).coerceAtLeast(MIN_TICK_RATE)
|
||||
}
|
||||
|
||||
private fun isEntityTolerant(entity: EntityLivingBase): Boolean{
|
||||
private fun isEntityTolerant(entity: EntityLivingBase): Boolean {
|
||||
return CustomCreatureType.isDemon(entity) || CustomCreatureType.isShadow(entity) || entity is IImmuneToCorruptedEnergy
|
||||
}
|
||||
}
|
||||
|
||||
override fun fillStateContainer(container: Builder<Block, BlockState>){
|
||||
override fun fillStateContainer(container: Builder<Block, BlockState>) {
|
||||
container.add(LEVEL)
|
||||
}
|
||||
|
||||
// Utility methods
|
||||
|
||||
enum class SpawnResult{
|
||||
enum class SpawnResult {
|
||||
SUCCESS, PASSTHROUGH, FAIL
|
||||
}
|
||||
|
||||
fun spawnCorruptedEnergy(world: World, pos: BlockPos, level: Int): SpawnResult{
|
||||
if (level < MIN_LEVEL){
|
||||
fun spawnCorruptedEnergy(world: World, pos: BlockPos, level: Int): SpawnResult {
|
||||
if (level < MIN_LEVEL) {
|
||||
return FAIL
|
||||
}
|
||||
else if (level > MAX_LEVEL){
|
||||
else if (level > MAX_LEVEL) {
|
||||
return spawnCorruptedEnergy(world, pos, MAX_LEVEL)
|
||||
}
|
||||
|
||||
@ -96,21 +97,21 @@ class BlockCorruptedEnergy(builder: BlockBuilder) : BlockSimple(builder){
|
||||
val currentBlock = currentState.block
|
||||
var updateFlags = FLAG_SYNC_CLIENT
|
||||
|
||||
if (currentBlock === this){
|
||||
if (level - currentState[LEVEL] < 3 || world.rand.nextBoolean()){
|
||||
if (currentBlock === this) {
|
||||
if (level - currentState[LEVEL] < 3 || world.rand.nextBoolean()) {
|
||||
return FAIL
|
||||
}
|
||||
|
||||
updateFlags = FLAG_NONE
|
||||
}
|
||||
else if (currentBlock === ModBlocks.ENERGY_CLUSTER){
|
||||
if (world.rand.nextInt(100) < 5 * level){
|
||||
else if (currentBlock === ModBlocks.ENERGY_CLUSTER) {
|
||||
if (world.rand.nextInt(100) < 5 * level) {
|
||||
pos.getTile<TileEntityEnergyCluster>(world)?.deteriorateCapacity(level)
|
||||
}
|
||||
|
||||
return PASSTHROUGH
|
||||
}
|
||||
else if (!currentBlock.isAir(currentState, world, pos)){
|
||||
else if (!currentBlock.isAir(currentState, world, pos)) {
|
||||
return if (currentState.isNormalCube(world, pos))
|
||||
FAIL
|
||||
else
|
||||
@ -123,39 +124,39 @@ class BlockCorruptedEnergy(builder: BlockBuilder) : BlockSimple(builder){
|
||||
|
||||
// Tick handling
|
||||
|
||||
override fun tickRate(world: IWorldReader): Int{
|
||||
override fun tickRate(world: IWorldReader): Int {
|
||||
return MAX_TICK_RATE
|
||||
}
|
||||
|
||||
override fun onBlockAdded(state: BlockState, world: World, pos: BlockPos, oldState: BlockState, isMoving: Boolean){
|
||||
override fun onBlockAdded(state: BlockState, world: World, pos: BlockPos, oldState: BlockState, isMoving: Boolean) {
|
||||
world.pendingBlockTicks.scheduleTick(pos, this, tickRateForLevel(state[LEVEL]))
|
||||
}
|
||||
|
||||
override fun randomTick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
if (!world.pendingBlockTicks.isTickScheduled(pos, this)){
|
||||
override fun randomTick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random) {
|
||||
if (!world.pendingBlockTicks.isTickScheduled(pos, this)) {
|
||||
pos.removeBlock(world)
|
||||
}
|
||||
}
|
||||
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random) {
|
||||
val level = state[LEVEL]
|
||||
val remainingFacings = Facing6.toMutableList()
|
||||
|
||||
repeat(rand.nextInt(3, 5).coerceAtMost(level)){
|
||||
repeat(rand.nextInt(3, 5).coerceAtMost(level)) {
|
||||
val facing = rand.removeItem(remainingFacings)
|
||||
val adjacentPos = pos.offset(facing)
|
||||
|
||||
val spreadDecrease = if (rand.nextInt(3) == 0) 0 else 1
|
||||
|
||||
if (spawnCorruptedEnergy(world, adjacentPos, level - spreadDecrease) == PASSTHROUGH){
|
||||
if (spawnCorruptedEnergy(world, adjacentPos, level - spreadDecrease) == PASSTHROUGH) {
|
||||
spawnCorruptedEnergy(world, adjacentPos.offset(facing), level - spreadDecrease - 1)
|
||||
}
|
||||
}
|
||||
|
||||
if (rand.nextInt(4) != 0){
|
||||
if (rand.nextInt(4) != 0) {
|
||||
val decreaseToLevel = level - rand.nextInt(1, 2)
|
||||
|
||||
if (decreaseToLevel < MIN_LEVEL){
|
||||
if (decreaseToLevel < MIN_LEVEL) {
|
||||
pos.removeBlock(world)
|
||||
return
|
||||
}
|
||||
@ -168,16 +169,16 @@ class BlockCorruptedEnergy(builder: BlockBuilder) : BlockSimple(builder){
|
||||
|
||||
// Interactions
|
||||
|
||||
override fun isAir(state: BlockState, world: IBlockReader, pos: BlockPos): Boolean{
|
||||
override fun isAir(state: BlockState, world: IBlockReader, pos: BlockPos): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun propagatesSkylightDown(state: BlockState, world: IBlockReader, pos: BlockPos): Boolean{
|
||||
override fun propagatesSkylightDown(state: BlockState, world: IBlockReader, pos: BlockPos): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity){
|
||||
if (!world.isRemote && entity is EntityLivingBase && !isEntityTolerant(entity)){
|
||||
override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) {
|
||||
if (!world.isRemote && entity is EntityLivingBase && !isEntityTolerant(entity)) {
|
||||
CombinedDamage(
|
||||
DAMAGE_PART_NORMAL to 0.75F,
|
||||
DAMAGE_PART_MAGIC to (0.75F + state[LEVEL] / 10F)
|
||||
@ -188,16 +189,16 @@ class BlockCorruptedEnergy(builder: BlockBuilder) : BlockSimple(builder){
|
||||
// Client side
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
override fun animateTick(state: BlockState, world: World, pos: BlockPos, rand: Random){
|
||||
override fun animateTick(state: BlockState, world: World, pos: BlockPos, rand: Random) {
|
||||
val amount = rand.nextInt(0, 2)
|
||||
|
||||
if (amount > 0){
|
||||
if (amount > 0) {
|
||||
PARTICLE_CORRUPTION.spawn(Point(pos, amount), rand) // POLISH figure out how to show particles outside animateTick range
|
||||
}
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
override fun getAmbientOcclusionLightValue(state: BlockState, world: IBlockReader, pos: BlockPos): Float{
|
||||
override fun getAmbientOcclusionLightValue(state: BlockState, world: IBlockReader, pos: BlockPos): Float {
|
||||
return 1F
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.game.block.entity.TileEntityDarkChest
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
import chylex.hee.game.entity.living.ai.AIOcelotSitOverride.IOcelotCanSitOn
|
||||
@ -13,12 +14,12 @@ import net.minecraft.world.IBlockReader
|
||||
import net.minecraft.world.IWorldReader
|
||||
import java.util.function.Supplier
|
||||
|
||||
class BlockDarkChest(builder: BlockBuilder) : BlockChest(builder.p, Supplier<TileEntityType<out TileEntityChest>> { ModTileEntities.DARK_CHEST }), IOcelotCanSitOn{
|
||||
override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity{
|
||||
class BlockDarkChest(builder: BlockBuilder) : BlockChest(builder.p, Supplier<TileEntityType<out TileEntityChest>> { ModTileEntities.DARK_CHEST }), IOcelotCanSitOn {
|
||||
override fun createTileEntity(state: BlockState, world: IBlockReader): TileEntity {
|
||||
return TileEntityDarkChest()
|
||||
}
|
||||
|
||||
override fun canOcelotSitOn(world: IWorldReader, pos: BlockPos): Boolean{
|
||||
override fun canOcelotSitOn(world: IWorldReader, pos: BlockPos): Boolean {
|
||||
return TileEntityChest.getPlayersUsing(world, pos) < 1
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package chylex.hee.game.block
|
||||
|
||||
import chylex.hee.client.render.block.IBlockLayerCutout
|
||||
import chylex.hee.game.block.IBlockDeathFlowerDecaying.Companion.LEVEL
|
||||
import chylex.hee.game.block.properties.BlockBuilder
|
||||
@ -19,8 +20,8 @@ import net.minecraft.world.server.ServerWorld
|
||||
import net.minecraft.world.storage.loot.LootContext
|
||||
import java.util.Random
|
||||
|
||||
class BlockDeathFlowerDecaying(builder: BlockBuilder) : BlockEndPlant(builder), IBlockDeathFlowerDecaying, IBlockLayerCutout{
|
||||
override fun fillStateContainer(container: Builder<Block, BlockState>){
|
||||
class BlockDeathFlowerDecaying(builder: BlockBuilder) : BlockEndPlant(builder), IBlockDeathFlowerDecaying, IBlockLayerCutout {
|
||||
override fun fillStateContainer(container: Builder<Block, BlockState>) {
|
||||
container.add(LEVEL)
|
||||
}
|
||||
|
||||
@ -33,33 +34,33 @@ class BlockDeathFlowerDecaying(builder: BlockBuilder) : BlockEndPlant(builder),
|
||||
override val witheredFlowerBlock
|
||||
get() = ModBlocks.DEATH_FLOWER_WITHERED
|
||||
|
||||
override fun tickRate(world: IWorldReader): Int{
|
||||
override fun tickRate(world: IWorldReader): Int {
|
||||
return implTickRate()
|
||||
}
|
||||
|
||||
override fun getStateForPlacement(context: BlockItemUseContext): BlockState{
|
||||
override fun getStateForPlacement(context: BlockItemUseContext): BlockState {
|
||||
return defaultState.with(LEVEL, ItemDeathFlower.getDeathLevel(context.item))
|
||||
}
|
||||
|
||||
private fun getDrop(state: BlockState): ItemStack{
|
||||
private fun getDrop(state: BlockState): ItemStack {
|
||||
return ItemStack(this).also { ItemDeathFlower.setDeathLevel(it, state[LEVEL]) }
|
||||
}
|
||||
|
||||
override fun getDrops(state: BlockState, context: LootContext.Builder): MutableList<ItemStack>{
|
||||
override fun getDrops(state: BlockState, context: LootContext.Builder): MutableList<ItemStack> {
|
||||
return mutableListOf(getDrop(state))
|
||||
}
|
||||
|
||||
override fun getPickBlock(state: BlockState, target: RayTraceResult, world: IBlockReader, pos: BlockPos, player: EntityPlayer): ItemStack{
|
||||
override fun getPickBlock(state: BlockState, target: RayTraceResult, world: IBlockReader, pos: BlockPos, player: EntityPlayer): ItemStack {
|
||||
return getDrop(state)
|
||||
}
|
||||
|
||||
override fun onBlockAdded(state: BlockState, world: World, pos: BlockPos, oldState: BlockState, isMoving: Boolean){
|
||||
override fun onBlockAdded(state: BlockState, world: World, pos: BlockPos, oldState: BlockState, isMoving: Boolean) {
|
||||
@Suppress("DEPRECATION")
|
||||
super.onBlockAdded(state, world, pos, oldState, isMoving)
|
||||
implOnBlockAdded(world, pos)
|
||||
}
|
||||
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random){
|
||||
override fun tick(state: BlockState, world: ServerWorld, pos: BlockPos, rand: Random) {
|
||||
@Suppress("DEPRECATION")
|
||||
super.tick(state, world, pos, rand)
|
||||
implUpdateTick(world, pos, state, rand)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user