61 lines
2.5 KiB
Java
61 lines
2.5 KiB
Java
package net.minecraft.world.level.block;
|
|
|
|
import net.minecraft.world.level.block.state.AbstractStateHolder;
|
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
|
import net.minecraft.world.entity.player.Inventory;
|
|
import net.minecraft.world.level.block.state.StateDefinition;
|
|
import net.minecraft.world.level.block.state.properties.Property;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.world.item.BlockPlaceContext;
|
|
import net.minecraft.network.chat.Component;
|
|
import net.minecraft.world.SimpleMenuProvider;
|
|
import net.minecraft.world.inventory.LoomMenu;
|
|
import net.minecraft.world.inventory.ContainerLevelAccess;
|
|
import net.minecraft.world.MenuProvider;
|
|
import net.minecraft.stats.Stats;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.phys.BlockHitResult;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.network.chat.TranslatableComponent;
|
|
|
|
public class LoomBlock extends HorizontalDirectionalBlock {
|
|
private static final TranslatableComponent CONTAINER_TITLE;
|
|
|
|
protected LoomBlock(final Properties c) {
|
|
super(c);
|
|
}
|
|
|
|
@Override
|
|
public InteractionResult use(final BlockState byg, final Level bjt, final BlockPos fk, final Player ayg, final InteractionHand ajh, final BlockHitResult cvd) {
|
|
if (bjt.isClientSide) {
|
|
return InteractionResult.SUCCESS;
|
|
}
|
|
ayg.openMenu(byg.getMenuProvider(bjt, fk));
|
|
ayg.awardStat(Stats.INTERACT_WITH_LOOM);
|
|
return InteractionResult.SUCCESS;
|
|
}
|
|
|
|
@Override
|
|
public MenuProvider getMenuProvider(final BlockState byg, final Level bjt, final BlockPos fk) {
|
|
return new SimpleMenuProvider((integer, ayf, ayg) -> new LoomMenu(integer, ayf, ContainerLevelAccess.create(bjt, fk)), LoomBlock.CONTAINER_TITLE);
|
|
}
|
|
|
|
@Override
|
|
public BlockState getStateForPlacement(final BlockPlaceContext bcn) {
|
|
return ((AbstractStateHolder<O, BlockState>)this.defaultBlockState()).<Comparable, Direction>setValue((Property<Comparable>)LoomBlock.FACING, bcn.getHorizontalDirection().getOpposite());
|
|
}
|
|
|
|
@Override
|
|
protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> a) {
|
|
a.add(LoomBlock.FACING);
|
|
}
|
|
|
|
static {
|
|
CONTAINER_TITLE = new TranslatableComponent("container.loom", new Object[0]);
|
|
}
|
|
}
|