154 lines
8.0 KiB
Java
154 lines
8.0 KiB
Java
package com.dairymoose.modernlife.blocks;
|
|
|
|
import com.dairymoose.entity.projectile.ThrownSeedEntity;
|
|
import com.dairymoose.modernlife.tileentities.SeedSpreaderBlockEntity;
|
|
import com.dairymoose.modernlife.util.ModernLifeUtil;
|
|
import java.util.List;
|
|
import java.util.stream.Stream;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.network.chat.Component;
|
|
import net.minecraft.network.chat.TextComponent;
|
|
import net.minecraft.world.Containers;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.MenuProvider;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.player.Inventory;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
|
import net.minecraft.world.inventory.ChestMenu;
|
|
import net.minecraft.world.inventory.MenuType;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.item.TooltipFlag;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.block.Block;
|
|
import net.minecraft.world.level.block.EntityBlock;
|
|
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.BlockBehaviour;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.phys.BlockHitResult;
|
|
import net.minecraft.world.phys.shapes.BooleanOp;
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
import net.minecraft.world.phys.shapes.EntityCollisionContext;
|
|
import net.minecraft.world.phys.shapes.Shapes;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/SeedSpreaderBlock.class */
|
|
public class SeedSpreaderBlock extends Block implements EntityBlock {
|
|
protected static final VoxelShape SHAPE_NORTH = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{Block.box(6.5d, 3.5d, 6.5d, 9.5d, 7.5d, 9.5d), Block.box(3.0d, 10.5d, 3.0d, 13.0d, 13.5d, 13.0d), Block.box(4.0d, 7.5d, 4.0d, 12.0d, 10.5d, 12.0d), Block.box(5.9289321881345245d, 0.0d, 3.0d, 10.071067811865476d, 3.504d, 7.0d), Block.box(5.9289321881345245d, 0.0d, 3.0d, 10.071067811865476d, 3.5d, 7.0d), Block.box(9.0d, 0.0d, 5.9289321881345245d, 13.0d, 3.501d, 10.071067811865476d), Block.box(9.0d, 0.0d, 5.9289321881345245d, 13.0d, 3.5d, 10.071067811865476d), Block.box(5.9289321881345245d, 0.0d, 9.0d, 10.071067811865476d, 3.502d, 13.0d), Block.box(5.9289321881345245d, 0.0d, 9.0d, 10.071067811865476d, 3.5d, 13.0d), Block.box(3.0d, 0.0d, 5.9289321881345245d, 7.0d, 3.503d, 10.071067811865476d), Block.box(3.0d, 0.0d, 5.9289321881345245d, 7.0d, 3.5d, 10.071067811865476d), Block.box(4.0d, 10.6d, 11.75d, 12.0d, 13.25d, 12.75d), Block.box(3.25d, 10.6d, 4.0d, 4.25d, 13.25d, 12.0d), Block.box(4.0d, 10.6d, 3.25d, 12.0d, 13.25d, 4.25d), Block.box(11.75d, 10.6d, 4.0d, 12.75d, 13.25d, 12.0d)}).reduce((v1, v2) -> {
|
|
return Shapes.join(v1, v2, BooleanOp.OR);
|
|
}).get();
|
|
|
|
public SeedSpreaderBlock(Properties p_i48377_1_) {
|
|
super(p_i48377_1_);
|
|
}
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
public void appendHoverText(ItemStack itemStack, @Nullable BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag) {
|
|
list.add(new TextComponent("Automatically disperses seeds that are put inside of it"));
|
|
}
|
|
|
|
public void onRemove(BlockState p_196243_1_, Level p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, boolean p_196243_5_) {
|
|
if (!p_196243_1_.is(p_196243_4_.getBlock())) {
|
|
BlockEntity lvt_6_1_ = p_196243_2_.getBlockEntity(p_196243_3_);
|
|
if (lvt_6_1_ instanceof SeedSpreaderBlockEntity) {
|
|
Containers.dropContents(p_196243_2_, p_196243_3_, (SeedSpreaderBlockEntity) lvt_6_1_);
|
|
p_196243_2_.updateNeighbourForOutputSignal(p_196243_3_, this);
|
|
}
|
|
super.onRemove(p_196243_1_, p_196243_2_, p_196243_3_, p_196243_4_, p_196243_5_);
|
|
}
|
|
}
|
|
|
|
/* renamed from: com.dairymoose.modernlife.blocks.SeedSpreaderBlock$1 */
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/SeedSpreaderBlock$1.class */
|
|
public class C00551 implements MenuProvider {
|
|
final /* synthetic */ Level val$p_220052_2_;
|
|
final /* synthetic */ BlockPos val$p_220052_3_;
|
|
|
|
C00551(Level level, BlockPos blockPos) {
|
|
p_220052_2_ = level;
|
|
p_220052_3_ = blockPos;
|
|
}
|
|
|
|
public AbstractContainerMenu createMenu(int paramInt, Inventory paramInventory, Player paramPlayer) {
|
|
BlockEntity tileEntity = p_220052_2_.getBlockEntity(p_220052_3_);
|
|
if (tileEntity instanceof SeedSpreaderBlockEntity) {
|
|
SeedSpreaderBlockEntity seedSpreaderBlockEntity = (SeedSpreaderBlockEntity) tileEntity;
|
|
ChestMenu chest = new ChestMenu(MenuType.GENERIC_9x1, paramInt, paramInventory, seedSpreaderBlockEntity, 1);
|
|
if (!paramPlayer.level.isClientSide) {
|
|
}
|
|
return chest;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public Component getDisplayName() {
|
|
return new TextComponent("Seed Spreader");
|
|
}
|
|
}
|
|
|
|
public MenuProvider getMenuProvider(BlockState p_220052_1_, Level p_220052_2_, BlockPos p_220052_3_) {
|
|
return new MenuProvider() { // from class: com.dairymoose.modernlife.blocks.SeedSpreaderBlock.1
|
|
final /* synthetic */ Level val$p_220052_2_;
|
|
final /* synthetic */ BlockPos val$p_220052_3_;
|
|
|
|
C00551(Level p_220052_2_2, BlockPos p_220052_3_2) {
|
|
p_220052_2_ = p_220052_2_2;
|
|
p_220052_3_ = p_220052_3_2;
|
|
}
|
|
|
|
public AbstractContainerMenu createMenu(int paramInt, Inventory paramInventory, Player paramPlayer) {
|
|
BlockEntity tileEntity = p_220052_2_.getBlockEntity(p_220052_3_);
|
|
if (tileEntity instanceof SeedSpreaderBlockEntity) {
|
|
SeedSpreaderBlockEntity seedSpreaderBlockEntity = (SeedSpreaderBlockEntity) tileEntity;
|
|
ChestMenu chest = new ChestMenu(MenuType.GENERIC_9x1, paramInt, paramInventory, seedSpreaderBlockEntity, 1);
|
|
if (!paramPlayer.level.isClientSide) {
|
|
}
|
|
return chest;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public Component getDisplayName() {
|
|
return new TextComponent("Seed Spreader");
|
|
}
|
|
};
|
|
}
|
|
|
|
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
|
return ModernLifeUtil.createTickerHelper(type, SeedSpreaderBlockEntity.SEED_SPREADER, SeedSpreaderBlockEntity::tick);
|
|
}
|
|
|
|
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
|
return SeedSpreaderBlockEntity.SEED_SPREADER.create(pos, state);
|
|
}
|
|
|
|
public InteractionResult use(BlockState p_225533_1_, Level p_225533_2_, BlockPos p_225533_3_, Player p_225533_4_, InteractionHand p_225533_5_, BlockHitResult p_225533_6_) {
|
|
MenuProvider lvt_7_1_ = getMenuProvider(p_225533_1_, p_225533_2_, p_225533_3_);
|
|
if (lvt_7_1_ != null) {
|
|
p_225533_4_.openMenu(lvt_7_1_);
|
|
}
|
|
return InteractionResult.CONSUME;
|
|
}
|
|
|
|
public VoxelShape getCollisionShape(BlockState state, BlockGetter blockReader, BlockPos blockPos, CollisionContext ctx) {
|
|
if (ctx instanceof EntityCollisionContext) {
|
|
Entity optEntity = ((EntityCollisionContext) ctx).getEntity();
|
|
if (optEntity instanceof ThrownSeedEntity) {
|
|
return Shapes.empty();
|
|
}
|
|
}
|
|
return super.getCollisionShape(state, blockReader, blockPos, ctx);
|
|
}
|
|
|
|
public VoxelShape getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel) {
|
|
return SHAPE_NORTH;
|
|
}
|
|
}
|