drill added

This commit is contained in:
Jottyfan 2024-06-11 22:56:21 +02:00
parent 9299dc39f1
commit a757dce854
46 changed files with 1101 additions and 0 deletions

View File

@ -19,4 +19,14 @@ public class BlockEntityTypes {
BlockEntityType.Builder.create(ItemHoarderBlockEntity::new, QuickieBlocks.ITEMHOARDER.getBlock()).build(null)); BlockEntityType.Builder.create(ItemHoarderBlockEntity::new, QuickieBlocks.ITEMHOARDER.getBlock()).build(null));
public static final BlockEntityType<MonsterHoarderBlockEntity> MONSTERHOARDER = Registry.register(Registries.BLOCK_ENTITY_TYPE, public static final BlockEntityType<MonsterHoarderBlockEntity> MONSTERHOARDER = Registry.register(Registries.BLOCK_ENTITY_TYPE,
BlockEntityIdentity.MONSTERHOARDER, BlockEntityType.Builder.create(MonsterHoarderBlockEntity::new, QuickieBlocks.MONSTERHOARDER.getBlock()).build(null)); BlockEntityIdentity.MONSTERHOARDER, BlockEntityType.Builder.create(MonsterHoarderBlockEntity::new, QuickieBlocks.MONSTERHOARDER.getBlock()).build(null));
public static final BlockEntityType<DrillBlockDownEntity> DRILL_DOWN = Registry.register(Registries.BLOCK_ENTITY_TYPE, BlockEntityIdentity.DRILL_DOWN,
BlockEntityType.Builder.create(DrillBlockDownEntity::new, QuickieBlocks.DRILL_DOWN.getBlock()).build(null));
public static final BlockEntityType<DrillBlockEastEntity> DRILL_EAST = Registry.register(Registries.BLOCK_ENTITY_TYPE, BlockEntityIdentity.DRILL_EAST,
BlockEntityType.Builder.create(DrillBlockEastEntity::new, QuickieBlocks.DRILL_EAST.getBlock()).build(null));
public static final BlockEntityType<DrillBlockSouthEntity> DRILL_SOUTH = Registry.register(Registries.BLOCK_ENTITY_TYPE, BlockEntityIdentity.DRILL_SOUTH,
BlockEntityType.Builder.create(DrillBlockSouthEntity::new, QuickieBlocks.DRILL_SOUTH.getBlock()).build(null));
public static final BlockEntityType<DrillBlockWestEntity> DRILL_WEST = Registry.register(Registries.BLOCK_ENTITY_TYPE, BlockEntityIdentity.DRILL_WEST,
BlockEntityType.Builder.create(DrillBlockWestEntity::new, QuickieBlocks.DRILL_WEST.getBlock()).build(null));
public static final BlockEntityType<DrillBlockNorthEntity> DRILL_NORTH = Registry.register(Registries.BLOCK_ENTITY_TYPE, BlockEntityIdentity.DRILL_NORTH,
BlockEntityType.Builder.create(DrillBlockNorthEntity::new, QuickieBlocks.DRILL_NORTH.getBlock()).build(null));
} }

View File

@ -0,0 +1,62 @@
package de.jottyfan.quickiemod.blockentity;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class DrillBlockDownEntity extends DrillBlockEntity {
private static final Integer MAXDRILLSTEP = 20;
public DrillBlockDownEntity(BlockPos pos, BlockState state) {
super(BlockEntityTypes.DRILL_DOWN, pos, state, MAXDRILLSTEP);
}
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
if (be instanceof DrillBlockDownEntity) {
DrillBlockDownEntity dbe = (DrillBlockDownEntity) be;
DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, generateBlockPos(pos));
}
}
public static final List<BlockPos> generateBlockPos(BlockPos pos) {
List<BlockPos> list = new ArrayList<>();
Integer tracesMod = pos.getY() % 8;
tracesMod = tracesMod < 0 ? tracesMod * -1 : tracesMod; // lower that 0 makes it negative
if (tracesMod != 0) {
list.add(pos.north());
}
if (tracesMod != 1) {
list.add(pos.north().west());
}
if (tracesMod != 2) {
list.add(pos.west());
}
if (tracesMod != 3) {
list.add(pos.south().west());
}
if (tracesMod != 4) {
list.add(pos.south());
}
if (tracesMod != 5) {
list.add(pos.south().east());
}
if (tracesMod != 6) {
list.add(pos.east());
}
if (tracesMod != 7) {
list.add(pos.north().east());
}
list.add(pos.down()); // must be last position
return list;
}
}

View File

@ -0,0 +1,36 @@
package de.jottyfan.quickiemod.blockentity;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class DrillBlockEastEntity extends DrillBlockEntity {
private static final Integer MAXDRILLSTEP = 24;
public DrillBlockEastEntity(BlockPos pos, BlockState state) {
super(BlockEntityTypes.DRILL_EAST, pos, state, MAXDRILLSTEP);
}
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
if (be instanceof DrillBlockEastEntity) {
DrillBlockEastEntity dbe = (DrillBlockEastEntity) be;
List<BlockPos> list = new ArrayList<>();
list.add(pos.east());
list.add(pos.east().up());
list.add(pos.east().up().up());
list.add(pos.east().up().up().up());
list.add(pos.east().down()); // must be last position
DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, list);
}
}
}

View File

@ -0,0 +1,73 @@
package de.jottyfan.quickiemod.blockentity;
import java.util.List;
import de.jottyfan.quickiemod.blocks.QuickieBlocks;
import de.jottyfan.quickiemod.blocks.help.DrillBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public abstract class DrillBlockEntity extends BlockEntity {
private Integer drillstep;
private final Integer maxDrillStep;
public DrillBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state, Integer maxDrillStep) {
super(type, pos, state);
this.maxDrillStep = maxDrillStep;
}
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());
Integer newFuel = bs.get(DrillBlock.FUEL) - 1;
world.setBlockState(to, bs.with(DrillBlock.FUEL, newFuel));
world.addBlockEntity(be);
world.removeBlockEntity(from);
}
}
protected static final Boolean drill(BlockPos pos, List<BlockPos> toList, World world) {
Boolean lastSuccess = false;
for (BlockPos to : toList) {
if (!world.getBlockState(to).isOf(Blocks.BEDROCK) && !world.getBlockState(to).isOf(QuickieBlocks.DRILLSTOP.getBlock())) {
world.breakBlock(to, true);
lastSuccess = pos.down() != to; // no need for the falling one
} else {
lastSuccess = false; // in case that the last one is a bedrock or a drillstop
}
}
return lastSuccess;
}
public static void tick(World world, BlockPos pos, BlockState state, DrillBlockEntity be, Integer maxDrillStep,
List<BlockPos> drillPosition) {
if (state.get(DrillBlock.FUEL) > 0) {
if (be.getDrillstep() < 1) {
be.setDrillstep(maxDrillStep);
if (drill(pos, drillPosition, world)) {
moveBlockWithEntity(pos, drillPosition.get(drillPosition.size() - 1), world);
}
} else {
be.doDrillstep();
}
}
}
public void doDrillstep() {
setDrillstep(getDrillstep() - 1);
}
public Integer getDrillstep() {
return drillstep == null ? maxDrillStep : drillstep;
}
public void setDrillstep(Integer drillstep) {
this.drillstep = drillstep;
}
}

View File

@ -0,0 +1,36 @@
package de.jottyfan.quickiemod.blockentity;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class DrillBlockNorthEntity extends DrillBlockEntity {
private static final Integer MAXDRILLSTEP = 24;
public DrillBlockNorthEntity(BlockPos pos, BlockState state) {
super(BlockEntityTypes.DRILL_NORTH, pos, state, MAXDRILLSTEP);
}
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
if (be instanceof DrillBlockNorthEntity) {
DrillBlockNorthEntity dbe = (DrillBlockNorthEntity) be;
List<BlockPos> list = new ArrayList<>();
list.add(pos.north());
list.add(pos.north().up());
list.add(pos.north().up().up());
list.add(pos.north().up().up().up());
list.add(pos.north().down()); // must be last position
DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, list);
}
}
}

View File

@ -0,0 +1,35 @@
package de.jottyfan.quickiemod.blockentity;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class DrillBlockSouthEntity extends DrillBlockEntity {
private static final Integer MAXDRILLSTEP = 24;
public DrillBlockSouthEntity(BlockPos pos, BlockState state) {
super(BlockEntityTypes.DRILL_SOUTH, pos, state, MAXDRILLSTEP);
}
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
if (be instanceof DrillBlockSouthEntity) {
DrillBlockSouthEntity dbe = (DrillBlockSouthEntity) be;
List<BlockPos> list = new ArrayList<>();
list.add(pos.south());
list.add(pos.south().up());
list.add(pos.south().up().up());
list.add(pos.south().up().up().up());
list.add(pos.south().down()); // must be last position
DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, list);
}
}
}

View File

@ -0,0 +1,36 @@
package de.jottyfan.quickiemod.blockentity;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class DrillBlockWestEntity extends DrillBlockEntity {
private static final Integer MAXDRILLSTEP = 24;
public DrillBlockWestEntity(BlockPos pos, BlockState state) {
super(BlockEntityTypes.DRILL_WEST, pos, state, MAXDRILLSTEP);
}
public static void tick(World world, BlockPos pos, BlockState state, BlockEntity be) {
if (be instanceof DrillBlockWestEntity) {
DrillBlockWestEntity dbe = (DrillBlockWestEntity) be;
List<BlockPos> list = new ArrayList<>();
list.add(pos.west());
list.add(pos.west().up());
list.add(pos.west().up().up());
list.add(pos.west().up().up().up());
list.add(pos.west().down()); // must be last position
DrillBlockEntity.tick(world, pos, state, dbe, MAXDRILLSTEP, list);
}
}
}

View File

@ -0,0 +1,61 @@
package de.jottyfan.quickiemod.blocks;
import java.util.ArrayList;
import java.util.List;
import com.mojang.serialization.MapCodec;
import de.jottyfan.quickiemod.blockentity.DrillBlockDownEntity;
import de.jottyfan.quickiemod.blocks.help.DrillBlock;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContextParameterSet.Builder;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class BlockDrillDown extends DrillBlock implements BlockEntityProvider {
public BlockDrillDown() {
super(AbstractBlock.Settings.create().hardness(2.5f));
}
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
return new DrillBlockDownEntity(pos, blockState);
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
List<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(QuickieBlocks.DRILL_DOWN.getBlock()));
return list;
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state,
BlockEntityType<T> type) {
return (world1, pos, state1, be) -> DrillBlockDownEntity.tick(world1, pos, state1, be);
}
@Override
protected MapCodec<? extends FallingBlock> getCodec() {
return null; // TODO: what to return here?
}
}

View File

@ -0,0 +1,61 @@
package de.jottyfan.quickiemod.blocks;
import java.util.ArrayList;
import java.util.List;
import com.mojang.serialization.MapCodec;
import de.jottyfan.quickiemod.blockentity.DrillBlockEastEntity;
import de.jottyfan.quickiemod.blocks.help.DrillBlock;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContextParameterSet.Builder;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class BlockDrillEast extends DrillBlock implements BlockEntityProvider {
public BlockDrillEast() {
super(AbstractBlock.Settings.create().hardness(2.5f));
}
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
return new DrillBlockEastEntity(pos, blockState);
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
List<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(QuickieBlocks.DRILL_EAST.getBlock()));
return list;
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){
return (world1, pos, state1, be) -> DrillBlockEastEntity.tick(world1, pos, state1, be);
}
@Override
protected MapCodec<? extends FallingBlock> getCodec() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,61 @@
package de.jottyfan.quickiemod.blocks;
import java.util.ArrayList;
import java.util.List;
import com.mojang.serialization.MapCodec;
import de.jottyfan.quickiemod.blockentity.DrillBlockNorthEntity;
import de.jottyfan.quickiemod.blocks.help.DrillBlock;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContextParameterSet.Builder;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class BlockDrillNorth extends DrillBlock implements BlockEntityProvider {
public BlockDrillNorth() {
super(AbstractBlock.Settings.create().hardness(2.5f));
}
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
return new DrillBlockNorthEntity(pos, blockState);
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
List<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(QuickieBlocks.DRILL_NORTH.getBlock()));
return list;
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){
return (world1, pos, state1, be) -> DrillBlockNorthEntity.tick(world1, pos, state1, be);
}
@Override
protected MapCodec<? extends FallingBlock> getCodec() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,61 @@
package de.jottyfan.quickiemod.blocks;
import java.util.ArrayList;
import java.util.List;
import com.mojang.serialization.MapCodec;
import de.jottyfan.quickiemod.blockentity.DrillBlockSouthEntity;
import de.jottyfan.quickiemod.blocks.help.DrillBlock;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContextParameterSet.Builder;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class BlockDrillSouth extends DrillBlock implements BlockEntityProvider {
public BlockDrillSouth() {
super(AbstractBlock.Settings.create().hardness(2.5f));
}
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
return new DrillBlockSouthEntity(pos, blockState);
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
List<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(QuickieBlocks.DRILL_SOUTH.getBlock()));
return list;
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){
return (world1, pos, state1, be) -> DrillBlockSouthEntity.tick(world1, pos, state1, be);
}
@Override
protected MapCodec<? extends FallingBlock> getCodec() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,61 @@
package de.jottyfan.quickiemod.blocks;
import java.util.ArrayList;
import java.util.List;
import com.mojang.serialization.MapCodec;
import de.jottyfan.quickiemod.blockentity.DrillBlockWestEntity;
import de.jottyfan.quickiemod.blocks.help.DrillBlock;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContextParameterSet.Builder;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class BlockDrillWest extends DrillBlock implements BlockEntityProvider {
public BlockDrillWest() {
super(AbstractBlock.Settings.create().hardness(2.5f));
}
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
return new DrillBlockWestEntity(pos, blockState);
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
List<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(QuickieBlocks.DRILL_WEST.getBlock()));
return list;
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){
return (world1, pos, state1, be) -> DrillBlockWestEntity.tick(world1, pos, state1, be);
}
@Override
protected MapCodec<? extends FallingBlock> getCodec() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,30 @@
package de.jottyfan.quickiemod.blocks;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContextParameterSet.Builder;
/**
*
* @author jotty
*
*/
public class BlockDrillstop extends Block {
public BlockDrillstop() {
super(AbstractBlock.Settings.create().hardness(2.5f));
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
List<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(QuickieBlocks.DRILLSTOP.getBlock()));
return list;
}
}

View File

@ -9,6 +9,12 @@ import net.minecraft.block.Block;
*/ */
public enum QuickieBlocks { public enum QuickieBlocks {
// @formatter:off // @formatter:off
DRILL_DOWN(new BlockDrillDown(), "drill"),
DRILL_EAST(new BlockDrillEast(), "drilleast"),
DRILL_SOUTH(new BlockDrillSouth(), "drillsouth"),
DRILL_WEST(new BlockDrillWest(), "drillwest"),
DRILL_NORTH(new BlockDrillNorth(), "drillnorth"),
DRILLSTOP(new BlockDrillstop(), "drillstop"),
MONSTERHOARDER(new BlockMonsterhoarder(), "monsterhoarder"), MONSTERHOARDER(new BlockMonsterhoarder(), "monsterhoarder"),
ITEMHOARDER(new BlockItemhoarder(), "itemhoarder"), ITEMHOARDER(new BlockItemhoarder(), "itemhoarder"),
LAVAHOARDER(new BlockLavahoarder(), "lavahoarder", false), LAVAHOARDER(new BlockLavahoarder(), "lavahoarder", false),

View File

@ -0,0 +1,78 @@
package de.jottyfan.quickiemod.blocks.help;
import java.util.HashMap;
import java.util.Map;
import de.jottyfan.quickiemod.items.QuickieItems;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FallingBlock;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.state.property.IntProperty;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public abstract class DrillBlock extends FallingBlock {
private static final Integer MAX_FUEL = 255;
public static final IntProperty FUEL = IntProperty.of("fuel", 0, MAX_FUEL);
public DrillBlock(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(FUEL, 0));
}
@Override
public BlockState onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
Integer fuelLeft = state.get(FUEL);
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(QuickieItems.CANOLABOTTLE.getItem(), fuelLeft)));
return super.onBreak(world, pos, state, player);
}
@Override
protected void appendProperties(net.minecraft.state.StateManager.Builder<Block, BlockState> builder) {
builder.add(FUEL);
}
@Override
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
Map<Item, Integer> loadings = new HashMap<>();
loadings.put(QuickieItems.CANOLABOTTLE.getItem(), 8);
loadings.put(QuickieItems.CANOLABOTTLESTACK.getItem(), 72);
ItemStack stack = player.getStackInHand(player.getActiveHand());
Item item = stack.getItem();
if (stack.isEmpty() || !loadings.containsKey(item) ) {
if (world.isClient()) {
player.sendMessage(Text.translatable("msg.drill.fuelinfo", state.get(FUEL)));
}
} else {
Integer fuelWeight = loadings.get(item);
if (fuelWeight != null) {
Integer load = MAX_FUEL - state.get(FUEL);
if (load < fuelWeight) {
// Integer numberOfTooMuchLoad = fuelWeight - load;
fuelWeight = load;
}
world.setBlockState(pos, state.with(FUEL, state.get(FUEL) + fuelWeight));
if (item.equals(QuickieItems.CANOLABOTTLE.getItem())) {
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.GLASS_BOTTLE, 1)));
} else if (item.equals(QuickieItems.CANOLABOTTLESTACK.getItem())) {
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.GLASS_BOTTLE, 9)));
}
stack.decrement(1);
}
}
return ActionResult.PASS;
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "quickiemod:block/drill"
}
}
}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "quickiemod:block/drillstop"
}
}
}

View File

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

View File

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "quickiemod:block/drill"
}
}

View File

@ -0,0 +1,45 @@
{
"parent": "block/cube",
"textures": {
"bottom": "quickiemod:block/drilleast",
"all": "quickiemod: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": "quickiemod:block/drillnorth",
"all": "quickiemod: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": "quickiemod:block/drillsouth",
"all": "quickiemod: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,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "quickiemod:block/drillstop"
}
}

View File

@ -0,0 +1,45 @@
{
"parent": "block/cube",
"textures": {
"bottom": "quickiemod:block/drillwest",
"all": "quickiemod: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": "quickiemod:block/drill",
"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": "quickiemod: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": "quickiemod: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": "quickiemod: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": "quickiemod:block/drillstop",
"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": "quickiemod: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: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"q q",
"dqd",
" d "
],
"key": {
"q": {
"item": "quickiemod:quickieingot"
},
"d": {
"item": "minecraft:diamond"
}
},
"result": {
"id": "quickiemod:drill",
"count": 1
}
}

View File

@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"ooo",
"oso",
"ooo"
],
"key": {
"s": {
"item": "quickiemod:speedingot"
},
"o": {
"item": "minecraft:obsidian"
}
},
"result": {
"id": "quickiemod:drillstop",
"count": 1
}
}

View File

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

View File

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

View File

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

View File

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

View File

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