use of gregtech.common.blocks.BlockFrame in project GregTech by GregTechCEu.
the class CommandRecipeCheck method prettyPrintItemStack.
public String prettyPrintItemStack(ItemStack stack) {
if (stack.getItem() instanceof MetaItem) {
MetaItem<?> metaItem = (MetaItem<?>) stack.getItem();
MetaValueItem metaValueItem = metaItem.getItem(stack);
if (metaValueItem == null) {
if (metaItem instanceof MetaPrefixItem) {
Material material = ((MetaPrefixItem) metaItem).getMaterial(stack);
OrePrefix orePrefix = ((MetaPrefixItem) metaItem).getOrePrefix();
return "(MetaItem) OrePrefix: " + orePrefix.name + ", Material: " + material + " * " + stack.getCount();
}
} else {
if (MetaItems.INTEGRATED_CIRCUIT.isItemEqual(stack)) {
return "Config circuit #" + IntCircuitIngredient.getCircuitConfiguration(stack);
}
return "(MetaItem) " + metaValueItem.unlocalizedName + " * " + stack.getCount();
}
} else if (stack.getItem() instanceof MachineItemBlock) {
MetaTileEntity mte = MachineItemBlock.getMetaTileEntity(stack);
if (mte != null) {
String id = mte.metaTileEntityId.toString();
if (mte.metaTileEntityId.getNamespace().equals("gregtech"))
id = mte.metaTileEntityId.getPath();
return "(MetaTileEntity) " + id + " * " + stack.getCount();
}
} else {
Block block = Block.getBlockFromItem(stack.getItem());
String id = null;
if (block instanceof BlockCompressed) {
id = "block" + ((BlockCompressed) block).getGtMaterial(stack.getMetadata()).toCamelCaseString();
} else if (block instanceof BlockFrame) {
id = "frame" + ((BlockFrame) block).getGtMaterial(stack.getMetadata()).toCamelCaseString();
} else if (block instanceof BlockMaterialPipe) {
id = ((BlockMaterialPipe<?, ?, ?>) block).getPrefix().name + ((BlockMaterialPipe<?, ?, ?>) block).getItemMaterial(stack).toCamelCaseString();
}
if (id != null) {
return "(MetaBlock) " + id + " * " + stack.getCount();
}
}
// noinspection ConstantConditions
return stack.getItem().getRegistryName().toString() + " * " + stack.getCount() + " (Meta " + stack.getItemDamage() + ")";
}
use of gregtech.common.blocks.BlockFrame in project GregTech by GregTechCEu.
the class FoamSprayerBehavior method onItemUse.
@Override
public ActionResult<ItemStack> onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack itemStack = player.getHeldItem(hand);
IFluidHandlerItem fluidHandlerItem = itemStack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
FluidStack fluidStack = fluidHandlerItem.drain(Integer.MAX_VALUE, false);
if (fluidStack != null && fluidStack.amount >= FLUID_PER_BLOCK) {
BlockPos offsetPos = pos.offset(facing);
IBlockState initialBlockState = world.getBlockState(pos);
IBlockState offsetState = world.getBlockState(offsetPos);
if (initialBlockState.getBlock() instanceof BlockFrame) {
int blocksToFoam = fluidStack.amount / FLUID_PER_BLOCK;
int blocksFoamed = foamAllFrameBlocks(world, pos, blocksToFoam, player.isSneaking());
if (!player.capabilities.isCreativeMode) {
fluidHandlerItem.drain(FLUID_PER_BLOCK * blocksFoamed, true);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);
} else if (offsetState.getBlock().isReplaceable(world, offsetPos)) {
int blocksToFoam = fluidStack.amount / FLUID_PER_BLOCK;
int blocksFoamed = foamReplacableBlocks(world, offsetPos, blocksToFoam);
if (!player.capabilities.isCreativeMode) {
fluidHandlerItem.drain(FLUID_PER_BLOCK * blocksFoamed, true);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);
}
}
return ActionResult.newResult(EnumActionResult.PASS, itemStack);
}
Aggregations