generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
progress on Arcane Resonator, a redstone component detecting spell usage
Showing
30 changed files
with
355 additions
and
15 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
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
122 changes: 122 additions & 0 deletions
122
src/main/java/io/github/reoseah/magisterium/block/ArcaneResonatorBlock.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,122 @@ | ||
package io.github.reoseah.magisterium.block; | ||
|
||
import com.mojang.serialization.MapCodec; | ||
import io.github.reoseah.magisterium.block.entity.ArcaneResonatorBlockEntity; | ||
import net.minecraft.block.*; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.entity.ai.pathing.NavigationType; | ||
import net.minecraft.item.BlockItem; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.particle.DustParticleEffect; | ||
import net.minecraft.registry.RegistryKey; | ||
import net.minecraft.registry.RegistryKeys; | ||
import net.minecraft.state.StateManager; | ||
import net.minecraft.state.property.BooleanProperty; | ||
import net.minecraft.state.property.Properties; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.math.random.Random; | ||
import net.minecraft.util.shape.VoxelShape; | ||
import net.minecraft.world.BlockView; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.WorldView; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ArcaneResonatorBlock extends BlockWithEntity { | ||
public static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 2, 16); | ||
public static final BooleanProperty POWERED = Properties.POWERED; | ||
public static final MapCodec<ArcaneResonatorBlock> CODEC = createCodec(ArcaneResonatorBlock::new); | ||
|
||
public static final Block INSTANCE = new ArcaneResonatorBlock(Settings.create() // | ||
.breakInstantly() // | ||
.nonOpaque() // | ||
.luminance(state -> state.get(POWERED) ? 13 : 0) // | ||
.strength(0) // | ||
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of("magisterium", "arcane_resonator")))); | ||
public static final Item ITEM = new BlockItem(INSTANCE, new Item.Settings() // | ||
.registryKey(RegistryKey.of(RegistryKeys.ITEM, Identifier.of("magisterium", "arcane_resonator"))) // | ||
.useBlockPrefixedTranslationKey()); | ||
|
||
public ArcaneResonatorBlock(Settings settings) { | ||
super(settings); | ||
this.setDefaultState(this.stateManager.getDefaultState().with(POWERED, false)); | ||
} | ||
|
||
@Override | ||
protected MapCodec<? extends BlockWithEntity> getCodec() { | ||
return CODEC; | ||
} | ||
|
||
@Override | ||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) { | ||
builder.add(POWERED); | ||
} | ||
|
||
@Override | ||
protected boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { | ||
BlockPos blockPos = pos.down(); | ||
return this.canPlaceAbove(world, blockPos, world.getBlockState(blockPos)); | ||
} | ||
|
||
protected boolean canPlaceAbove(WorldView world, BlockPos pos, BlockState state) { | ||
return state.isSideSolid(world, pos, Direction.UP, SideShapeType.RIGID); | ||
} | ||
|
||
@Override | ||
protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { | ||
return SHAPE; | ||
} | ||
|
||
@Override | ||
protected boolean emitsRedstonePower(BlockState state) { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected BlockRenderType getRenderType(BlockState state) { | ||
return BlockRenderType.MODEL; | ||
} | ||
|
||
@Override | ||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { | ||
if (state.get(POWERED)) { | ||
double x = pos.getX() + 0.5 + (random.nextDouble() - 0.5); | ||
double y = pos.getY() + 0.4 + (random.nextDouble() - 0.5); | ||
double z = pos.getZ() + 0.5 + (random.nextDouble() - 0.5); | ||
|
||
world.addParticle(DustParticleEffect.DEFAULT, x, y, z, 0, 0, 0); | ||
} | ||
} | ||
|
||
@Override | ||
public @Nullable BlockEntity createBlockEntity(BlockPos pos, BlockState state) { | ||
return new ArcaneResonatorBlockEntity(pos, state); | ||
} | ||
|
||
private static void updateNeighbors(World world, BlockPos pos, BlockState state) { | ||
var block = state.getBlock(); | ||
world.updateNeighborsAlways(pos, block); | ||
world.updateNeighborsAlways(pos.down(), block); | ||
} | ||
|
||
@Override | ||
protected int getWeakRedstonePower(BlockState state, BlockView world, BlockPos pos, Direction direction) { | ||
return state.get(POWERED) ? 15 : 0; | ||
} | ||
|
||
@Override | ||
public int getStrongRedstonePower(BlockState state, BlockView world, BlockPos pos, Direction direction) { | ||
return direction == Direction.UP ? state.getWeakRedstonePower(world, pos, direction) : 0; | ||
} | ||
|
||
@Override | ||
protected boolean canPathfindThrough(BlockState state, NavigationType type) { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected boolean hasSidedTransparency(BlockState state) { | ||
return true; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/main/java/io/github/reoseah/magisterium/block/IllusoryWallBlock.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
16 changes: 16 additions & 0 deletions
16
src/main/java/io/github/reoseah/magisterium/block/entity/ArcaneResonatorBlockEntity.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,16 @@ | ||
package io.github.reoseah.magisterium.block.entity; | ||
|
||
import io.github.reoseah.magisterium.block.ArcaneResonatorBlock; | ||
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.block.entity.BlockEntityType; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
public class ArcaneResonatorBlockEntity extends BlockEntity { | ||
public static final BlockEntityType<ArcaneResonatorBlockEntity> TYPE = FabricBlockEntityTypeBuilder.create(ArcaneResonatorBlockEntity::new, ArcaneResonatorBlock.INSTANCE).build(); | ||
|
||
public ArcaneResonatorBlockEntity(BlockPos pos, BlockState state) { | ||
super(TYPE, pos, state); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
...terium/block/IllusoryWallBlockEntity.java → ...block/entity/IllusoryWallBlockEntity.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
41 changes: 41 additions & 0 deletions
41
src/main/java/io/github/reoseah/magisterium/client/render/ArcaneResonatorRenderer.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,41 @@ | ||
package io.github.reoseah.magisterium.client.render; | ||
|
||
import io.github.reoseah.magisterium.block.ArcaneResonatorBlock; | ||
import io.github.reoseah.magisterium.block.entity.ArcaneResonatorBlockEntity; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.render.OverlayTexture; | ||
import net.minecraft.client.render.RenderLayers; | ||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.block.BlockRenderManager; | ||
import net.minecraft.client.render.block.entity.BlockEntityRenderer; | ||
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.math.MathHelper; | ||
import net.minecraft.util.math.RotationAxis; | ||
import net.minecraft.util.math.random.Random; | ||
|
||
public class ArcaneResonatorRenderer implements BlockEntityRenderer<ArcaneResonatorBlockEntity> { | ||
public static final Identifier CRYSTAL = Identifier.of("magisterium:block/arcane_resonator_crystal"); | ||
public static final Identifier CRYSTAL_ON = Identifier.of("magisterium:block/arcane_resonator_crystal_on"); | ||
|
||
private final BlockRenderManager renderManager; | ||
|
||
public ArcaneResonatorRenderer(BlockEntityRendererFactory.Context ctx) { | ||
this.renderManager = ctx.getRenderManager(); | ||
} | ||
|
||
@Override | ||
public void render(ArcaneResonatorBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) { | ||
boolean powered = entity.getCachedState().get(ArcaneResonatorBlock.POWERED); | ||
var model = MinecraftClient.getInstance().getBakedModelManager().getModel(powered ? CRYSTAL_ON : CRYSTAL); | ||
var world = entity.getWorld(); | ||
var pos = entity.getPos(); | ||
matrices.push(); | ||
matrices.translate(.5F, MathHelper.sin((world.getTime() + tickDelta) / 20) * .1F, .5F); | ||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(world.getTime() + tickDelta)); | ||
matrices.translate(-.5F, 0, -.5F); | ||
this.renderManager.getModelRenderer().render(world, model, entity.getCachedState(), pos, matrices, vertexConsumers.getBuffer(RenderLayers.getMovingBlockLayer(entity.getCachedState())), false, Random.create(), 1, OverlayTexture.DEFAULT_UV); | ||
matrices.pop(); | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
src/main/resources/assets/magisterium/blockstates/arcane_resonator.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,10 @@ | ||
{ | ||
"variants": { | ||
"powered=false": { | ||
"model": "magisterium:block/arcane_resonator" | ||
}, | ||
"powered=true": { | ||
"model": "magisterium:block/arcane_resonator_on" | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/resources/assets/magisterium/blockstates/arcane_resonator_crystal.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,10 @@ | ||
{ | ||
"variants": { | ||
"powered=false": { | ||
"model": "magisterium:block/arcane_resonator_crystal" | ||
}, | ||
"powered=true": { | ||
"model": "magisterium:block/arcane_resonator_crystal_on" | ||
} | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/main/resources/assets/magisterium/models/block/arcane_resonator.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,22 @@ | ||
{ | ||
"ambientocclusion": false, | ||
"textures": { | ||
"particle": "magisterium:block/arcane_resonator", | ||
"slab": "block/smooth_stone", | ||
"top": "magisterium:block/arcane_resonator" | ||
}, | ||
"elements": [ | ||
{ | ||
"from": [ 0, 0, 0 ], | ||
"to": [ 16, 2, 16 ], | ||
"faces": { | ||
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#slab", "cullface": "down" }, | ||
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top" }, | ||
"north": { "uv": [ 0, 14, 16, 16 ], "texture": "#slab", "cullface": "north" }, | ||
"south": { "uv": [ 0, 14, 16, 16 ], "texture": "#slab", "cullface": "south" }, | ||
"west": { "uv": [ 0, 14, 16, 16 ], "texture": "#slab", "cullface": "west" }, | ||
"east": { "uv": [ 0, 14, 16, 16 ], "texture": "#slab", "cullface": "east" } | ||
} | ||
} | ||
] | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/resources/assets/magisterium/models/block/arcane_resonator_crystal.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,23 @@ | ||
{ | ||
"credit": "Made with Blockbench", | ||
"ambientocclusion": false, | ||
"texture_size": [32, 32], | ||
"textures": { | ||
"0": "magisterium:block/arcane_resonator_crystal", | ||
"particle": "magisterium:block/arcane_resonator_crystal" | ||
}, | ||
"elements": [ | ||
{ | ||
"from": [4, 5, 4], | ||
"to": [12, 13, 12], | ||
"faces": { | ||
"north": {"uv": [4, 4, 8, 8], "texture": "#0"}, | ||
"east": {"uv": [8, 4, 12, 8], "texture": "#0"}, | ||
"south": {"uv": [12, 4, 16, 8], "texture": "#0"}, | ||
"west": {"uv": [0, 4, 4, 8], "texture": "#0"}, | ||
"up": {"uv": [4, 0, 8, 4], "texture": "#0"}, | ||
"down": {"uv": [8, 0, 12, 4], "texture": "#0"} | ||
} | ||
} | ||
] | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/resources/assets/magisterium/models/block/arcane_resonator_crystal_on.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,23 @@ | ||
{ | ||
"credit": "Made with Blockbench", | ||
"ambientocclusion": false, | ||
"texture_size": [32, 32], | ||
"textures": { | ||
"0": "magisterium:block/arcane_resonator_crystal", | ||
"particle": "magisterium:block/arcane_resonator_crystal" | ||
}, | ||
"elements": [ | ||
{ | ||
"from": [4, 5, 4], | ||
"to": [12, 13, 12], | ||
"faces": { | ||
"north": {"uv": [4, 12, 8, 16], "texture": "#0"}, | ||
"east": {"uv": [8, 12, 12, 16], "texture": "#0"}, | ||
"south": {"uv": [12, 12, 16, 16], "texture": "#0"}, | ||
"west": {"uv": [0, 12, 4, 16], "texture": "#0"}, | ||
"up": {"uv": [4, 8, 8, 12], "texture": "#0"}, | ||
"down": {"uv": [8, 8, 12, 12], "texture": "#0"} | ||
} | ||
} | ||
] | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/resources/assets/magisterium/models/block/arcane_resonator_on.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,22 @@ | ||
{ | ||
"ambientocclusion": false, | ||
"textures": { | ||
"particle": "magisterium:block/arcane_resonator_on", | ||
"slab": "block/smooth_stone", | ||
"top": "magisterium:block/arcane_resonator_on" | ||
}, | ||
"elements": [ | ||
{ | ||
"from": [ 0, 0, 0 ], | ||
"to": [ 16, 2, 16 ], | ||
"faces": { | ||
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#slab", "cullface": "down" }, | ||
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top" }, | ||
"north": { "uv": [ 0, 14, 16, 16 ], "texture": "#slab", "cullface": "north" }, | ||
"south": { "uv": [ 0, 14, 16, 16 ], "texture": "#slab", "cullface": "south" }, | ||
"west": { "uv": [ 0, 14, 16, 16 ], "texture": "#slab", "cullface": "west" }, | ||
"east": { "uv": [ 0, 14, 16, 16 ], "texture": "#slab", "cullface": "east" } | ||
} | ||
} | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/magisterium/models/item/arcane_resonator.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": "magisterium:item/arcane_resonator" | ||
} | ||
} |
Binary file added
BIN
+581 Bytes
src/main/resources/assets/magisterium/textures/block/arcane_resonator.png
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
+816 Bytes
src/main/resources/assets/magisterium/textures/block/arcane_resonator_crystal.png
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
+585 Bytes
src/main/resources/assets/magisterium/textures/block/arcane_resonator_on.png
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
+437 Bytes
src/main/resources/assets/magisterium/textures/item/arcane_resonator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-10 Bytes
(98%)
src/main/resources/assets/magisterium/textures/item/blaze_rune.png
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
+225 Bytes
src/main/resources/assets/magisterium/textures/item/placeholder/fire.png
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
+239 Bytes
src/main/resources/assets/magisterium/textures/item/placeholder/wind.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-6 Bytes
(99%)
src/main/resources/assets/magisterium/textures/item/wind_rune.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
src/main/resources/data/magisterium/loot_table/blocks/arcane_resonator.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,21 @@ | ||
{ | ||
"type": "minecraft:block", | ||
"pools": [ | ||
{ | ||
"bonus_rolls": 0.0, | ||
"conditions": [ | ||
{ | ||
"condition": "minecraft:survives_explosion" | ||
} | ||
], | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"name": "magisterium:arcane_resonator" | ||
} | ||
], | ||
"rolls": 1.0 | ||
} | ||
], | ||
"random_sequence": "magisterium:blocks/arcane_resonator" | ||
} |
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
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.