use of pl.asie.charset.lib.notify.Notice in project Charset by CharsetMC.
the class TileEntityDayBarrel method activate.
// * Left-Click Right-Click
// * No Shift: Remove stack Add item
// * Shift: Remove 1 item Use item
// * Double: Add all but 1 item
public boolean activate(EntityPlayer player, EnumFacing side, EnumHand hand) {
if (lockable.hasLock())
return false;
ItemStack held = player.getHeldItem(hand);
if (!world.isRemote && isNested(held) && (item.isEmpty() || itemMatch(held))) {
new Notice(notice_target, new TextComponentTranslation("notice.charset.barrel.no")).sendTo(player);
return true;
}
if (doubleClickHandler.isDoubleClick(player) && !item.isEmpty()) {
addAllItems(player, hand);
return true;
}
doubleClickHandler.markLastClick(player);
// right click: put an item
if (held.isEmpty()) {
info(player);
return true;
}
switch(insertFromItemHandler(player, false)) {
case PASS:
break;
case SUCCESS:
return true;
case FAIL:
info(player);
return true;
}
if (!canInsert(held)) {
info(player);
return true;
}
boolean hadNoItem = item.isEmpty();
int free = getMaxItemCount() - getItemCount();
if (free <= 0) {
info(player);
return true;
}
int take = Math.min(free, held.getCount());
if (take > 0) {
ItemStack toInsert = held.copy();
toInsert.setCount(take);
ItemStack leftover = insertionView.insertItem(0, toInsert, false);
take -= leftover.getCount();
if (take > 0) {
held.shrink(take);
if (hadNoItem) {
markBlockForUpdate();
}
} else {
info(player);
}
}
return true;
}
Aggregations