use of com.eerussianguy.firmalife.te.TELeafMat in project firmalife by eerussianguy.
the class BlockLeafMat method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
ItemStack held = player.getHeldItem(hand);
if (held.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
return false;
TELeafMat te = Helpers.getTE(world, pos, TELeafMat.class);
if (te != null) {
IItemHandler inventory = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (inventory != null) {
ItemStack tryStack = new ItemStack(held.getItem(), 1);
if (DryingRecipe.get(tryStack) != null && inventory.getStackInSlot(0).isEmpty()) {
ItemStack leftover = inventory.insertItem(0, held.splitStack(1), false);
ItemHandlerHelper.giveItemToPlayer(player, leftover);
te.start();
te.markForSync();
return true;
}
if (held.isEmpty() && player.isSneaking()) {
ItemStack takeStack = inventory.extractItem(0, 1, false);
Helpers.spawnItemStack(world, pos, takeStack);
te.deleteSlot();
te.clear();
te.markForSync();
}
}
}
}
return true;
}
use of com.eerussianguy.firmalife.te.TELeafMat in project firmalife by eerussianguy.
the class BlockLeafMat method breakBlock.
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
TELeafMat te = Helpers.getTE(world, pos, TELeafMat.class);
if (te != null) {
te.onBreakBlock(world, pos, state);
}
super.breakBlock(world, pos, state);
}
use of com.eerussianguy.firmalife.te.TELeafMat in project firmalife by eerussianguy.
the class LeafMatProvider method getTooltip.
@Nonnull
@Override
public List<String> getTooltip(World world, @Nonnull BlockPos pos, @Nonnull NBTTagCompound nbt) {
List<String> currentTooltip = new ArrayList<>();
TileEntity te = world.getTileEntity(pos);
if (te instanceof TELeafMat) {
TELeafMat leafMat = (TELeafMat) te;
ItemStack mainSlot = leafMat.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).getStackInSlot(0);
DryingRecipe recipe = DryingRecipe.get(mainSlot);
if (!mainSlot.isEmpty() && recipe != null) {
long remainingTicks = leafMat.getTicksRemaining();
switch(ConfigTFC.Client.TOOLTIP.timeTooltipMode) {
case NONE:
break;
case TICKS:
currentTooltip.add(new TextComponentTranslation("waila.tfc.devices.ticks_remaining", remainingTicks).getFormattedText());
case MINECRAFT_HOURS:
long remainingHours = Math.round(remainingTicks / (float) ICalendar.TICKS_IN_HOUR);
currentTooltip.add(new TextComponentTranslation("waila.tfc.devices.hours_remaining", remainingHours).getFormattedText());
break;
case REAL_MINUTES:
long remainingMinutes = Math.round(remainingTicks / 1200.0f);
currentTooltip.add(new TextComponentTranslation("waila.tfc.devices.minutes_remaining", remainingMinutes).getFormattedText());
break;
}
currentTooltip.add(new TextComponentTranslation(recipe.getOutputItem(mainSlot).getTranslationKey() + ".name").getFormattedText());
}
}
return currentTooltip;
}
Aggregations