Skip to content

Commit

Permalink
Media jar
Browse files Browse the repository at this point in the history
  • Loading branch information
miyucomics committed Jul 5, 2024
1 parent e24aa54 commit 795c20c
Show file tree
Hide file tree
Showing 26 changed files with 133 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/main/java/miyucomics/hexical/blocks/HexCandleBlock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import net.minecraft.world.World
import net.minecraft.world.event.GameEvent

class HexCandleBlock : CandleBlock(Settings.of(Material.DECORATION).nonOpaque().strength(0.1f).sounds(BlockSoundGroup.CANDLE).luminance(STATE_TO_LUMINANCE)), BlockEntityProvider {
@Deprecated("Deprecated in Java")
override fun onUse(state: BlockState, world: World, pos: BlockPos, player: PlayerEntity, hand: Hand, hit: BlockHitResult?): ActionResult {
if (player.isSneaking)
return super.onUse(state, world, pos, player, hand, hit)
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/miyucomics/hexical/blocks/MediaJarBlock.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package miyucomics.hexical.blocks

import net.minecraft.block.*
import net.minecraft.sound.BlockSoundGroup
import net.minecraft.util.math.BlockPos
import net.minecraft.util.shape.VoxelShape
import net.minecraft.util.shape.VoxelShapes
import net.minecraft.world.BlockView

class MediaJarBlock : TransparentBlock(Settings.of(Material.GLASS).emissiveLighting { _, _, _ -> true }.luminance { _ -> 15 }.sounds(BlockSoundGroup.GLASS).nonOpaque()) {
override fun getRenderType(state: BlockState?) = BlockRenderType.MODEL
override fun isTranslucent(state: BlockState?, world: BlockView?, pos: BlockPos?) = true
override fun getAmbientOcclusionLightLevel(state: BlockState?, world: BlockView?, pos: BlockPos?) = 1f
override fun getCameraCollisionShape(state: BlockState?, world: BlockView?, pos: BlockPos?, context: ShapeContext?): VoxelShape = VoxelShapes.empty()
override fun getOutlineShape(state: BlockState?, view: BlockView?, pos: BlockPos?, context: ShapeContext?): VoxelShape = VoxelShapes.cuboid(4.0 / 16, 0.0, 4.0 / 16, 12.0 / 16, 10.0 / 16, 12.0 / 16)
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class LivingScrollEntity(entityType: EntityType<LivingScrollEntity?>?, world: Wo
val constructed = mutableListOf<PatternIota>()
for (pattern in this.patterns)
constructed.add(PatternIota(HexPattern.fromNBT(pattern)))
stack.orCreateNbt.putBoolean("aged", this.dataTracker.get(agedDataTracker))
stack.orCreateNbt.putCompound("patterns", HexIotaTypes.serialize(ListIota(constructed.toList())))
this.dropStack(stack)
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/miyucomics/hexical/items/LivingScrollItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class LivingScrollItem(private val size: Int) : Item(Settings().group(HexicalIte
}

val scroll = LivingScrollEntity(world, position, direction, size, patternList)
if (stack.orCreateNbt.getBoolean("aged"))
scroll.toggleAged()

if (scroll.canStayAttached()) {
scroll.onPlace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ private void copyIota(BlockState state, World world, BlockPos pos, PlayerEntity
return;
if (player.isSneaking() || hand == Hand.OFF_HAND)
return;
if (!player.getMainHandStack().isEmpty())
return;
BlockEntity shelf = world.getBlockEntity(pos);
if (shelf instanceof BlockEntityAkashicBookshelf) {
NbtCompound nbt = ((BlockEntityAkashicBookshelf) shelf).getIotaTag();
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/miyucomics/hexical/registry/HexicalBlocks.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package miyucomics.hexical.registry

import miyucomics.hexical.HexicalMain
import miyucomics.hexical.blocks.HexCandleBlock
import miyucomics.hexical.blocks.HexCandleBlockEntity
import miyucomics.hexical.blocks.MageBlock
import miyucomics.hexical.blocks.MageBlockEntity
import miyucomics.hexical.blocks.*
import net.minecraft.block.entity.BlockEntityType
import net.minecraft.util.registry.Registry

Expand All @@ -13,12 +10,14 @@ object HexicalBlocks {
val HEX_CANDLE_BLOCK_ENTITY: BlockEntityType<HexCandleBlockEntity> = BlockEntityType.Builder.create(::HexCandleBlockEntity, HEX_CANDLE_BLOCK).build(null)
val MAGE_BLOCK: MageBlock = MageBlock()
val MAGE_BLOCK_ENTITY: BlockEntityType<MageBlockEntity> = BlockEntityType.Builder.create(::MageBlockEntity, MAGE_BLOCK).build(null)
val MEDIA_JAR_BLOCK: MediaJarBlock = MediaJarBlock()

@JvmStatic
fun init() {
Registry.register(Registry.BLOCK, HexicalMain.id("hex_candle"), HEX_CANDLE_BLOCK)
Registry.register(Registry.BLOCK_ENTITY_TYPE, HexicalMain.id("hex_candle"), HEX_CANDLE_BLOCK_ENTITY)
Registry.register(Registry.BLOCK, HexicalMain.id("mage_block"), MAGE_BLOCK)
Registry.register(Registry.BLOCK_ENTITY_TYPE, HexicalMain.id("mage_block"), MAGE_BLOCK_ENTITY)
Registry.register(Registry.BLOCK, HexicalMain.id("media_jar"), MEDIA_JAR_BLOCK)
}
}
4 changes: 4 additions & 0 deletions src/main/java/miyucomics/hexical/registry/HexicalItems.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ object HexicalItems {
Registry.register(Registry.ITEM, HexicalMain.id("hextito"), HEXTITO_ITEM)
Registry.register(Registry.ITEM, HexicalMain.id("null_media"), NULL_MEDIA_ITEM)
Registry.register(Registry.ITEM, HexicalMain.id("mage_block"), BlockItem(HexicalBlocks.MAGE_BLOCK, Settings()))
Registry.register(Registry.ITEM, HexicalMain.id("media_jar"), BlockItem(HexicalBlocks.MEDIA_JAR_BLOCK, Settings().group(HEXICAL_GROUP)))
Registry.register(Registry.ITEM, HexicalMain.id("hex_candle"), BlockItem(HexicalBlocks.HEX_CANDLE_BLOCK, Settings().group(HEXICAL_GROUP)))
}

@JvmStatic
fun clientInit() {
ModelPredicateProviderRegistry.register(SMALL_LIVING_SCROLL_ITEM, Identifier("aged")) { stack: ItemStack, _: ClientWorld?, _: LivingEntity?, _: Int -> if (stack.orCreateNbt.getBoolean("aged")) 1f else 0f }
ModelPredicateProviderRegistry.register(MEDIUM_LIVING_SCROLL_ITEM, Identifier("aged")) { stack: ItemStack, _: ClientWorld?, _: LivingEntity?, _: Int -> if (stack.orCreateNbt.getBoolean("aged")) 1f else 0f }
ModelPredicateProviderRegistry.register(LARGE_LIVING_SCROLL_ITEM, Identifier("aged")) { stack: ItemStack, _: ClientWorld?, _: LivingEntity?, _: Int -> if (stack.orCreateNbt.getBoolean("aged")) 1f else 0f }
ModelPredicateProviderRegistry.register(CONJURED_STAFF_ITEM, Identifier("sprite")) { stack: ItemStack, _: ClientWorld?, _: LivingEntity?, _: Int -> stack.orCreateNbt.getFloat("sprite") }
ModelPredicateProviderRegistry.register(CONJURED_COMPASS_ITEM, Identifier("angle"), CompassAnglePredicateProvider(CompassTarget { _: ClientWorld?, stack: ItemStack?, player: Entity? ->
if (player != null && stack != null && stack.hasNbt()) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/assets/hexical/blockstates/media_jar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "hexical:block/media_jar"
}
}
}
46 changes: 46 additions & 0 deletions src/main/resources/assets/hexical/models/block/media_jar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"textures": {
"0": "hexical:block/media_jar",
"particle": "hexical:block/media_jar"
},
"elements": [
{
"from": [4, 0, 4],
"to": [12, 10, 12],
"faces": {
"north": {"uv": [8, 0, 0, 10], "texture": "#0"},
"east": {"uv": [0, 0, 8, 10], "texture": "#0"},
"south": {"uv": [8, 0, 0, 10], "texture": "#0"},
"west": {"uv": [0, 0, 8, 10], "texture": "#0"},
"up": {"uv": [16, 8, 8, 0], "texture": "#0"},
"down": {"uv": [16, 0, 8, 8], "texture": "#0"}
}
},
{
"from": [5, 10, 5],
"to": [11, 11, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 1, 0]},
"faces": {
"north": {"uv": [0, 10, 6, 11], "texture": "#0"},
"east": {"uv": [0, 10, 6, 11], "texture": "#0"},
"south": {"uv": [0, 10, 6, 11], "texture": "#0"},
"west": {"uv": [0, 10, 6, 11], "texture": "#0"},
"up": {"uv": [0, 10, 6, 16], "texture": "#0"},
"down": {"uv": [0, 10, 6, 16], "texture": "#0"}
}
},
{
"from": [4.5, 0.5, 4.5],
"to": [11.5, 7.5, 11.5],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 0.5, 5]},
"faces": {
"north": {"uv": [8, 8, 15, 15], "rotation": 90, "texture": "#0"},
"east": {"uv": [8, 8, 15, 15], "rotation": 180, "texture": "#0"},
"south": {"uv": [8, 8, 15, 15], "rotation": 90, "texture": "#0"},
"west": {"uv": [8, 8, 15, 15], "rotation": 270, "texture": "#0"},
"up": {"uv": [8, 8, 15, 15], "rotation": 180, "texture": "#0"},
"down": {"uv": [8, 8, 15, 15], "rotation": 90, "texture": "#0"}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexical:item/living_scroll_large"
}
}
},
"overrides": [
{
"predicate": {
"aged": 1
},
"model": "hexical:item/living_scroll_large_aged"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexical:item/living_scroll_large_aged"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexical:item/living_scroll_medium"
}
}
},
"overrides": [
{
"predicate": {
"aged": 1
},
"model": "hexical:item/living_scroll_medium_aged"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexical:item/living_scroll_medium_aged"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexical:item/living_scroll_small"
}
}
},
"overrides": [
{
"predicate": {
"aged": 1
},
"model": "hexical:item/living_scroll_small_aged"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexical:item/living_scroll_small_aged"
}
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/hexical/models/item/media_jar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "hexical:block/media_jar"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit 795c20c

Please sign in to comment.