Skip to content

Commit 68e5962

Browse files
committed
Blocklayer head, now 75% more useful
1 parent 6ebe0e3 commit 68e5962

File tree

5 files changed

+58
-12
lines changed

5 files changed

+58
-12
lines changed

src/main/java/net/automotons/client/BlocklayerHeadRenderer.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@ public class BlocklayerHeadRenderer implements HeadRenderer<Object>{
1717
public void render(AutomotonBlockEntity entity, MatrixStack matrices, VertexConsumerProvider vertexConsumers, Object o, int light, int overlay, float tickDelta){
1818
float rotationOffset = 0;
1919
matrices.push();
20-
if(entity.lastFacing != null && entity.lastFacing != entity.facing){
21-
// FIXME: state rotation
20+
if(entity.lastFacing != null && entity.lastFacing != entity.facing)
2221
if(Automotons.isClockwiseRotation(entity.lastFacing, entity.facing))
2322
rotationOffset = min((entity.moduleTime + tickDelta) / (float)entity.moduleSpeed(), 1) - 1;
2423
else
2524
rotationOffset = 1 - min((entity.moduleTime + tickDelta) / (float)entity.moduleSpeed(), 1);
26-
}
27-
// only display if rotating
2825
// point of rotation
2926
matrices.translate(.5, 0, .5);
3027
matrices.multiply(Vector3f.NEGATIVE_Y.getDegreesQuaternion(90 * (entity.facing.getHorizontal() + rotationOffset + 1)));
@@ -33,8 +30,8 @@ public void render(AutomotonBlockEntity entity, MatrixStack matrices, VertexCons
3330
VertexConsumer outline = vertexConsumers.getBuffer(RenderLayer.getLines());
3431
Matrix4f matrix4f = matrices.peek().getModel();
3532
VoxelShapes.fullCube().forEachEdge((minX, minY, minZ, maxX, maxY, maxZ) -> {
36-
outline.vertex(matrix4f, (float)(minX), (float)(minY), (float)(minZ)).color(0, 0, 0, 0.4f).next();
37-
outline.vertex(matrix4f, (float)(maxX), (float)(maxY), (float)(maxZ)).color(0, 0, 0, 0.4f).next();
33+
outline.vertex(matrix4f, (float)(minX), (float)(minY), (float)(minZ)).color(.4f, 0, .4f, 0.5f).next();
34+
outline.vertex(matrix4f, (float)(maxX), (float)(maxY), (float)(maxZ)).color(.4f, 0, .4f, 0.5f).next();
3835
});
3936
matrices.pop();
4037
}

src/main/java/net/automotons/items/heads/BlocklayerHeadItem.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
import net.automotons.blocks.AutomotonBlockEntity;
44
import net.automotons.items.HeadItem;
5+
import net.minecraft.block.Block;
56
import net.minecraft.block.BlockState;
67
import net.minecraft.block.piston.PistonBehavior;
78
import net.minecraft.item.BlockItem;
89
import net.minecraft.item.Item;
10+
import net.minecraft.sound.BlockSoundGroup;
11+
import net.minecraft.sound.SoundCategory;
912
import net.minecraft.util.math.BlockPos;
1013
import net.minecraft.world.World;
1114

@@ -18,13 +21,19 @@ public BlocklayerHeadItem(Settings settings){
1821
public void tick(AutomotonBlockEntity automoton, BlockPos facing, Object o){
1922
World world = automoton.getWorld();
2023
BlockState state = world.getBlockState(facing);
21-
if(state.isAir() || state.getPistonBehavior() == PistonBehavior.DESTROY){
24+
if(automoton.engaged && automoton.moduleTime == automoton.moduleSpeed() - 1 && (state.isAir() || state.getPistonBehavior() == PistonBehavior.DESTROY)){
2225
Item item = automoton.getStoreStack().getItem();
2326
if(item instanceof BlockItem){
24-
world.breakBlock(facing, true);
25-
// Won't work for beds, doors, etc
26-
world.setBlockState(facing, ((BlockItem)item).getBlock().getDefaultState());
27-
automoton.getStoreStack().decrement(1);
27+
Block block = ((BlockItem)item).getBlock();
28+
if(block.canPlaceAt(block.getDefaultState(), world, facing)){
29+
// Don't break block - block replacement doesn't do so
30+
// Won't work for beds, doors, etc
31+
world.setBlockState(facing, block.getDefaultState());
32+
automoton.getStoreStack().decrement(1);
33+
// Make some kind of effect
34+
BlockSoundGroup group = block.getSoundGroup(block.getDefaultState());
35+
world.playSound(facing.getX(), facing.getY(), facing.getZ(), group.getPlaceSound(), SoundCategory.BLOCKS, (group.getVolume() + 1) / 2, group.getPitch() * .8f, false);
36+
}
2837
}
2938
}
3039
}

src/main/resources/assets/automotons/lang/en_us.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"item.automotons.note_block_on_a_stick": "Note Block on a Stick",
1313
"item.automotons.steel_hammer": "Steel Hammer",
1414
"item.automotons.broadcast_antennae": "Broadcast Antennae",
15-
"item.automotons.blocklayer_head": "Blocklayer",
15+
"item.automotons.blocklayer_head": "Blocklayer Head",
1616

1717
"item.automotons.blank_module": "Empty Module",
1818
"item.automotons.iron_gear": "Iron Gear",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "Blocklayer Head",
3+
"icon": "automotons:blocklayer_head",
4+
"category": "automotons:heads",
5+
"pages": [
6+
{
7+
"type": "text",
8+
"text": "An engaged automoton holding a Blocklayer Head will place blocks in front of it, consuming held blocks. It can place blocks into empty space or a replaceable block (e.g. tall grass), but will not replace preexisting solid blocks, and can only place blocks where they would be valid to place."
9+
},
10+
{
11+
"type": "crafting",
12+
"recipe": "automotons:blocklayer_head"
13+
}
14+
]
15+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"type": "minecraft:crafting_shaped",
3+
"pattern": [
4+
"PdP",
5+
" g ",
6+
" i "
7+
],
8+
"key": {
9+
"i": {
10+
"item": "minecraft:gold_ingot"
11+
},
12+
"g": {
13+
"item": "automotons:iron_gear"
14+
},
15+
"d": {
16+
"item": "minecraft:dispenser"
17+
},
18+
"P": {
19+
"item": "minecraft:piston"
20+
}
21+
},
22+
"result": {
23+
"item": "automotons:blocklayer_head"
24+
}
25+
}

0 commit comments

Comments
 (0)