Save
This commit is contained in:
parent
a56025fcc6
commit
f323507a8a
|
|
@ -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.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
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 org.jetbrains.annotations.Nullable;
|
||||||
import thedarkcolour.exdeorum.blockentity.MechanicalHammerBlockEntity;
|
import thedarkcolour.exdeorum.blockentity.MechanicalHammerBlockEntity;
|
||||||
import thedarkcolour.exdeorum.registry.EBlockEntities;
|
import thedarkcolour.exdeorum.registry.EBlockEntities;
|
||||||
|
|
||||||
public class MechanicalHammerBlock extends EBlock {
|
public class MechanicalHammerBlock extends EBlock {
|
||||||
|
public static final BooleanProperty RUNNING = BooleanProperty.create("running");
|
||||||
|
|
||||||
public MechanicalHammerBlock(Properties properties) {
|
public MechanicalHammerBlock(Properties properties) {
|
||||||
super(properties, EBlockEntities.MECHANICAL_HAMMER);
|
super(properties, EBlockEntities.MECHANICAL_HAMMER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||||
|
builder.add(RUNNING);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@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;
|
return type == EBlockEntities.MECHANICAL_HAMMER.get() && !level.isClientSide ? (BlockEntityTicker<T>) new MechanicalHammerBlockEntity.ServerTicker<>() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import thedarkcolour.exdeorum.block.MechanicalHammerBlock;
|
||||||
import thedarkcolour.exdeorum.blockentity.helper.ItemHelper;
|
import thedarkcolour.exdeorum.blockentity.helper.ItemHelper;
|
||||||
import thedarkcolour.exdeorum.config.EConfig;
|
import thedarkcolour.exdeorum.config.EConfig;
|
||||||
import thedarkcolour.exdeorum.data.TranslationKeys;
|
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 (!input.isEmpty() && !this.inventory.getStackInSlot(HAMMER_SLOT).isEmpty()) {
|
||||||
if (canFitResultIntoOutput(input) != null) {
|
if (canFitResultIntoOutput(input) != null) {
|
||||||
this.progress = 0;
|
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;
|
this.progress = NOT_RUNNING;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.level.setBlock(this.worldPosition, this.getBlockState().setValue(MechanicalHammerBlock.RUNNING, false), 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"running=false": {
|
||||||
|
"model": "exdeorum:block/mechanical_hammer_off"
|
||||||
|
},
|
||||||
|
"running=true": {
|
||||||
|
"model": "exdeorum:block/mechanical_hammer_on"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user