-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supported to template 'path_find_through'.
Modified entity and block settings code style.
- Loading branch information
Showing
15 changed files
with
316 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,11 @@ | |
5, | ||
5 | ||
] | ||
}, | ||
"path_find_through": { | ||
"land": true, | ||
"water": true, | ||
"air": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/java/com/github/cao/awa/conium/block/builder/ConiumBlockBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
src/main/java/com/github/cao/awa/conium/block/setting/ConiumBlockSettings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
package com.github.cao.awa.conium.block.setting | ||
|
||
import com.github.cao.awa.conium.block.template.ConiumBlockTemplate | ||
import com.github.cao.awa.conium.setting.ConiumSettings | ||
import net.minecraft.block.AbstractBlock | ||
import net.minecraft.block.AbstractBlock.Settings | ||
import net.minecraft.client.color.block.BlockColorProvider | ||
import net.minecraft.util.shape.VoxelShape | ||
import net.minecraft.util.shape.VoxelShapes | ||
import net.minecraft.world.RaycastContext | ||
|
||
object ConiumBlockSettingsValue { | ||
val color: Int = 0 | ||
val outlineShape: VoxelShape = VoxelShapes.fullCube() | ||
val landPathThrough: Boolean = false | ||
val waterPathThrough: Boolean = false | ||
val airPathThrough: Boolean = false | ||
} | ||
|
||
class ConiumBlockSettings(val vanillaSettings: Settings) : ConiumSettings<ConiumBlockSettings>() { | ||
companion object { | ||
@JvmStatic | ||
fun create(templates: MutableList<ConiumBlockTemplate>, settings: Settings): ConiumBlockSettings { | ||
return ConiumBlockSettings(settings).also { | ||
templates.forEach { template -> | ||
template.prepare(it) | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Setting the color code of block. | ||
* | ||
* Default is 0. | ||
* | ||
* @see BlockColorProvider.getColor | ||
* | ||
* @author cao_awa | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
var color: Int | ||
get() = this._color ?: ConiumBlockSettingsValue.color | ||
set(value) { | ||
this._color = value | ||
|
||
} | ||
|
||
// The delegate. | ||
private var _color: Int? = null | ||
|
||
/** | ||
* Setting the outline shape of block. | ||
* | ||
* Default is ``fullCube``. | ||
* | ||
* @see AbstractBlock.getOutlineShape | ||
* @see AbstractBlock.AbstractBlockState.getOutlineShape | ||
* @see RaycastContext.ShapeType.OUTLINE | ||
* | ||
* @author cao_awa | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
var outlineShape: VoxelShape | ||
get() = this._outlineShape ?: ConiumBlockSettingsValue.outlineShape | ||
set(value) { | ||
this._outlineShape = value | ||
} | ||
|
||
// The delegate. | ||
private var _outlineShape: VoxelShape? = null | ||
|
||
/** | ||
* Setting the land path through-able of block. | ||
* | ||
* Default is ``false``. | ||
* | ||
* @see AbstractBlock.canPathfindThrough | ||
* | ||
* @author cao_awa | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
var landPathThrough: Boolean | ||
get() = this._landPathThrough ?: ConiumBlockSettingsValue.landPathThrough | ||
set(value) { | ||
this._landPathThrough = value | ||
} | ||
|
||
// The delegate. | ||
private var _landPathThrough: Boolean? = null | ||
|
||
/** | ||
* Setting the water path through-able of block. | ||
* | ||
* Default is ``false``. | ||
* | ||
* @see AbstractBlock.canPathfindThrough | ||
* | ||
* @author cao_awa | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
var waterPathThrough: Boolean | ||
get() = this._waterPathThrough ?: ConiumBlockSettingsValue.waterPathThrough | ||
set(value) { | ||
this._waterPathThrough = value | ||
} | ||
|
||
// The delegate. | ||
private var _waterPathThrough: Boolean? = null | ||
|
||
/** | ||
* Setting the air path through-able of block. | ||
* | ||
* Default is ``false``. | ||
* | ||
* @see AbstractBlock.canPathfindThrough | ||
* | ||
* @author cao_awa | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
var airPathThrough: Boolean | ||
get() = this._airPathThrough ?: ConiumBlockSettingsValue.airPathThrough | ||
set(value) { | ||
this._airPathThrough = value | ||
} | ||
|
||
// The delegate. | ||
private var _airPathThrough: Boolean? = null | ||
|
||
override fun migrateTo(settings: ConiumBlockSettings): ConiumBlockSettings { | ||
return settings.also { | ||
// Apply settings(only configured, no default). | ||
} | ||
} | ||
|
||
override fun newInstance(): ConiumBlockSettings = ConiumBlockSettings(this.vanillaSettings) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...m/github/cao/awa/conium/block/template/path/through/ConiumBlockPathFindThroughTemplate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.github.cao.awa.conium.block.template.path.through | ||
|
||
import com.github.cao.awa.conium.block.setting.ConiumBlockSettings | ||
import com.github.cao.awa.conium.block.template.ConiumBlockTemplate | ||
import com.github.cao.awa.conium.kotlin.extent.json.ifBoolean | ||
import com.github.cao.awa.conium.kotlin.extent.json.ifJsonObject | ||
import com.github.cao.awa.conium.template.ConiumTemplates.Block.PATH_FIND_THROUGH | ||
import com.google.gson.JsonElement | ||
import net.minecraft.registry.RegistryWrapper.WrapperLookup | ||
|
||
class ConiumBlockPathFindThroughTemplate( | ||
private val landPathThrough: Boolean, | ||
private val waterPathThrough: Boolean, | ||
private val airPathThrough: Boolean | ||
) : ConiumBlockTemplate(PATH_FIND_THROUGH) { | ||
companion object { | ||
@JvmStatic | ||
fun create(element: JsonElement, registryLookup: WrapperLookup): ConiumBlockPathFindThroughTemplate { | ||
return element.ifJsonObject({ | ||
ConiumBlockPathFindThroughTemplate( | ||
it["land"]?.asBoolean ?: false, | ||
it["water"]?.asBoolean ?: false, | ||
it["air"]?.asBoolean ?: false, | ||
) | ||
}) { | ||
it.ifBoolean { pathThrough -> | ||
ConiumBlockPathFindThroughTemplate( | ||
pathThrough, | ||
pathThrough, | ||
pathThrough | ||
) | ||
} | ||
}!! | ||
} | ||
} | ||
|
||
override fun settings(settings: ConiumBlockSettings) { | ||
settings.landPathThrough = this.landPathThrough | ||
settings.waterPathThrough = this.waterPathThrough | ||
settings.airPathThrough = this.airPathThrough | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.