compass direction drills

This commit is contained in:
Jörg Henke 2021-01-30 18:58:01 +01:00
parent 82e46f6129
commit 44d1e86f13
31 changed files with 640 additions and 0 deletions

View File

@ -0,0 +1,54 @@
package de.jottyfan.minecraft.quickiefabric.blockentity;
import de.jottyfan.minecraft.quickiefabric.blocks.QuickieBlocks;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class DrillBlockDownEntity extends BlockEntity implements Tickable {
private static final Integer MAXDRILLSTEP = 20;
private Integer drillstep;
public DrillBlockDownEntity() {
super(QuickieFabricBlockEntity.DRILL_DOWN);
}
protected static final void moveBlockWithEntity(BlockPos from, BlockPos to, World world) {
BlockEntity be = world.getBlockEntity(from);
BlockState bs = world.getBlockState(from);
if (be != null) {
world.setBlockState(from, Blocks.AIR.getDefaultState());
world.setBlockState(to, bs);
world.removeBlockEntity(from);
world.setBlockEntity(to, be);
}
}
protected static final void drill(BlockPos pos, BlockPos to, World world) {
if (!world.getBlockState(to).isOf(Blocks.BEDROCK) && !world.getBlockState(to).isOf(QuickieBlocks.DRILLSTOP)) {
world.breakBlock(to, true);
if (pos.down() != to) { // no need for the falling one
moveBlockWithEntity(pos, to, world);
}
}
}
@Override
public void tick() {
drillstep = drillstep == null ? MAXDRILLSTEP : drillstep - 1;
if (drillstep < 1) {
drillstep = MAXDRILLSTEP;
drill(getPos(), getPos().down(), getWorld());
}
}
}

View File

@ -0,0 +1,28 @@
package de.jottyfan.minecraft.quickiefabric.blockentity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Tickable;
/**
*
* @author jotty
*
*/
public class DrillBlockEastEntity extends BlockEntity implements Tickable {
private static final Integer MAXDRILLSTEP = 24;
private Integer drillstep;
public DrillBlockEastEntity() {
super(QuickieFabricBlockEntity.DRILL_EAST);
}
@Override
public void tick() {
drillstep = drillstep == null ? MAXDRILLSTEP : drillstep - 1;
if (drillstep < 1) {
drillstep = MAXDRILLSTEP;
DrillBlockDownEntity.drill(getPos(), getPos().east().down(), getWorld());
}
}
}

View File

@ -0,0 +1,28 @@
package de.jottyfan.minecraft.quickiefabric.blockentity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Tickable;
/**
*
* @author jotty
*
*/
public class DrillBlockNorthEntity extends BlockEntity implements Tickable {
private static final Integer MAXDRILLSTEP = 24;
private Integer drillstep;
public DrillBlockNorthEntity() {
super(QuickieFabricBlockEntity.DRILL_NORTH);
}
@Override
public void tick() {
drillstep = drillstep == null ? MAXDRILLSTEP : drillstep - 1;
if (drillstep < 1) {
drillstep = MAXDRILLSTEP;
DrillBlockDownEntity.drill(getPos(), getPos().north().down(), getWorld());
}
}
}

View File

@ -0,0 +1,28 @@
package de.jottyfan.minecraft.quickiefabric.blockentity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Tickable;
/**
*
* @author jotty
*
*/
public class DrillBlockSouthEntity extends BlockEntity implements Tickable {
private static final Integer MAXDRILLSTEP = 24;
private Integer drillstep;
public DrillBlockSouthEntity() {
super(QuickieFabricBlockEntity.DRILL_SOUTH);
}
@Override
public void tick() {
drillstep = drillstep == null ? MAXDRILLSTEP : drillstep - 1;
if (drillstep < 1) {
drillstep = MAXDRILLSTEP;
DrillBlockDownEntity.drill(getPos(), getPos().south().down(), getWorld());
}
}
}

View File

@ -0,0 +1,28 @@
package de.jottyfan.minecraft.quickiefabric.blockentity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Tickable;
/**
*
* @author jotty
*
*/
public class DrillBlockWestEntity extends BlockEntity implements Tickable {
private static final Integer MAXDRILLSTEP = 24;
private Integer drillstep;
public DrillBlockWestEntity() {
super(QuickieFabricBlockEntity.DRILL_WEST);
}
@Override
public void tick() {
drillstep = drillstep == null ? MAXDRILLSTEP : drillstep - 1;
if (drillstep < 1) {
drillstep = MAXDRILLSTEP;
DrillBlockDownEntity.drill(getPos(), getPos().west().down(), getWorld());
}
}
}

View File

@ -0,0 +1,39 @@
package de.jottyfan.minecraft.quickiefabric.blocks;
import java.util.ArrayList;
import java.util.List;
import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockEastEntity;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext.Builder;
import net.minecraft.world.BlockView;
/**
*
* @author jotty
*
*/
public class BlockDrillEast extends FallingBlock implements BlockEntityProvider {
public BlockDrillEast() {
super(FabricBlockSettings.of(Material.STONE).hardness(2.5f));
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
return new DrillBlockEastEntity();
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
List<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(QuickieBlocks.DRILL_EAST));
return list;
}
}

View File

@ -0,0 +1,39 @@
package de.jottyfan.minecraft.quickiefabric.blocks;
import java.util.ArrayList;
import java.util.List;
import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockNorthEntity;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext.Builder;
import net.minecraft.world.BlockView;
/**
*
* @author jotty
*
*/
public class BlockDrillNorth extends FallingBlock implements BlockEntityProvider {
public BlockDrillNorth() {
super(FabricBlockSettings.of(Material.STONE).hardness(2.5f));
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
return new DrillBlockNorthEntity();
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
List<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(QuickieBlocks.DRILL_NORTH));
return list;
}
}

View File

@ -0,0 +1,39 @@
package de.jottyfan.minecraft.quickiefabric.blocks;
import java.util.ArrayList;
import java.util.List;
import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockSouthEntity;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext.Builder;
import net.minecraft.world.BlockView;
/**
*
* @author jotty
*
*/
public class BlockDrillSouth extends FallingBlock implements BlockEntityProvider {
public BlockDrillSouth() {
super(FabricBlockSettings.of(Material.STONE).hardness(2.5f));
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
return new DrillBlockSouthEntity();
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
List<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(QuickieBlocks.DRILL_SOUTH));
return list;
}
}

View File

@ -0,0 +1,39 @@
package de.jottyfan.minecraft.quickiefabric.blocks;
import java.util.ArrayList;
import java.util.List;
import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockWestEntity;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext.Builder;
import net.minecraft.world.BlockView;
/**
*
* @author jotty
*
*/
public class BlockDrillWest extends FallingBlock implements BlockEntityProvider {
public BlockDrillWest() {
super(FabricBlockSettings.of(Material.STONE).hardness(2.5f));
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
return new DrillBlockWestEntity();
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
List<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(QuickieBlocks.DRILL_WEST));
return list;
}
}

View File

@ -0,0 +1,10 @@
package de.jottyfan.minecraft.quickiefabric.blocks.help;
/**
*
* @author jotty
*
*/
public enum NWSE {
NORTH, SOUTH, EAST, WEST, NONE;
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "quickiefabric:block/drilleast"
}
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "quickiefabric:block/drillnorth"
}
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "quickiefabric:block/drillsouth"
}
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "quickiefabric:block/drillwest"
}
}
}

View File

@ -0,0 +1,45 @@
{
"parent": "block/cube",
"textures": {
"bottom": "quickiefabric:block/drilleast",
"all": "quickiefabric:block/drill"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"down": {
"uv": [0, 0, 16, 16],
"texture": "#bottom",
"cullface": "down"
},
"up": {
"uv": [0, 0, 16, 16],
"texture": "#bottom",
"cullface": "up"
},
"north": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "north"
},
"south": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "south"
},
"east": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "east"
},
"west": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "west"
}
}
}
]
}

View File

@ -0,0 +1,45 @@
{
"parent": "block/cube",
"textures": {
"bottom": "quickiefabric:block/drillnorth",
"all": "quickiefabric:block/drill"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"down": {
"uv": [0, 0, 16, 16],
"texture": "#bottom",
"cullface": "down"
},
"up": {
"uv": [0, 0, 16, 16],
"texture": "#bottom",
"cullface": "up"
},
"north": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "north"
},
"south": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "south"
},
"east": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "east"
},
"west": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "west"
}
}
}
]
}

View File

@ -0,0 +1,45 @@
{
"parent": "block/cube",
"textures": {
"bottom": "quickiefabric:block/drillsouth",
"all": "quickiefabric:block/drill"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"down": {
"uv": [0, 0, 16, 16],
"texture": "#bottom",
"cullface": "down"
},
"up": {
"uv": [0, 0, 16, 16],
"texture": "#bottom",
"cullface": "up"
},
"north": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "north"
},
"south": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "south"
},
"east": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "east"
},
"west": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "west"
}
}
}
]
}

View File

@ -0,0 +1,45 @@
{
"parent": "block/cube",
"textures": {
"bottom": "quickiefabric:block/drillwest",
"all": "quickiefabric:block/drill"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"down": {
"uv": [0, 0, 16, 16],
"texture": "#bottom",
"cullface": "down"
},
"up": {
"uv": [0, 0, 16, 16],
"texture": "#bottom",
"cullface": "up"
},
"north": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "north"
},
"south": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "south"
},
"east": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "east"
},
"west": {
"uv": [0, 0, 16, 16],
"texture": "#all",
"cullface": "west"
}
}
}
]
}

View File

@ -0,0 +1,10 @@
{
"parent": "quickiefabric:block/drilleast",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}

View File

@ -0,0 +1,10 @@
{
"parent": "quickiefabric:block/drillnorth",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}

View File

@ -0,0 +1,10 @@
{
"parent": "quickiefabric:block/drillsouth",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}

View File

@ -0,0 +1,10 @@
{
"parent": "quickiefabric:block/drillwest",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,12 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "quickiefabric:drillwest"
}
],
"result": {
"item": "quickiefabric:drillnorth",
"count": 1
}
}

View File

@ -0,0 +1,12 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "quickiefabric:drill"
}
],
"result": {
"item": "quickiefabric:drilleast",
"count": 1
}
}

View File

@ -0,0 +1,12 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "quickiefabric:drillnorth"
}
],
"result": {
"item": "quickiefabric:drill",
"count": 1
}
}

View File

@ -0,0 +1,12 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "quickiefabric:drilleast"
}
],
"result": {
"item": "quickiefabric:drillsouth",
"count": 1
}
}

View File

@ -0,0 +1,12 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "quickiefabric:drillsouth"
}
],
"result": {
"item": "quickiefabric:drillwest",
"count": 1
}
}