Search in sources :

Example 11 with TileBPMultipart

use of com.bluepowermod.tile.TileBPMultipart in project BluePower by Qmunity.

the class BlockBPMultipart method removedByPlayer.

@Override
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, FluidState fluid) {
    BlockState partState = MultipartUtils.getClosestState(player, pos);
    TileEntity te = world.getBlockEntity(pos);
    if (partState != null && partState.getBlock() instanceof IBPPartBlock && te instanceof TileBPMultipart) {
        // Remove Selected Part
        ((TileBPMultipart) te).removeState(partState);
        // Call onMultipartReplaced
        ((IBPPartBlock) partState.getBlock()).onMultipartReplaced(partState, world, pos, state, false);
        // Play Break Sound
        world.playSound(null, pos, SoundEvents.STONE_BREAK, SoundCategory.BLOCKS, 1.0F, 1.0F);
        return false;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBPPartBlock(com.bluepowermod.api.multipart.IBPPartBlock) TileBPMultipart(com.bluepowermod.tile.TileBPMultipart)

Example 12 with TileBPMultipart

use of com.bluepowermod.tile.TileBPMultipart in project BluePower by Qmunity.

the class BlockBPMultipart method getDrops.

@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
    TileEntity tileentity = builder.getParameter(LootParameters.BLOCK_ENTITY);
    List<ItemStack> itemStacks = new ArrayList<>();
    if (tileentity instanceof TileBPMultipart) {
        ((TileBPMultipart) tileentity).getStates().forEach(s -> itemStacks.addAll(s.getBlock().getDrops(s, builder)));
    }
    return itemStacks;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ArrayList(java.util.ArrayList) TileBPMultipart(com.bluepowermod.tile.TileBPMultipart) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileBPMultipart (com.bluepowermod.tile.TileBPMultipart)12 TileEntity (net.minecraft.tileentity.TileEntity)12 ItemStack (net.minecraft.item.ItemStack)6 ArrayList (java.util.ArrayList)5 CompoundNBT (net.minecraft.nbt.CompoundNBT)5 IBPPartBlock (com.bluepowermod.api.multipart.IBPPartBlock)4 TileBPMicroblock (com.bluepowermod.tile.TileBPMicroblock)3 TileInsulatedWire (com.bluepowermod.tile.tier1.TileInsulatedWire)2 Nullable (javax.annotation.Nullable)2 BlockState (net.minecraft.block.BlockState)2 Direction (net.minecraft.util.Direction)2 StringTextComponent (net.minecraft.util.text.StringTextComponent)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 BlockBPMultipart (com.bluepowermod.block.BlockBPMultipart)1 AABBUtils (com.bluepowermod.util.AABBUtils)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 net.minecraft.block (net.minecraft.block)1 Material (net.minecraft.block.material.Material)1 LivingEntity (net.minecraft.entity.LivingEntity)1