This commit is contained in:
thedarkcolour 2024-01-13 23:20:20 -08:00
parent a56025fcc6
commit f323507a8a
5 changed files with 40 additions and 1 deletions

View File

@ -25,19 +25,28 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import org.jetbrains.annotations.Nullable;
import thedarkcolour.exdeorum.blockentity.MechanicalHammerBlockEntity;
import thedarkcolour.exdeorum.registry.EBlockEntities;
public class MechanicalHammerBlock extends EBlock {
public static final BooleanProperty RUNNING = BooleanProperty.create("running");
public MechanicalHammerBlock(Properties properties) {
super(properties, EBlockEntities.MECHANICAL_HAMMER);
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(RUNNING);
}
@SuppressWarnings("unchecked")
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState pState, BlockEntityType<T> type) {
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
return type == EBlockEntities.MECHANICAL_HAMMER.get() && !level.isClientSide ? (BlockEntityTicker<T>) new MechanicalHammerBlockEntity.ServerTicker<>() : null;
}

View File

@ -33,6 +33,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import thedarkcolour.exdeorum.block.MechanicalHammerBlock;
import thedarkcolour.exdeorum.blockentity.helper.ItemHelper;
import thedarkcolour.exdeorum.config.EConfig;
import thedarkcolour.exdeorum.data.TranslationKeys;
@ -101,6 +102,7 @@ public class MechanicalHammerBlockEntity extends AbstractMachineBlockEntity<Mech
if (!input.isEmpty() && !this.inventory.getStackInSlot(HAMMER_SLOT).isEmpty()) {
if (canFitResultIntoOutput(input) != null) {
this.progress = 0;
this.level.setBlock(this.worldPosition, this.getBlockState().setValue(MechanicalHammerBlock.RUNNING, true), 3);
}
}
}
@ -153,6 +155,8 @@ public class MechanicalHammerBlockEntity extends AbstractMachineBlockEntity<Mech
this.progress = NOT_RUNNING;
}
} else {
this.level.setBlock(this.worldPosition, this.getBlockState().setValue(MechanicalHammerBlock.RUNNING, false), 3);
}
}

View File

@ -0,0 +1,10 @@
{
"variants": {
"running=false": {
"model": "exdeorum:block/mechanical_hammer_off"
},
"running=true": {
"model": "exdeorum:block/mechanical_hammer_on"
}
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/orientable",
"textures": {
"front": "exdeorum:block/mechanical_hammer_front_off",
"side": "exdeorum:block/mechanical_hammer_side",
"top": "exdeorum:block/mechanical_hammer_top"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/orientable",
"textures": {
"front": "exdeorum:block/mechanical_hammer_front_on",
"side": "exdeorum:block/mechanical_hammer_side",
"top": "exdeorum:block/mechanical_hammer_top"
}
}