2019-06-20 00:29:15 +02:00
|
|
|
package io.github.cottonmc.templates.block;
|
2019-06-19 22:32:58 +02:00
|
|
|
|
2023-07-04 08:51:41 +02:00
|
|
|
import io.github.cottonmc.templates.api.TemplateInteractionUtil;
|
2019-06-19 22:32:58 +02:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.BlockEntityProvider;
|
|
|
|
import net.minecraft.block.BlockState;
|
2023-07-04 08:51:41 +02:00
|
|
|
import net.minecraft.block.entity.BlockEntity;
|
2023-07-03 10:05:55 +02:00
|
|
|
import net.minecraft.entity.LivingEntity;
|
2019-06-19 22:32:58 +02:00
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2023-06-15 07:59:48 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2023-07-03 09:35:07 +02:00
|
|
|
import net.minecraft.state.StateManager;
|
2023-06-15 09:08:20 +02:00
|
|
|
import net.minecraft.util.ActionResult;
|
2019-06-19 22:32:58 +02:00
|
|
|
import net.minecraft.util.Hand;
|
|
|
|
import net.minecraft.util.hit.BlockHitResult;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.math.Direction;
|
|
|
|
import net.minecraft.world.BlockView;
|
|
|
|
import net.minecraft.world.World;
|
2023-07-03 10:05:55 +02:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2019-06-19 22:32:58 +02:00
|
|
|
|
2023-06-16 05:09:57 +02:00
|
|
|
public abstract class TemplateBlock extends Block implements BlockEntityProvider {
|
2019-06-19 22:32:58 +02:00
|
|
|
public TemplateBlock(Settings settings) {
|
|
|
|
super(settings);
|
2023-07-04 08:51:41 +02:00
|
|
|
setDefaultState(TemplateInteractionUtil.setDefaultStates(getDefaultState()));
|
2019-06-19 22:32:58 +02:00
|
|
|
}
|
2023-06-15 07:59:48 +02:00
|
|
|
|
2023-07-04 08:51:41 +02:00
|
|
|
@Override
|
|
|
|
public abstract @Nullable BlockEntity createBlockEntity(BlockPos blockPos, BlockState blockState);
|
2023-06-15 09:08:20 +02:00
|
|
|
|
2023-07-03 09:35:07 +02:00
|
|
|
@Override
|
|
|
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
2023-07-04 08:51:41 +02:00
|
|
|
super.appendProperties(TemplateInteractionUtil.appendProperties(builder));
|
2023-07-03 09:35:07 +02:00
|
|
|
}
|
|
|
|
|
2019-06-19 22:32:58 +02:00
|
|
|
@Override
|
2023-06-15 09:08:20 +02:00
|
|
|
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
2023-07-04 08:51:41 +02:00
|
|
|
return TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
|
2019-06-19 22:32:58 +02:00
|
|
|
}
|
2023-06-15 07:59:48 +02:00
|
|
|
|
2019-06-19 22:32:58 +02:00
|
|
|
@Override
|
2023-06-15 09:08:20 +02:00
|
|
|
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
2023-07-04 08:51:41 +02:00
|
|
|
TemplateInteractionUtil.onStateReplaced(state, world, pos, newState, moved);
|
2023-06-15 09:08:20 +02:00
|
|
|
super.onStateReplaced(state, world, pos, newState, moved);
|
2019-06-19 22:32:58 +02:00
|
|
|
}
|
2023-06-15 07:59:48 +02:00
|
|
|
|
2023-07-03 10:05:55 +02:00
|
|
|
@Override
|
|
|
|
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
2023-07-04 08:51:41 +02:00
|
|
|
TemplateInteractionUtil.onPlaced(world, pos, state, placer, stack);
|
2023-07-03 10:05:55 +02:00
|
|
|
super.onPlaced(world, pos, state, placer, stack);
|
|
|
|
}
|
|
|
|
|
2019-06-19 22:32:58 +02:00
|
|
|
@Override
|
|
|
|
public boolean emitsRedstonePower(BlockState state) {
|
2023-07-04 08:51:41 +02:00
|
|
|
return TemplateInteractionUtil.emitsRedstonePower(state);
|
2019-06-19 22:32:58 +02:00
|
|
|
}
|
2023-06-15 07:59:48 +02:00
|
|
|
|
2019-06-19 22:32:58 +02:00
|
|
|
@Override
|
|
|
|
public int getWeakRedstonePower(BlockState state, BlockView view, BlockPos pos, Direction dir) {
|
2023-07-04 08:51:41 +02:00
|
|
|
return TemplateInteractionUtil.getWeakRedstonePower(state, view, pos, dir);
|
2019-06-19 22:32:58 +02:00
|
|
|
}
|
2023-06-15 07:59:48 +02:00
|
|
|
|
2019-06-19 22:32:58 +02:00
|
|
|
@Override
|
|
|
|
public int getStrongRedstonePower(BlockState state, BlockView view, BlockPos pos, Direction dir) {
|
2023-07-04 08:51:41 +02:00
|
|
|
return TemplateInteractionUtil.getStrongRedstonePower(state, view, pos, dir);
|
2023-06-15 09:08:20 +02:00
|
|
|
}
|
2019-06-19 22:32:58 +02:00
|
|
|
}
|