-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c291dd4
commit 6b294e7
Showing
27 changed files
with
340 additions
and
5 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,75 @@ | ||
package miyucomics.hexical.blocks | ||
|
||
import at.petrak.hexcasting.api.misc.FrozenColorizer | ||
import at.petrak.hexcasting.common.particles.ConjureParticleOptions | ||
import at.petrak.hexcasting.xplat.IXplatAbstractions | ||
import net.minecraft.block.* | ||
import net.minecraft.block.entity.BlockEntity | ||
import net.minecraft.block.entity.BlockEntityTicker | ||
import net.minecraft.block.entity.BlockEntityType | ||
import net.minecraft.entity.player.PlayerEntity | ||
import net.minecraft.sound.BlockSoundGroup | ||
import net.minecraft.sound.SoundCategory | ||
import net.minecraft.sound.SoundEvents | ||
import net.minecraft.util.ActionResult | ||
import net.minecraft.util.Hand | ||
import net.minecraft.util.hit.BlockHitResult | ||
import net.minecraft.util.math.BlockPos | ||
import net.minecraft.util.math.Vec3d | ||
import net.minecraft.util.math.random.Random | ||
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 { | ||
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) | ||
if (!state.get(AbstractCandleBlock.LIT)) | ||
return super.onUse(state, world, pos, player, hand, hit) | ||
val stack = player.getStackInHand(hand) | ||
val be = world.getBlockEntity(pos)!! as HexCandleBlockEntity | ||
var givenColor = IXplatAbstractions.INSTANCE.getColorizer(player) | ||
if (IXplatAbstractions.INSTANCE.isColorizer(stack)) | ||
givenColor = FrozenColorizer(stack.copy(), player.uuid) | ||
be.setPigment(givenColor) | ||
world.emitGameEvent(player, GameEvent.BLOCK_CHANGE, pos) | ||
return ActionResult.SUCCESS | ||
} | ||
|
||
override fun randomDisplayTick(state: BlockState, world: World, pos: BlockPos, random: Random) { | ||
if (!state.get(AbstractCandleBlock.LIT)) | ||
return | ||
getParticleOffsets(state).forEach { offset: Vec3d -> | ||
val position = offset.add(pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble()) | ||
if (random.nextFloat() < 0.25f) | ||
world.playSound(position.x + 0.5, position.y + 0.5, position.z + 0.5, SoundEvents.BLOCK_CANDLE_AMBIENT, SoundCategory.BLOCKS, 1.0f + random.nextFloat(), random.nextFloat() * 0.7f + 0.3f, false) | ||
} | ||
} | ||
|
||
fun getPositions(state: BlockState): Iterable<Vec3d> { | ||
return getParticleOffsets(state) | ||
} | ||
|
||
override fun createBlockEntity(pos: BlockPos?, state: BlockState?): BlockEntity = HexCandleBlockEntity(pos, state) | ||
override fun <T : BlockEntity> getTicker(world: World, state: BlockState, type: BlockEntityType<T>): BlockEntityTicker<T> = BlockEntityTicker { world1, pos, state1, blockEntity -> tick(world1, pos, state1, blockEntity as HexCandleBlockEntity) } | ||
|
||
companion object { | ||
fun tick(world: World, pos: BlockPos, state: BlockState, blockEntity: HexCandleBlockEntity) { | ||
if (!world.isClient) | ||
return | ||
if (!state.get(AbstractCandleBlock.LIT)) | ||
return | ||
val pigment = blockEntity.getPigment() | ||
(state.block as HexCandleBlock).getPositions(state).forEach { offset: Vec3d -> | ||
if (world.random.nextFloat() > 0.5) | ||
return@forEach | ||
val position = offset.add(pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble()) | ||
world.addParticle( | ||
ConjureParticleOptions(pigment.getColor(world.time.toFloat(), position), true), | ||
position.x, position.y, position.z, | ||
0.0, world.random.nextFloat() * 0.02, 0.0 | ||
) | ||
} | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/miyucomics/hexical/blocks/HexCandleBlockEntity.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,30 @@ | ||
package miyucomics.hexical.blocks | ||
|
||
import at.petrak.hexcasting.api.misc.FrozenColorizer | ||
import miyucomics.hexical.registry.HexicalBlocks | ||
import net.minecraft.block.BlockState | ||
import net.minecraft.block.entity.BlockEntity | ||
import net.minecraft.nbt.NbtCompound | ||
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket | ||
import net.minecraft.util.math.BlockPos | ||
|
||
class HexCandleBlockEntity(pos: BlockPos?, state: BlockState?) : BlockEntity(HexicalBlocks.HEX_CANDLE_BLOCK_ENTITY, pos, state) { | ||
private var pigment: FrozenColorizer = FrozenColorizer.DEFAULT.get() | ||
|
||
fun getPigment() = this.pigment | ||
fun setPigment(pigment: FrozenColorizer) { | ||
this.pigment = pigment | ||
markDirty() | ||
} | ||
|
||
override fun writeNbt(nbt: NbtCompound) { | ||
nbt.put("pigment", pigment.serializeToNBT()) | ||
} | ||
|
||
override fun readNbt(nbt: NbtCompound) { | ||
pigment = FrozenColorizer.fromNBT(nbt.getCompound("pigment")) | ||
} | ||
|
||
override fun toUpdatePacket(): BlockEntityUpdateS2CPacket = BlockEntityUpdateS2CPacket.create(this) | ||
override fun toInitialChunkDataNbt(): NbtCompound = createNbt() | ||
} |
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
48 changes: 48 additions & 0 deletions
48
src/main/java/miyucomics/hexical/mixin/BlockAkashicBookshelfMixin.java
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,48 @@ | ||
package miyucomics.hexical.mixin; | ||
|
||
import at.petrak.hexcasting.api.spell.casting.CastingHarness; | ||
import at.petrak.hexcasting.api.spell.iota.Iota; | ||
import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicBookshelf; | ||
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicBookshelf; | ||
import at.petrak.hexcasting.common.lib.HexSounds; | ||
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes; | ||
import at.petrak.hexcasting.xplat.IXplatAbstractions; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.sound.SoundCategory; | ||
import net.minecraft.sound.SoundEvents; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.hit.BlockHitResult; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(BlockAkashicBookshelf.class) | ||
public class BlockAkashicBookshelfMixin { | ||
@Inject(method = "onUse", at = @At(value = "TAIL")) | ||
private void copyIota(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) { | ||
if (world.isClient) | ||
return; | ||
if (player.isSneaking() || hand == Hand.OFF_HAND) | ||
return; | ||
BlockEntity shelf = world.getBlockEntity(pos); | ||
if (shelf instanceof BlockEntityAkashicBookshelf) { | ||
NbtCompound nbt = ((BlockEntityAkashicBookshelf) shelf).getIotaTag(); | ||
if (nbt == null) | ||
return; | ||
CastingHarness harness = IXplatAbstractions.INSTANCE.getHarness((ServerPlayerEntity) player, hand); | ||
harness.getStack().add(HexIotaTypes.deserialize(nbt, (ServerWorld) world)); | ||
IXplatAbstractions.INSTANCE.setHarness((ServerPlayerEntity) player, harness); | ||
world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, 1f, 1f); | ||
player.swingHand(hand, 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
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
28 changes: 28 additions & 0 deletions
28
src/main/resources/assets/hexical/blockstates/hex_candle.json
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,28 @@ | ||
{ | ||
"variants": { | ||
"candles=1,lit=false": { | ||
"model": "hexical:block/hex_candle_one_candle" | ||
}, | ||
"candles=1,lit=true": { | ||
"model": "hexical:block/hex_candle_one_candle_lit" | ||
}, | ||
"candles=2,lit=false": { | ||
"model": "hexical:block/hex_candle_two_candles" | ||
}, | ||
"candles=2,lit=true": { | ||
"model": "hexical:block/hex_candle_two_candles_lit" | ||
}, | ||
"candles=3,lit=false": { | ||
"model": "hexical:block/hex_candle_three_candles" | ||
}, | ||
"candles=3,lit=true": { | ||
"model": "hexical:block/hex_candle_three_candles_lit" | ||
}, | ||
"candles=4,lit=false": { | ||
"model": "hexical:block/hex_candle_four_candles" | ||
}, | ||
"candles=4,lit=true": { | ||
"model": "hexical:block/hex_candle_four_candles_lit" | ||
} | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/hexical/models/block/hex_candle_four_candles.json
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,7 @@ | ||
{ | ||
"parent": "minecraft:block/template_four_candles", | ||
"textures": { | ||
"all": "hexical:block/hex_candle", | ||
"particle": "hexical:block/hex_candle" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/hexical/models/block/hex_candle_four_candles_lit.json
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,7 @@ | ||
{ | ||
"parent": "minecraft:block/template_four_candles", | ||
"textures": { | ||
"all": "hexical:block/hex_candle_lit", | ||
"particle": "hexical:block/hex_candle_lit" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/hexical/models/block/hex_candle_one_candle.json
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,7 @@ | ||
{ | ||
"parent": "minecraft:block/template_candle", | ||
"textures": { | ||
"all": "hexical:block/hex_candle", | ||
"particle": "hexical:block/hex_candle" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/hexical/models/block/hex_candle_one_candle_lit.json
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,7 @@ | ||
{ | ||
"parent": "minecraft:block/template_candle", | ||
"textures": { | ||
"all": "hexical:block/hex_candle_lit", | ||
"particle": "hexical:block/hex_candle_lit" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/hexical/models/block/hex_candle_three_candles.json
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,7 @@ | ||
{ | ||
"parent": "minecraft:block/template_three_candles", | ||
"textures": { | ||
"all": "hexical:block/hex_candle", | ||
"particle": "hexical:block/hex_candle" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/hexical/models/block/hex_candle_three_candles_lit.json
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,7 @@ | ||
{ | ||
"parent": "minecraft:block/template_three_candles", | ||
"textures": { | ||
"all": "hexical:block/hex_candle_lit", | ||
"particle": "hexical:block/hex_candle_lit" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/hexical/models/block/hex_candle_two_candles.json
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,7 @@ | ||
{ | ||
"parent": "minecraft:block/template_two_candles", | ||
"textures": { | ||
"all": "hexical:block/hex_candle", | ||
"particle": "hexical:block/hex_candle" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/hexical/models/block/hex_candle_two_candles_lit.json
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,7 @@ | ||
{ | ||
"parent": "minecraft:block/template_two_candles", | ||
"textures": { | ||
"all": "hexical:block/hex_candle_lit", | ||
"particle": "hexical:block/hex_candle_lit" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/hexical/models/item/hex_candle.json
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,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "hexical:item/hex_candle" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+166 Bytes
src/main/resources/assets/hexical/textures/block/hex_candle_lit.png
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.
62 changes: 62 additions & 0 deletions
62
src/main/resources/data/hexical/loot_tables/blocks/hex_candle.json
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,62 @@ | ||
{ | ||
"type": "minecraft:block", | ||
"pools": [ | ||
{ | ||
"bonus_rolls": 0.0, | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"functions": [ | ||
{ | ||
"add": false, | ||
"conditions": [ | ||
{ | ||
"block": "hexical:hex_candle", | ||
"condition": "minecraft:block_state_property", | ||
"properties": { | ||
"candles": "2" | ||
} | ||
} | ||
], | ||
"count": 2.0, | ||
"function": "minecraft:set_count" | ||
}, | ||
{ | ||
"add": false, | ||
"conditions": [ | ||
{ | ||
"block": "hexical:hex_candle", | ||
"condition": "minecraft:block_state_property", | ||
"properties": { | ||
"candles": "3" | ||
} | ||
} | ||
], | ||
"count": 3.0, | ||
"function": "minecraft:set_count" | ||
}, | ||
{ | ||
"add": false, | ||
"conditions": [ | ||
{ | ||
"block": "hexical:hex_candle", | ||
"condition": "minecraft:block_state_property", | ||
"properties": { | ||
"candles": "4" | ||
} | ||
} | ||
], | ||
"count": 4.0, | ||
"function": "minecraft:set_count" | ||
}, | ||
{ | ||
"function": "minecraft:explosion_decay" | ||
} | ||
], | ||
"name": "hexical:hex_candle" | ||
} | ||
], | ||
"rolls": 1.0 | ||
} | ||
] | ||
} |
Oops, something went wrong.