fuel for the drills needed
This commit is contained in:
parent
9592018381
commit
a12beb0d3d
@ -9,7 +9,7 @@
|
||||
loader_version=0.15.1
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.20.4.3
|
||||
mod_version = 1.20.4.4
|
||||
maven_group = de.jottyfan.minecraft
|
||||
archives_base_name = quickiefabric
|
||||
|
||||
|
@ -2,6 +2,7 @@ package de.jottyfan.minecraft.quickiefabric.blockentity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.minecraft.quickiefabric.blocks.DrillBlock;
|
||||
import de.jottyfan.minecraft.quickiefabric.blocks.QuickieBlocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@ -11,7 +12,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class DrillBlockEntity extends BlockEntity {
|
||||
|
||||
private Integer drillstep;
|
||||
private final Integer maxDrillStep;
|
||||
|
||||
@ -25,7 +25,8 @@ public abstract class DrillBlockEntity extends BlockEntity {
|
||||
BlockState bs = world.getBlockState(from);
|
||||
if (be != null) {
|
||||
world.setBlockState(from, Blocks.AIR.getDefaultState());
|
||||
world.setBlockState(to, bs);
|
||||
Integer newFuel = bs.get(DrillBlock.FUEL) - 1;
|
||||
world.setBlockState(to, bs.with(DrillBlock.FUEL, newFuel));
|
||||
world.addBlockEntity(be);
|
||||
world.removeBlockEntity(from);
|
||||
}
|
||||
@ -44,14 +45,17 @@ public abstract class DrillBlockEntity extends BlockEntity {
|
||||
return lastSuccess;
|
||||
}
|
||||
|
||||
public static void tick(World world, BlockPos pos, BlockState state, DrillBlockEntity be, Integer maxDrillStep, List<BlockPos> drillPosition) {
|
||||
if (be.getDrillstep() < 1) {
|
||||
be.setDrillstep(maxDrillStep);
|
||||
if (drill(pos, drillPosition, world)) {
|
||||
moveBlockWithEntity(pos, drillPosition.get(drillPosition.size() - 1), world);
|
||||
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();
|
||||
}
|
||||
} else {
|
||||
be.doDrillstep();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,13 @@ import net.minecraft.world.World;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockDrillDown extends FallingBlock implements BlockEntityProvider {
|
||||
public class BlockDrillDown extends DrillBlock implements BlockEntityProvider {
|
||||
|
||||
public BlockDrillDown() {
|
||||
super(FabricBlockSettings.create().hardness(2.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
return new DrillBlockDownEntity(pos, blockState);
|
||||
}
|
||||
@ -47,7 +48,8 @@ public class BlockDrillDown extends FallingBlock implements BlockEntityProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ import net.minecraft.world.World;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockDrillEast extends FallingBlock implements BlockEntityProvider {
|
||||
public class BlockDrillEast extends DrillBlock implements BlockEntityProvider {
|
||||
|
||||
public BlockDrillEast() {
|
||||
super(FabricBlockSettings.create().hardness(2.5f));
|
||||
|
@ -24,7 +24,7 @@ import net.minecraft.world.World;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockDrillNorth extends FallingBlock implements BlockEntityProvider {
|
||||
public class BlockDrillNorth extends DrillBlock implements BlockEntityProvider {
|
||||
|
||||
public BlockDrillNorth() {
|
||||
super(FabricBlockSettings.create().hardness(2.5f));
|
||||
|
@ -24,7 +24,7 @@ import net.minecraft.world.World;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockDrillSouth extends FallingBlock implements BlockEntityProvider {
|
||||
public class BlockDrillSouth extends DrillBlock implements BlockEntityProvider {
|
||||
|
||||
public BlockDrillSouth() {
|
||||
super(FabricBlockSettings.create().hardness(2.5f));
|
||||
|
@ -24,7 +24,7 @@ import net.minecraft.world.World;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class BlockDrillWest extends FallingBlock implements BlockEntityProvider {
|
||||
public class BlockDrillWest extends DrillBlock implements BlockEntityProvider {
|
||||
|
||||
public BlockDrillWest() {
|
||||
super(FabricBlockSettings.create().hardness(2.5f));
|
||||
|
@ -0,0 +1,78 @@
|
||||
package de.jottyfan.minecraft.quickiefabric.blocks;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import de.jottyfan.minecraft.quickiefabric.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.Hand;
|
||||
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(Items.REDSTONE, fuelLeft)));
|
||||
return super.onBreak(world, pos, state, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(net.minecraft.state.StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(FUEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand,
|
||||
BlockHitResult hit) {
|
||||
Map<Item, Integer> loadings = new HashMap<>();
|
||||
loadings.put(QuickieItems.SPEEDPOWDER, 8);
|
||||
loadings.put(QuickieItems.QUICKIEPOWDER, 32);
|
||||
loadings.put(Items.REDSTONE, 1);
|
||||
loadings.put(Items.REDSTONE_BLOCK, 10);
|
||||
ItemStack stack = player.getStackInHand(hand);
|
||||
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.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.REDSTONE, numberOfTooMuchLoad)));
|
||||
}
|
||||
world.setBlockState(pos, state.with(FUEL, state.get(FUEL) + fuelWeight));
|
||||
stack.decrement(1);
|
||||
}
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
@ -101,5 +101,6 @@
|
||||
"msg.backpack.transfer.filled": "Der Rucksack wurde befüllt.",
|
||||
"msg.backpack.transfer.cleared": "Der Rucksackinhalt wurde soweit möglich geleert.",
|
||||
"msg.backpack.transfer.cancel": "Entweder der Rucksack oder die Kiste sind nicht komplett leer.",
|
||||
"msg.drill.fuelinfo": "Der Bohrer hat noch eine Ladung für den Abbau von %s Blöcken. Er kann mit Redstone, Flucht- oder Eilpulver aufgeladen werden.",
|
||||
"error.unleveling.inventory.full": "Es ist kein Platz mehr frei, um die Aufwertungen abzulegen."
|
||||
}
|
||||
|
@ -101,5 +101,6 @@
|
||||
"msg.backpack.transfer.filled": "Filled the backpack.",
|
||||
"msg.backpack.transfer.cleared": "Cleared the backpack as much as possible.",
|
||||
"msg.backpack.transfer.cancel": "Eigther backpack or chest are not completely empty.",
|
||||
"msg.drill.fuelinfo": "The drill still has a charge for mining %s blocks. It can be charged with redstone, speed or hurry powder.",
|
||||
"error.unleveling.inventory.full": "There is no free stack in your inventory for the level ups."
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user